I’m using a Sonoff switch running Tasmota, I’ve set the PowerOnState = 1, so that the switch turns on when powered and stays on, in order to allow people to use the light connected to the Sonoff with its old fashioned switch.
The problem is that after the Sonoff has been powered on with a power cycle (and not through HA or its own push button), HA seems to reverse the state of the switch and forces it to off state a few seconds after the Sonoff boot.
Is it possible to let HA know that the switch is on and that if it’s already on it has to stay that way?
I think the problem is that when the switch is powered on with a power cycle (with PowerOnState set to 1), the stat message is not generated from the switch. So HA is not aware of the change of status.
I’ve also asked in Tasmota’s Github (see https://github.com/arendst/Sonoff-Tasmota/issues/372), I confirm that the problem is that the Sonoff-tasmota sends the stat message 10 seconds after is powered on with a power cycle. So HA acts before the stat message is sent and powers off the switch.
Is it possible to do something to avoid this situation?
Hi there - followed your thread in the Sonoff issues tracker. I see they recommend changing HASS settings to not turn off the relay within the 10 seconds it takes Sonoff to publish the stat message.
@asp that… is really unfortunate. Having my lights turn themselves back off again when I use them at the hard-wired switch is really not a good result. I guess I’m going to have to learn the intricacies of MQTT.
@asp Tasmota sends out an LWT topic: /x/y/tele/sonoff/LWT Online which turns to /x/y/tele/sonoff/LWT Offline when the mqtt broker cannot connect to the Sonoff anymore.
Now, reset your light switch to off via an automation when the Sonoff is turned off when /x/y/tele/sonoff/LWT == Offline for more than a minute for instance.
I have the same problem. If the switch in HA is off and i turn off/on on the wall switch and PowerOnState 1 the light turns on and after 3 seconds it turns off.
Thanks to the suggestion of @abmantis I finally decided to switch to ESPurna and I’m now able to use my Sonoff together with a “dumb” switch. You can find the details here.