When I click on the switch in main dashboard to turn it on
giP3mE1noJWQhEIRtj5K1iaJRlS.png
switch will power ON but the button after few seconds will have “OFF” status again, but switch is still ON … when I click the button two times and fast, switch will power off
I am receiving the topic to home assistant correctly:
Listen to a topic
Topic to subscribe to
stat/sonoff-6283/RESULT
Message 1 received on stat/sonoff-6283/RESULT at 19:24:
{
"POWER": "OFF"
}
QoS: 1 - Retain: false
Message 0 received on stat/sonoff-6283/RESULT at 19:24:
{
"POWER": "ON"
}
QoS: 1 - Retain: false
Also I am able to set status via MQTT “Publish a packet” function without problems
But cant see real status of the switch (it all the time appears to be OFF)
Can you help me find the problem please? Hope you understand my issue, if not i can upload a video or something…
I noticed you also have retain set to true. You probably don’t want that unless you have a good reason. When you set retain in Home Assistant for an MQTT light or switch, it retains the commands. You usually only want to retain the states.You can get TASMOTA to send retained state messages for power by issuing the command “PowerRetain ON” from the console, or via MQTT with cmnd/topic/PowerRetain ON.
If you setoption19 on - that enables MQTT discovers and it changes the topic… eg:
sonoff-6283/stat/POWER
So your manually configured switches will disappear. Even if you turn discovery off it won’t revert the topic - you will need to do that in Tasmota seperately.
Your problem is probably because you set retain: true. That screws everything up.
I personally don’t have any manually configured switches and I don’t have a mqtt: section either as it’s not required for the Hass.io broker. I use MQTT discovery and when I set the option they all just pop up in HA.
It seems like this might be a better route for you here.
Incidentally, the username you have used for Tasmota - homeassistant is a reserved username in the latest (v4+ versions of the broker)
I have exactly the same issue as @dvdrw15 describes, but I’m using the autodiscovery MQTT-feature:
The binary_sensor.so_s_100_b2 (name of my entity) turns on for 2-3 seconds when I push the button in either direction, but then flips back to off.
Is it possible to also use retain: false whilst autodiscovery is enabled or do I have to switch over to manual config for the expected behavior? If yes, where could I change the retain-flag?
I found the solution: I had to change the settings on the tasmota-config: Configuration -> Configure Template -> **GPIO4** Switch2 (10). Now the state of the switch is displayed correctly in Home Assistant for the external switch.