Sonoff (Tasmota) lights status not updating

Lately, i’m having way too many problems with my HA. Trying to fix something with my zigbee switch i rolled back and then more problems started.

I have two sonoff basics and 3 sonoff in wall switches. I can turn on everything from HA, the status changes to on and after a second back to off. The lights/devices stays on thought. From all these devices only one of the sonoff basic works and shows everything correct. This is how i have the light configured. Mosquitto is updated to latest version and Hassio as well.

  • platform: mqtt
    name: OfficeLamp
    state_topic: “stat/officeLamp/POWER”
    command_topic: “cmnd/officeLamp/POWER”
    availability_topic: “tele/officeLamp/LWT”
    qos: 0
    optimistic: false
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”

This occurs because HA is not receiving the status message back from the sonoff indicating that the light has changed state, so HA assumes it has not.

You need to use another client such as mosquitto_sub or MQTT.FX to see what each sonoff is sending, and match the state_topic to that.

For instance

mosquitto_sub -t "#" -v

You many need to add host, username and password parameters, depending on your setup.

And can you please edit your original post and format the yaml snippet using the instructions in the blue box at the top of the page.

I figure that it would be something like this but why? I mean I didn’t change a thing. And even I copied the back up from the one sonoff basic that works to the other one (I changed of course the names) and it didn’t work.

I think to start with you have to figure out what has changed, by running the other client and seeing what messages are being sent.

Once you have discovered what is happening, it will probably become apparent why it is.

So with mqtt.fx i found that it for stat/lamp/POWER is the one for the status. I have the same in my lights.yaml under platform: mqtt. I even changed the topics because with mqtt.fx i found also other similar topics from older installations but still no luck, after a second it goes back to off.

Can you paste the yaml from your current configuration (formatted using the instructions in the blue box at the top of the page) and the output from MQTT.FX showing the command and status messages for the light.

lights.yaml

  • platform: mqtt
    name: Closet
    state_topic: “status/closet/POWER”
    command_topic: “comnd/closet/POWER”
    availability_topic: “tel/closet/LWT”
    qos: 0
    optimistic: false
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    retain: true

and from mqtt.fx

That’s interesting because the command being sent doesn’t actually correlate with the yaml. The payload in the yaml is all uppercase, but the output is “On”.

Are you sure the file is being loaded by HA correctly? Things like the correct file name is being included (if you are using more than one configuration file) and that HA is restarting after you have changed it.

Everything loads just fine. Don’t think that the command published is case sensitive.

I changed the yaml file to match the “On” just to test but nothing changed.

It definitely is. The command was not generated by that yaml configuration.

Tasmota accepts the command in any case, so will turn the light on. However HA is case sensitive, so will not match ON as it is not the same as the command that was sent.

What do you have in the configuration for the other Sonoffs that are working correctly?

And you really need to format your code properly in your posts.

Only one works and it has the same as the other ones but i have it as a switch not as a light

  - platform: mqtt
    name: Boiler
    state_topic: "stat/boiler/POWER"
    command_topic: "cmnd/boiler/POWER"
    availability_topic:  "tele/boiler/LWT"
    qos: 0
    optimistic: false
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

gpbenton

Even if it is I have tried everything, i even loaded the configuration from the one sonoff that works to another one.

So, I copied on of the lights to the switch.yaml and it worked. When i looked the light entities i have in the attributes it says “supported_features: 0”.

I am completely confused. I have two flux_led lights and they work which means that the lights.yaml is ok and it loads correctly.

The easy workaround is to put all of them under the switches.yaml and change the icon but I want to make it work…

You need to find the place where it has the payload defined as “On” and replace it with “ON”. This is not the place where you posted your first configuration, as that will send “ON”, and that is not happening.

Don’t know if you read the previous comment but when i copied the everything from lights.yaml to switch.yaml it worked. So, don’t think that “On”, “ON” etc has something to do with my problem. Also, even if it was the probelm it would be only for one of them as i changed the settings only from one sonoff device.

Yes, because at that point it would have sent “ON”, because it is reading that file. In the original location, it wasn’t being used, and is not sending “ON”.

Now you lost me. what is the difference of running the same code in 2 different files (not simultaneously)? Of course there is no difference as long as they files are being loaded correctly.

PS: of course i don’t have the same code to 2 files the same time

The original file is not being used, otherwise it would send “ON” not “On”. When you copied that configuration to a file that is being used, it worked fine.

Somewhere in your configuration, you have a light setting that is sending “On”. It may be in a different file, which is being used by HA rather than the one you think you are using.

I’ve checked all files and I have nothing that sends ON, instead of On. The On command you saw on mqtt.fx it wasn’t from HA but a command I send. I’m pretty positive that it’s not case sensitive because firstly I haven’t changed anything and it was working before the rollback and secondly in the automaton I have for the water heating I’m sending on and off commands and it works.

I changed also the name of the yaml with the lights but the problem remains… Not sure what the hell is going on.

:sob: If you had said this earlier, I would have come to completely different conclusions.

I think we need to erase the last few posts and start again with some good data. Use the MQTT.FX tool to capture the messages sent when you change the switch on HA from off to on. Then we can see the messages that HA sends, and the response it gets.