Integrating OpenHAB and Home Assistant with MQTT: A Smooth Experience

Integrating different smart home platforms can sometimes feel like a puzzle, but I’ve found a seamless way to connect OpenHAB and Home Assistant using MQTT. Let me share my journey and some tips that might help you too!

I primarily use OpenHAB for its robust rules engine and community support, but I love how Home Assistant handles iOS HomeKit. To bridge both systems, I set up an MQTT event bus in OpenHAB. This allows me to access hardware-dependent devices like Z-Wave switches from Home Assistant without any hassle.

Setup Steps:

  1. Configure MQTT Event Bus: I edited the mqtt-eventbus.cfg file to structure the topics neatly. This ensures all items are published to the MQTT broker, making them accessible to Home Assistant.
  2. Retain Messages: I faced an issue where Home Assistant lost item states after restarts. The solution was to enable the retain flag in MQTT. This ensures states persist even after system restarts.
  3. Dual Broker Configuration: To avoid conflicts with existing MQTT settings, I added a second broker instance in mqtt.cfg with retention enabled. This keeps everything running smoothly without affecting other devices.

Example Configuration:
plaintext
broker=openhab-ret
statePublishTopic=openhab/out/${item}/state
commandPublishTopic=openhab/out/${item}/command

This setup has been a game-changer for me. It allows me to leverage the strengths of both platforms while maintaining a unified system. If you’re looking to integrate multiple systems, I highly recommend exploring MQTT as a versatile solution!

Any questions or tips from others on optimizing this setup would be greatly appreciated. Happy integrating! :rocket: