Random turn on switch light

I used sonoff with tasmota firmware to automate my light switch. Problem is it randomly turn on without any manual or automated trigger. Log just simply showed “front porch turned on” . I m somewhat new to HA, familiar with few linux commands but not quite know how to debug this problem.

  • platform: mqtt
    name: “front porch”
    command_topic: “cmnd/sonoff3/power”
    state_topic: “stat/sonoff3/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

Any suggestion would be appreciated.

Could be ghost switching issues?

I’d use a MQTT monitor (mosquitto_sub in a session if you’re using a Pi or similar) and subscribe to the cmnd/sonoff3/power topic and make sure nothing is actually commanding switch on.

DrZzs here has a good vid on ghost switching here: https://youtu.be/aq8_os6g13s

Just some ideas. Just me but I usually keep my MQTT topics grouped so I’d have something like lights/sonoff3/power and lights/sonoff/state so I could just monitor the lights/sonoff/# topic and see all the action. Just me though.

The mosquitto_sub command should be like mosquitto_sub -h -v -t “//#” to monitor the topic and one down the topic tree.


thanks for advice. will try to MQTT monitor and see what’s going on.

You can also use MQTTlens on Chrome and MQTTfx on Windows to debug .

I can suggest MQTT Spy, it’s Java so it works on Mac, Linux and Windows.

Back to ghost switch issue, according to Dr.Zzs it could be electrical interference on the wire that could trigger “pushbutton” randomly. Some user also suggested to over come that by setting sonoff to “hold” for amount of time before fire a command. Through sonoff web console you can set following:

SwitchMode 6 << 6 : PUSHBUTTONHOLD_INV
SetOption32 2 << 2 : 2 x .1 sec delay
StateText4 TOGGLE

I tried but not sure how to test this. After setting SetOption32 to a larger value , e.g. 40 (i.e. 4 sec) I fired mqtt power on command, the switch was ON right away. i.e. it did not wait for 4sec… Has anyone try to tweak any of those setting above and could explain how it works?

Did you figured out how to overcome this problem with the HOLD idea?