Latest openHAB here, with MQTT binding in use. I’ve defined a channel “mode” linked to an item “modus”, and since on the MQTT side valid values are “0” and “1” but switches in openHAB have valid values ON and OFF, I selected MAP as profile and added the following simple transformation:
key=value
0=OFF
1=ON
=default
Now when I change the state on the MQTT side, e.g. like that:
But: now when I modify the channel (e.g. with mosquitto_pub), I can see ON / OFF for a fraction of a second as the state value, but then it immediately changes to NULL; why that?
BTW, I had the same behaviour before I added =default to the transformation I used earlier.
Interestingly, I just re-created channel and item, and before altering the state within openWB, the new openHAB item showed OFF, which was the correct state. When I started modifying it within openWB, I get the former behaviour: ON/OFF for a fraction of a second, then NULL. So it seems to work openWB → openHAB, but the state is “overwritten” by NULL immediately.
Ah, when trying the other way (openHAB → openWB) and observing with MQTT Explorer:
if the value is 0 and clicking on the switch in openHAB, the value gets modified to 1, but the OH item stays OFF (icon) and NULL (text)
if the value is 1 and clicking on the switch in openHAB, the value stays 1 (but highlighted grey for a second in MQTT Explorer, so an update is sent), but openHAB shows OFF (icon) and NULL (text)