Sliders revert back to lightning bolts after Restart

Every time I restart HA the sliders are replaced with lighting bolts. This only happens in my pool control card. If I toggle any of the lighting bolts they all return to sliders which is what I want.
Any suggestions?

This is normal where the entity has the state of unknown - HA can’t tell if it’s on, or off, or what, so it gives you both controls.

The only way around this is to switch to using an integration that can update the state at startup.

Why only on this one card? No other cards do that.

Had the same issue. Setup an automation on HA restart to trigger MQTT commands for them to report status and the lightning bolts went back to toggles.

For mqtt just set the retain flag for the messages so they are immediately reported to home assistant when it restarts and connects to the broker.

For some reason the retain flag never worked for me. Is that on the device sending the MQTT message or in HA?

The sending device.

I have retain: true in every instance but still have the same issue.
Here is an example of one of many commands.

- platform: mqtt
  name: "Light Off"
  state_topic: "PL-STATE"
  command_topic: "/POOL/LIGHT/ON"          
  payload_on: "PL-OFF"    
  payload_off: "0"
  state_on: "PL-OFF"
  state_off: "0"
  optimistic: false
  qos: 0
  retain: true

You want the state retained not the command. That will cause you issues.

Hi Tom, Can you please give an example how to do a state retain?

Nope. I know nothing about your device. This is good advice:

I don’t use Tasmota. I have coded ESP32’s. The code has not change for some time. I believe this is an HA issue.

It was general advice about command and state topics and which should be retained that you were supposed to take away from that.

Again, I don’t believe this is a retain issue. The sliders resort back to (off/on) lightning bolts until toggled.
Not a state change issue. Thanks anyway…

The only way it won’t be unknown at start up is if the state topic is retained.

1 Like

It is a retain issue.

The state (message) currently isn’t retained, so at startup there’s no message at the topic for HA to use, so the entity is in the unknown state.

If your device set the retain flag, as tom keeps recommending, then the message would be there, and HA would know the state.

Thanks Tom! I’m researching how to do a “retained” on the ESP32 side of MQTT.
I’ll post once I have it figured out. Keith

Tom and Tinkerer, Got it working. The sliders are retained after an HA “RESTART”.
Per the pubsubclient documentation I added a “retained”.
Example:

client.publish("NL-STATE", "NL-ON", "retained");

All good now!
Thank you both, for all of your help.

1 Like