Hi there!
I have a sonoff basic driven by Tasmota. I use this device as garage door opener. It worked well but hass and tasmota changed the handling of mqtt sensors in last releases (did not unterstand exactly what).
Now, if hass has to restart, the state of the sensor-switch is always open (sensor off / reed switch off) although the sensor is on ( garage door closed).
An here is the problem:
Hass mqtt auto detection (tasmota setoption19 1) detects
a rssi - sensor
the switch (power on/off)
and a binary sensor (reed-switch on switch1)
This should be ok.
This entities are subscribed by hass.
The binary reed-switch sensor is only updated when hass receives an
07:43:02 MQT: stat/sonoff-garage-1/SWITCH1 = {“STATE”:“OFF”} or {“STATE”:“OFF”}
But after a hass restart the binary sensor state isn’t be updated because the sonoff sends teleperiod topic for the sensor with
07:44:40 MQT: tele/sonoff-garage-1/SENSOR = {“Time”:“2020-04-20T07:44:40”,“Switch1”:“OFF”} (beibehalten)
and this topic is not subscribed by hass mqtt auto-detection… I can solve this issue with a automation (after hass start do …), but this is not a nice solution.
Am I able to subscribe manually the SENSOR message to? Bind it to the SWITCH1 ?
I tried to create a tasmota rule … without success.
The problem is the SENSOR information is only send during the tele/ messages. If you receive them when a tele/ message is received, it is already subscribed.
2 solutions :
1/ ask for the state on a hass restart
2/ increase the teleperiod to 10 seconds or so
Unfortunately hass doesn’t receive them. So my question is how could I make hass being aware this message or update the stat/sonoff-garage-1/SWITCH1 state so that hass is being aware of the actual state of the reed switch (SWITCH1 on or off).
To decrease the teleperiod would have no effect.
If I understand mqtt the right way in tasmota a rule like:
Rule1 on switch1#state=off do publish stat/sonoff-garage-1/SWITCH1 {“STATE”:“OFF”}
endon …
could solve the binary sensor update problem. But this example didn’t work for me. I’am not very experienced with tasmota rules.
If Tasmota send a message like tele/sonoff-garage-1/SENSOR = {“Time”:“2020-04-20T07:44:40”,“Switch1”:“OFF”} regularly, you can create a sensor :
Yes Francis, this would work. I tried this before.
But the stupid thing is, the SWITCH1 - sensor , wich is subscribed by hass reacts immediately. And the platform mqtt sensor is depending from one more event (teleperiod).
I think I will another try with rules in tasmota.