JS thing transformation

I have some things that provide temperature via MQTT. From time to time they send 0 when really they should send NULL. What is the correct way to transform 0 to NULL for OH3 in the thing definition? At the moment I’m using this JS:

(function(i) {
    return ( i == 0 ? null : i );

I think OH3 is simply ignoring zero values now rather than updating the linked item state to NULL. Is there a way to provide NULL?


You should be trying to set the Item to UNDEF really. This state is used to indicate a binding cannot determine some value, there is a subtle difference to NULL which means uninitialized so far.

Transformations always return strings, which the framework parses into whatever the channel/Item needs. Try returning the string “UNDEF” from your javascript.

This is interesting, because I think I’ve seen the same - is this on a Number type Channel?

Great, thanks, just what I needed to know.

Yes it is