When I toggle the switch on in HA it correctly publishes the topic and body that reflects turning the relay on, but the switch imediatley turns off. I am lost as to see why it works this way
I just tweaked the HA Component to the following based on some further reading, but did not make a differnce, the switch in HA toggles off straight after turning on.
You have come across one of the limitations of the HA implementation of an MQTT switch - the payload for the command and the status messages have to be symmetrical. This is because the payload_on is used for both the command and must exactly match the status (subject to the value_template:)
As such, I donât think you can get your current messages to work. There are other ways, but I suggest that you make the command and status message have the relevant zone in the topic, and just have the payload as a simple ON or OFF
I have the same problem with asymmetrical payloads. MQTT Switch is an ESP8266 with Tasmota as a Serial Brdige to control my old LG TV. At the moment I can switch the TV on, but the switch in HA jumps back to off, because it doesnât get the right state. So I canât switch the TV off.
To switch the TV on the command_topic is âHome/LR/sonoff_tv/cmnd/SerialSendâ and the payload is âka 00 01â.
The payload in the state_topic âHome/LR/sonoff_tv/tele/RESULTâ is then âa 01 OK01xâ.
What do I have to template to get this to work?
Here is my code:
So, now I have the same problem with a Tasmota switch. After turning on the state gets not updated and stays off. I believe it did work on 0.89 HA, but not anyomore. Availability detection works great.
Is it me or HA? Any help welcome.