Hi, I am new to HA. My setup is a RPi3 with Hassbian with Mosquitto MQTT and some Sonoff switches using sonoff-tasmota firmware (v 5.14.0). Try to switch from openHAB to HA (these switches where working under openHAB)
The problem i have is that when i switch on the light from HA, the switch in HA goes off after one second. Following the MQTT-process from the command line, i do not see an mqtt switch off command!
When i installed Mosquitto i checked the working wit two terminal sessions with resp mosquitto_pub and mosquitto_sub commands. This was working.
Second i userd mqtt.publish from the Developer tools window. This is the command i used:
{
âtopicâ: âtasmota/Sonoff_4S20/cmnd/powerâ,
âpayloadâ: âONâ
}
This was also working perfectly! The ON command leaves the sonoff on, as it should. The OFF command does the job for switching off. But not from the HA browser windowâŚ
The configuration of mosquitto broker in configuration.yaml is:
Mosquitto broker
mqtt:
broker: 192.168.178.56
port: 1883
client_id: home-assistant-1
keepalive: 60
username: ########
password: ########
protocol: 3.1
birth_message:
topic: âtele/hass1/LWTâ
payload: âOnlineâ
qos: 1
retain: true
will_message:
topic: âtele/hass1/LWTâ
payload: âOfflineâ
qos: 1
retain: true
(for some reason, the indentation is missing in the posted version, but it is there!)
The configuration of the Sonoff switch is:
switch:
I tried this also with retain: true.
Also in the in the Tasmota config to use PowerRetain OFF and ON, which i found somewhere in an other topic. Non of these helped.
Please, is there anyone who can help me with this issue?
Kind regards, Bert
And the Sonoff device reacts as it should; It needs an other --OFF command to switch off.
I think it is something in the configuration in HA for the Sonoff device, because bare MQTT commands work as it should. But i canât see whatâŚ
BTW, in configuration.yaml there are capitol letters usedâŚ
The button returns to its previous state because it does not receive a status message matching the state_topic: and payload, so HA decides that the switch didnât happen.
Looking at your trace it looks like the status came back in a message
@gpbenton Yes!!! you are absolutely right! That was the fault. I did expect it to be something like this (reading other topics here). But i was blind to see this in the tty sessionâŚ
However, i do not know quite why the syntax should be like this. I am using the by Theo Arends adviced mqtt topic configuration: tasmota/%topic%/%prefix%/
So i did use this also for the state-topic, as for both power (switch) topics.
But changing only this state_topic to your suggestion, did work (leaving the command_topic and availability_topic as it was).
However, I do not understand why the broker is sending this (stat/Sonoff_4S20/POWER ON) result in the terminal sessionâŚ
I canât explain this, and that bothers me a bit.
But i am very happy that it is working now! Thank you very much!
Kind regards, Bert
If i disable MQTT details in Tasmoto web UI. & control the switch either manually or thru tasmoto UI (ON/OFF) the switch/ socket works like a charm no issues.
Please help to resolve the issue
What am i missing wrong?
Alternatively, if you want to use the legacy âPowerâ without the â1â postfix, all you need to do is type âSetOption26 0â at the serial console, and it will go back to the legacy configuration
I think when I updated I assumed this would happen, updated my configuration and then my switches stopped working. Then I re-read it and I think it was only if the sonoff had more than one switch in it⌠in any case, I went back to power for both switches and it all worked again.
I had issues with tasmota sonoff basic switching on by its self or off by its self. I fixed this by switching from the official mqtt to the community mqtt.
I also had an issue with the sonoff basic flicking on off a number of times a day. I fixed this by following drzzs vid to stop ghosting with a cap and resistor.