I got mosquitto set up and it works very well. I like having the ability to run mosquitto_sub and watch all the messages and I guess because it’s a completely separate docker instance in hass.io when you restart HA, it retains everything which is IDEAL.
Thanks for the info RyanEwen.
P.S. That pulsetime thing is pretty awesome. I found it too, right after building my garage door monitors while I was reading through all the comments below the Dr Zzz video.
just wanted to share my setup that I’ve been working on. quick disclaimer, I haven’t hooked up the final project yet (hopefully doing that this weekend), but this seemed to work fine while testing with a breadboard at my desktop.
Rule1
ON switch1#boot DO var1 %value% ENDON
ON switch2#boot DO var2 %value% ENDON
ON mqtt#connected DO BACKLOG event SetClosed=%var1%; event SetOpened=%var2% ENDON
ON switch1#state DO event SetClosed=%value% ENDON
ON switch2#state DO event SetOpened=%value% ENDON
ON event#SetClosed DO publish2 ha/garage/closed %value% ENDON
ON event#SetOpened DO publish2 ha/garage/opened %value% ENDON
Rule1 is where the most of the magic happens. When the board boots, I use switch<x>#boot to get the value of the alarm contact sensors and set them both to a variable. Then, when the MQTT connection is initialized (mqtt#connected), I immediately publish those values via custom events (SetClosed & SetOpened). Finally, I use switch<x>#state to publish any alarm contact changes.
Some key points… publish2 is used instead of publish since publish2 uses a retain flag. This enables HomeAssistant to grab the last published message upon booting. Also, the switch<x>#boot event is nice because it lets me capture the alarm contact states immediately upon the ESP8266 boot instead of waiting for a state change.
I haven’t started testing the HomeAssistant side of things yet, but it will basically be two mqtt binary sensors and a template cover. The template cover will have open/close/stop actions that all publish an mqtt ON message to the POWER1 topic of my Tasmota. Then the position template will look something like the following pseudo-code:
if (closedSensor = 1) {
return 0
}
if (openedSensor = 1) {
return 100
}
return 50
hope this helps someone. i’ll report back once everything is setup entirely.
I’m migrating away from the tasmota/sonoff managed solution to my own ESPHome one. I posted the ESPHome.io yaml file here. It avoids using mqtt and brings all “decision making” into the esphome device, closer to the hardware. Now I just need to build the hardware for it.
It is still working for me. Are you still using the MQTT integration and discovery or did you switch to Tasmota integration? I’m still on discovery and MQTT integration and no issues.
David, thanks for your pointer. I added tasmota integration to HA, upgraded my tasmota from 8.3.1 to 9.2 and all 8 devices show up automatically. No need to add power state startup automation. Thanks again.
Weird. I am only using Mosquitto broker with MQTT integration. I also use auto-discovery and it’s worked like that for 3 years once I set the retain options properly. No idea why it would have just stopped working on your system. I tried the Tasmota integration but it didn’t add any value and in fact was less useful than the ‘old’ way.