Hello community, I’m using Tasmota on Sonoff Basic version 5.12.0 integrated in HA. Everything works perfect, but there is one issue who are driving me crazy. If I used the wall switch to power off the Sonoff, then Power On again, the light will switch on correctly, but after a few seconds it switch off automatically.
On Sonoff I have:
PowerRetain On
PowerOnState 1 (Turn relay(s) on after power on)
But wait, if I stop the mosquitto service on HA, I don’t have this behaviour. After wall switch on, the light stays on. And doesn’t matter if the sonoff is configured on configuration.yaml on HA. Btw, this is the HA config (even I tried to remove it and restart HA, but the issue still persist, as I said the only way is stop mosquitto service)
Now I have only to understand what’s wrong on previous configuration, and what’s the config row who switch off the light after power on. I’ll try to add one by one.
If you publish the command as retained message the sonoff will get that immediately when powering up and act accordingly. In your case it gets the off command.
I would change the state message as retained and command not.
Or then you need to figure out another way of switching instead of the wall switch.
Not a waste of space because I have this problem too :-). But didn’t put much time to solve it. Please, may you explain what you did? How it was, and how it is now?
Having retain using Mqtt meens that the server will remember the message. You should enable PowerRetain on the sonoff, that will only remember the state, so if you restart HA it will still have the correct state.
But you shouldn’t have retain in HA since it then will remember the command, and when sonoff boots it will turn on as you wish but when it connects to the server it will get the retained off message and turn of after a couple of seconds.
Thank you for explanation, I just remove all the "retain: true" commands in every switch configuration and seem it works. Except for only one Sonoff/light who still switch off after power on! DAMN!
This is the config (absolutely the same for other sonoff), I’m gettin crazy to understand what’s wrong
You also need to remove the retained messages from the broker’s database, otherwise it will continue sending the last message sent with the retain flag set. You need to send a message to each topic with the retain flag set and a null payload such as
Thank you, but still have the issue, I also tried to stop HA and mosquitto service, then delete the HA DB (home-assistant_v2.db), start again, but everytime the sonoff connect to HA, it will be switched off! DAMN!!!
Thia is the command I used on HA:
You probably haven’t turned that specific sonoff on and off via HA after you changed the config?
It isn’t enough to just change the config, you to send a new message to the mqtt server by example you can turn the sonoff off and on in HA that will change the topic to not retaining the message. If you don’t you could still have an old message retained in the mqtt server.
Otherwise you could use the command you tried above but the topic has to be cmnd/ingresso2/POWER
Thank you to point me to a solution Here the mosquitto commands I used, maybe can be useful to others. Since the stored MQTT message will always override the PowerOnState, with the following command we can check all the stored mqtt messages:
This looks like hassio weirdness. You are probably better off installing mosquitto_pub on your windows machine and running the command from there. Just remember to add the -h parameter to specify the host where mosquitto is running.
My problem was Tasmota 6.4.1 it kept disconnecting and as soon as it connects it sends the retain message again and it switched off. went back to tasmota 6.2.1 and is working now.
here was my old sonoff console info: