I recently embarked on a journey to integrate my Sonoff devices with MQTT, and I must say, it’s been a rewarding experience! Let me share my journey and some tips that might help others facing similar challenges.
The Setup
I started by flashing my Sonoff Bridge with Tasmota, which worked seamlessly. The device connected to my Mosquitto broker without any hiccups, and I could see the motion sensor data flowing in. The logs were clear and helpful, showing the connection status and client details. It was a great start!
The Challenge
However, things got a bit tricky when I tried to get the devices to show up in Home Assistant. Despite configuring the config.yaml correctly, the entities weren’t appearing on my Lovelace dashboard or in the entity list. I was puzzled—why wasn’t it working as expected?
The Solution
After some research and trial and error, I realized that the issue might be with the discovery_prefix and how Home Assistant interprets MQTT topics. I adjusted the configuration to ensure that the discovery prefix aligned perfectly with what Home Assistant expects. Here’s what worked for me:
yaml
mqtt:
broker: 10.0.0.33
port: 1883
discovery: true
discovery_prefix: homeassistant
binary_sensor:
- platform: mqtt
state_topic: ‘tele/RF_Bridge/RESULT’
name: ‘Window Sensor’
value_template: ‘{{value_json.RfReceived.Data}}’
payload_on: ‘1CE2DA’
payload_off: ‘1CE2DAoff’
device_class: motion
optimistic: false
qos: 1
retain: false
The Outcome
Once I made these adjustments, the entities started appearing in Home Assistant! It was a relief to see everything working smoothly. The motion sensor now triggers automations, and I can monitor its status from anywhere in the house.
Tips for Others
- Double-Check Configurations: Ensure that your
discovery_prefixand MQTT topics match exactly what Home Assistant expects. - Use Developer Tools: The developer tools in Home Assistant are invaluable for testing templates and debugging issues.
- Community Support: Don’t hesitate to reach out to the community if you’re stuck. Forums and Discord channels are goldmines of information and support.
Final Thoughts
This experience taught me the importance of meticulous configuration and the value of persistence. MQTT is a powerful tool, and with the right setup, it can seamlessly integrate into your smart home ecosystem. I’m excited to explore more MQTT-based projects and continue expanding my smart home setup!
Happy tinkering everyone! ![]()