I have some items where I have to convert from w to kw, would it make sense to create a transformation for this, it works with rules but I need an extra item and a rule.
A transformation would make this easier, what do you think?
I do remember a question in here asking for an āaddā transformation.
So, I would find a transformation for single and simple math functions usefull. If one is really in the need for a more complex math function, there is always the possibility of using a rule.
I will check if can offer all simple ones by a single binding, that could even be as simple as adding multiply and add. The rest can be inverted / derived.
I just realized (some sleep does miracles) that the transformation does not suffice for my goal
My actual need is to create a graph based on the transformed number and it seems that I cannot transform on the channel, so the actual stored number is not converted.
The presently working way would be using a seperate item. This item could be updated by a rule, which in turn would make the (math) transformation useless.
@martinvw already knew that, the idea was to avoid that kind of setup!
The only way I see that can solve Martinās requirement is to transform the respective value when persisting (trigger in the database)
Martin - is this PR merged into openHAB now or was it decided to not add it after all? If itās in openHAB, do the āMATHā transform modifiers actually change the value of the item or just the display of the value?
One of my remote temperature sensors reports a value that I know is not accurate. When the MQTT message arrives, the Item receives the value and I display it in my Sitemap. I have a Rule that uses the sensor value and I have a line in the Rule to adjust the reading before I act on the value.
I could update the Itemās value in the Rule so that the correct value is in the Itemā¦ but updating the value will trigger the Rule (i.e., the Item was updated and it changed) thus a race condition. Having the ADD modifier in the transform would allow me to change the value when it is updated by a new MQTT message.
I have seen that a JS transform could accomplish this, but I have never used thatā¦ and I donāt know how to write the associated script. My preference would be to have one transform approach for all of my temperature sensors. The JS would have to code which sensors should be adjusted and which should not. Yes, if I use your suggested enhanced transform, Iād have different syntax for each Itemā¦ but it would be right up front in my Items definition and not tucked away in a script.