I use Hass.io on the raspberry pi 3 with the Mosquito broker add on.
The switchtes and lights are working like a charm (use a lot of sonoff with tasmota).
But I have one problem:
If Home Assistant does a restart, the state of either the switch or the lights is not persistent. Meaning they are still “on” but Home Assistant does not know the state. I thougt the “retain” flag would solve this problem.
I don’t know about Tasmota but I use the Espurna firmware and inside the configs I have an option that sets what should be done by the Sonoff: turn on, turn off or remember last state.
Is that the issue? I though that pertained to if the sonoff loses power, when the power is restored to the sonoff, it will turn the relay on. If HA restarts, the sonoff doesn’t lose power or see a change in mqtt command, its just HA doesn’t know which state the sonoff is in. I thought HA would ask mqtt on restart what the state is and adjust its state.
I thought HA would ask mqtt on restart what the state is and adjust its state.
I thought that too!
I testet it with one sonoff switch which got the “cmnd/sonoff/PowerRetain on” message.
Home Assistant got the right state after restarting.
The other switch, which did not get the message and Home Assistant did not get the right state.