Strange behavior switch display

Hello,

I noticed some strange behavior in my hass.io.

When I leave my house and check my hass.io I see that some switches that were ON at home are now displayed as OFF, when I know that the devices behind it are ON.
It stays that way when i return home :expressionless:

The switch that was OFF at home, was now ON when away from home (but the device behind it is OFF)

Besides this, I also noticed that this kind of behavior takes place when I restart Hass.io.
The displayed switches states don’t always match the real on/off state of the device.

?? how to solve this

Please provide details, because there are many components involved.
Like: Which frontend (and maybe browser), switch brand, how do you manage API access on these devices… :wink:

OK, I will try

Running Hass.io 0.77.3 on a raspberry pi 2B

Swithes are Sonoff basic and TH10 flashed with tasmota 6.2.0 for the basics and 6.2.1 for the TH10

With API access I think you mean MQTT what I’m using

switch:
  - platform: mqtt
    name: "Sonoff Switch 01"
    command_topic: "cmnd/BasicSwitch01/power"
    state_topic: "stat/BasicSwitch01/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    
  - platform: mqtt
    name: "Centrale afzuiging"
    command_topic: "cmnd/BasicSwitch02/power"
    state_topic: "stat/BasicSwitch02/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    
  - platform: mqtt
    name: "Washok"
    state_topic: "stat/TH10sensor/POWER"
    command_topic: "cmnd/TH10sensor/POWER"
    availability_topic: "tele/TH10sensor/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

No one that knows the solution?

For a reason hass.io doesn’t get the actual state of my sonoff after reboot. or connection loss :cold_sweat:

Hey, is it not working for all or only for some of your devices?
If only for some you could check it you have retain configured for all of them.
At least in your snipped Washok has retain set to false.

It happens to all three i have.

Strangely It looks like what ON, will display as OFF and vice versa after reboot.
So after reboot the devices that are running, are marked as OFF in Hass.io.
I played around with retain, but that didn’t solve it.

Look at this;

Thank you Sjee,. I executed this now.
restarted and looks good
hopefully it stays that way