Tasmota ghost switching

I’m running Tasmota V. 6.4.1. I have watched The Hook Up video on adjusting retain settings to fix ghost switching. But I’m still seeing ghost switching.

Configuration.yaml for the switch

light:
  - platform: mqtt
    name: "Front House Lights"
    command_topic: "cmnd/lightswitch2/POWER"
    state_topic: "stat/lightswitch2/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: false

I entered these commands in my switch’s Tasmota console

SwitchRetain Off
ButtonRetain On
ButtonRetain Off
PowerOnState 3
PowerRetain On

Here is the console log. Notice that I never got any blank retain message after the “ButtonRetain On, ButtonRetain Off” commands.

23:56:35 CMD: SwitchRetain Off
23:56:35 MQT: stat/lightswitch2/RESULT = {"SwitchRetain":"OFF"}
23:56:37 CMD: ButtonRetain On
23:56:37 MQT: stat/lightswitch2/RESULT = {"ButtonRetain":"ON"}
23:56:41 CMD: ButtonRetain Off
23:56:41 MQT: stat/lightswitch2/RESULT = {"ButtonRetain":"OFF"}
23:56:44 CMD: PowerOnState 3
23:56:44 MQT: stat/lightswitch2/RESULT = {"PowerOnState":3}
23:56:53 CMD: PowerRetain On
23:56:53 MQT: stat/lightswitch2/RESULT = {"PowerRetain":"ON"}

I’m assuming the lack of blank retain messages are my problem. Is there another way to erase the retain messages?

What the distance between the the switch and the tasmota I had a over a mtr and I got ghosting

You need to delete the persistence database in your broker… or use something like MQTT Explorer to delete the retained messages.

1 Like

Hi, I had the same issue, I also entered the retain commands that you wrote above.
At the end the ON message was on the MQTT broker, I uninstalled MQTT broker and reinstalled it again.
Now everything seems fine.
Logs before the fix:
18:54:34 MQT: Attempting connection…
18:54:41 MQT: Connected
18:54:41 MQT: tele/sonoff_1/LWT = Online (retained)
18:54:41 MQT: cmnd/sonoff_1/POWER =
18:54:41 MQT: stat/sonoff_1/RESULT = {“POWER”:“ON”}
18:54:41 MQT: stat/sonoff_1/POWER = ON (retained)
Logs after the fix:
19:09:19 MQT: Attempting connection…
19:09:21 MQT: Connected
19:09:21 MQT: tele/sonoff_1/LWT = Online (retained)
19:09:21 MQT: cmnd/sonoff_1/POWER =

Deleting the addon is another way to go as deleting it deletes the persistence database and then adding it back it recreates a new one.

Ths looks like the issue I’m having (recently posted a new thread but missed this one in the search). I have mqtt broker running as an lxc proxmox container.

I guess I need to look into purging the messages or database. Bit concerned about that affecting other devices that are working fine though.