I'm trying to work on a few devices to get their values transformed into something more in line with how my zigbee devices display values of devices.
To start I want to convert the value of my humidity sensor from '51.466999' to just read '51' or better yet '51%' or maybe '51.4%'.
Looking at the details for the device association I see theres an expression input but it's unclear exactly what the format should be to do this or if i can use concatenation to add string characters for units (Degrees Celsius, Watts, Volts, %, etc) .
It says you can use math operators or functions. When I search the documentation I saw a few references to Round() or Int() or Trunc() to either transform the number or cast it or truncate it but I cant figure out the exact syntax to put in the expression box and the 500 pages of documentation is virtually impossible to search on this. I can't find anything in this forum with the search either because homeseers search is probably the worst user experience on the planet. It literally gives you a list of 500 forums to manually pick the one you want to search on and they aren't in any order so its impossible to find the mcsmqtt forum and just search that.
Section 4.1.15 gives some hints on transformations. Section 6.3 however refers to round() being used but then the function signatures below that show it as Round()
I've tried different variations of the following and have had no success yet:
Int($$PAYLOAD)
Round($$PAYLOAD,1)
<<Int($$PAYLOAD)>>
<<Round($$PAYLOAD,1)>>
<<Round($$PAYLOAD:,1)>>
Int($$VALUE)
All I ever get is just 0.00000 for the device value after that.
Is there a guide out there thats just on the format of how to write expressions and which variable is which like $$PAYLOAD, $$VALUE, etc, and which functions can be used.
Theres also references to round() Round() and ROUND() in some places so I'm not sure what the proper casing is if its all lower, all upper, or sentence case for the functions. I've searched the documentation for examples of Round( and have seen references to using << >> around the expression and sometimes not so it's unclear if brackets are required as well.
every reference to the variables I've seen is that they are all $$ and upper case.
Not sure what the difference is between $$PAYLOAD and $$VALUE. the documentation refers to $$VALUE as the device value and the $$PAYLOAD as the last MQTT value received. I'm not sure which variable I want to transform and what the order of operations is. is the device value set and then you transform it or is the mqtt value received, then transformed, then placed in the device. So I'm not sure when in the pipeline the expression contents are run.
Documentation is so great but very hard to search and virtually impossible to read the whole thing due to its size. I commend you on your documenting everything this plugin can do.
To start I want to convert the value of my humidity sensor from '51.466999' to just read '51' or better yet '51%' or maybe '51.4%'.
Looking at the details for the device association I see theres an expression input but it's unclear exactly what the format should be to do this or if i can use concatenation to add string characters for units (Degrees Celsius, Watts, Volts, %, etc) .
It says you can use math operators or functions. When I search the documentation I saw a few references to Round() or Int() or Trunc() to either transform the number or cast it or truncate it but I cant figure out the exact syntax to put in the expression box and the 500 pages of documentation is virtually impossible to search on this. I can't find anything in this forum with the search either because homeseers search is probably the worst user experience on the planet. It literally gives you a list of 500 forums to manually pick the one you want to search on and they aren't in any order so its impossible to find the mcsmqtt forum and just search that.
Section 4.1.15 gives some hints on transformations. Section 6.3 however refers to round() being used but then the function signatures below that show it as Round()
I've tried different variations of the following and have had no success yet:
Int($$PAYLOAD)
Round($$PAYLOAD,1)
<<Int($$PAYLOAD)>>
<<Round($$PAYLOAD,1)>>
<<Round($$PAYLOAD:,1)>>
Int($$VALUE)
All I ever get is just 0.00000 for the device value after that.
Is there a guide out there thats just on the format of how to write expressions and which variable is which like $$PAYLOAD, $$VALUE, etc, and which functions can be used.
Theres also references to round() Round() and ROUND() in some places so I'm not sure what the proper casing is if its all lower, all upper, or sentence case for the functions. I've searched the documentation for examples of Round( and have seen references to using << >> around the expression and sometimes not so it's unclear if brackets are required as well.
every reference to the variables I've seen is that they are all $$ and upper case.
Not sure what the difference is between $$PAYLOAD and $$VALUE. the documentation refers to $$VALUE as the device value and the $$PAYLOAD as the last MQTT value received. I'm not sure which variable I want to transform and what the order of operations is. is the device value set and then you transform it or is the mqtt value received, then transformed, then placed in the device. So I'm not sure when in the pipeline the expression contents are run.
Documentation is so great but very hard to search and virtually impossible to read the whole thing due to its size. I commend you on your documenting everything this plugin can do.
Comment