Today I’ve upgraded my system from openhab 2.3 to 2.4. After that I installed the embedded mqtt broker and the new mqtt2 binding.
I have a few knx items (with knx binding 2.4) that represent a temperature or light intensity.
From knx.items:
Number Lichtsterkte_Buiten "Lichtsterkte Buiten [%.1f Lux]" <temperature> (INFO) { channel="knx:device:knxd:generic:lichtsterkte_buiten" }
Number Temperatuur_Buiten "Temperatuur Buiten [%.1f °C]" <temperature> (INFO) { channel="knx:device:knxd:generic:temperatuur_buiten" }
Number Temperatuur_Binnen "Temperatuur Binnen [%.1f °C]" <temperature> (INFO) { channel="knx:device:knxd:generic:temperatuur_binnen" }
With openhab 2.3 and mqtt binding 1.0, I used to send these values to a mqtt broker using the following in mqtt.items:
Number Lichtsterkte_Buiten "Lichtsterkte Buiten [%.1f Lux]" <temperature> { mqtt=">[openhab:lichtsterkte_buiten:state:*:default]" }
Number Temperatuur_Buiten "Temperatuur Buiten [%.1f °C]" <temperature> { mqtt=">[openhab:temperatuur_buiten:state:*:default]" }
Number Temperatuur_Binnen "Temperatuur Binnen [%.1f °C]" <temperature> { mqtt=">[openhab:temperatuur_binnen:state:*:default]" }
That seemed to work OK. Now I’m trying to do the same with the mqtt2 binding, but that doesn’t seem to work for me.
Whenever I add the knx item (e.g. ‘temperatuur_buiten’) to the generic mqtt thing channel it seems to override the knx item value. And so in the end nothing gets published to the mqtt broker because nothing is feeding the item anymore…
Guys please read the detailed binding documentation. stateTopic and commandTopic are well described.
And yes the MQTT binding assumes it is the only source for an Item state and will override any existing state with the mqtt topic payload. If no payload is received yet the item is initialised with UNDEF.
All new bindings are doing it this way. If someone wants to synchronise two items (KNX and MQTT for example) he/she would use a follow profile.
I admit I’m a little confused about where to find the canonical documentation for the MQTT binding. I would expect it to be here: https://www.openhab.org/addons/bindings/mqtt/
However, that page doesn’t contain any of the information you are referring to.
Thx David, this confirms the behaviour I saw. Is there any documentation about this behaviour somewhere? Also which bindings do it like that and which don’t? Doesn’t seem completely consistent to me.
I had worked around it using rules. I’ll take a look to the follow profile.