I am new to fhem.
I have device that transmits the power along with the serial number.
While indicating on UI I need to Subtract the value from specific formula.
Is there in any way in conf to define variable to store $serial_number which user can input.
Which I can use in expression eg.
attr MYDEVICE obj-h123-expr $val - $serial_number
I tried something like(may be a wrong as well) but its not working
define MYDEVICE ModbusAttr 1 1 192.168.101.1:503 TCP
attr MYDEVICE ReadingsVal($serial,"serial_number")
attr MYDEVICE obj-h123-expr $val - $serial
set MYDEVICE obj-h123-serial_number 1234
attr MYDEVICE obj-h123-poll 1
attr MYDEVICE obj-h123-reading power
Can someone help/advice ?
Let me know if I have to write new module it self for this.
Thanks in advance.
Where do $val and $serial_number come from?
The right way to calculate new values depending on Readings of some Fhem Devices ist using userReadings https://fhem.de/commandref_DE.html#readingFnAttributes
And to get input from user, you can for example define a dummy, and then in th UI you have the possibility to user the set button
Zitat von: amenomade am 09 Dezember 2018, 20:54:15
Where do $val and $serial_number come from?
The right way to calculate new values depending on Readings of some Fhem Devices ist using userReadings https://fhem.de/commandref_DE.html#readingFnAttributes
I just tried this to check if something like this works
Zitat von: amenomade am 09 Dezember 2018, 21:07:15
And to get input from user, you can for example define a dummy, and then in th UI you have the possibility to user the set button
Thanks for the pointers I will try this now and let you know.
Will it be possible to use this value while evaluating the expression?
If you define a dummydefine serialid dummy
and then through the UI you do set serialid 45616845498
then you can use this value in a userReading with {Value("serialid")}
@smarthacker, I cant believe that your Modbus device has two different values in one single register !
What's in the Modbus documentation for your device ?
@wzut not it do not have 2 different value in a single register. This is impossible I have 2 different values in 2 registers which I need to combine
Simply 32bit = 16bit (reg1) + 16bit (reg2)
Zitat von: amenomade am 09 Dezember 2018, 23:27:17
If you define a dummydefine serialid dummy
and then through the UI you do set serialid 45616845498
then you can use this value in a userReading with {Value("serialid")}
Thank you so much for the help. It did work but I need to exclude {}.
Value("serial")