This is interesting - thanks for posting and sharing! A few thoughts:
- Is there any reason that you’re not using the
availabilitytopic which zigbee2mqtt sends for each device? This is a topic which is available to me when using theattributeoutput of zigbee2mqtt, rather than thejsonoutput. As soon as the device disappears, the messageofflineis sent on theavailabilitytopic, which I subscribe to with openHAB and can then act upon. - Did you know that this is possible? If you used this
profilefeature, you could get rid of yourtransformationPatternJS transformation altogether. - Did you know that you can use
friendly-namein your zigbee2mqttconfiguration.yaml? It would make your openHAB configurations, and MQTT topics, a bit more human-readable, as it would remove0x00158d0001c2cc22and use whatever you specified asfriendly-name!
Obviously, it’s working for you, so no need to change anything really!
Oooh, and one more thing: you can also monitor (and control) the status of your bridge (CC2531 USB stick, for example)!