This is interesting - thanks for posting and sharing! A few thoughts:
- Is there any reason that you’re not using the
availability
topic which zigbee2mqtt sends for each device? This is a topic which is available to me when using theattribute
output of zigbee2mqtt, rather than thejson
output. As soon as the device disappears, the messageoffline
is sent on theavailability
topic, which I subscribe to with openHAB and can then act upon. - Did you know that this is possible? If you used this
profile
feature, you could get rid of yourtransformationPattern
JS transformation altogether. - Did you know that you can use
friendly-name
in your zigbee2mqttconfiguration.yaml
? It would make your openHAB configurations, and MQTT topics, a bit more human-readable, as it would remove0x00158d0001c2cc22
and 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)!