As a homeowner who recently upgraded to zigbee2mqtt 2.x, I wanted to share my experience and some tips that might help others navigating the same transition. The upgrade process was straightforward, but I encountered a few challenges along the way, particularly with legacy availability payloads in OpenHAB. Here’s what I learned and how I resolved the issues.
The Challenge with Legacy Availability Payloads
When upgrading from zigbee2mqtt 1.x to 2.x, one of the breaking changes involves the legacy_availability_payload setting. By default, this setting was set to true in older versions, but in 2.x, it’s false. This change affects how availability messages are sent to MQTT brokers, which can cause compatibility issues with certain integrations, like OpenHAB.
In my setup, I noticed that all availability channels in OpenHAB were throwing errors. For example, the aqaraContactSensor1 sensor was sending a JSON payload {"state":"online"} instead of the expected string online. This mismatch caused OpenHAB to throw errors because it couldn’t parse the JSON state into an OnOffValue type.
How I Fixed It
After some research, I realized that the issue stemmed from the new payload format in zigbee2mqtt 2.x. The solution was to modify the OpenHAB Thing configuration to handle the JSON payload correctly. Here’s the adjusted configuration I used:
yaml
Type switch : availability “Availability” [
stateTopic = “zigbee2mqtt/aqaraContactSensor1/availability”,
commandTopic = “zigbee2mqtt/aqaraContactSensor1/availability/set”,
onCommand = “online”,
offCommand = “offline”
]
By specifying the commandTopic and adjusting the onCommand and offCommand values, I ensured that OpenHAB correctly interprets the state changes from zigbee2mqtt. This fix resolved the errors and restored proper functionality.
Lessons Learned
- Understand Payload Formats: Always check the payload formats expected by your integrations, especially after major version upgrades.
- Configuration Flexibility: OpenHAB’s flexibility in handling different payload formats is a huge advantage. Take the time to adjust configurations to match your ecosystem.
- Community Resources: If you encounter similar issues, don’t hesitate to consult the zigbee2mqtt GitHub discussions or OpenHAB forums. The community is incredibly helpful!
Final Thoughts
Upgrading to zigbee2mqtt 2.x has been a rewarding experience. The improved stability and new features make it worth the effort. By addressing compatibility issues early, I ensured a smooth transition and enhanced my home automation setup.
If anyone else has questions about zigbee2mqtt or OpenHAB integrations, feel free to reach out! I’d be happy to share more tips or troubleshoot issues together.
Happy automating!