Shelly 1 Connecting, Ghost Switching

I just installed a Shelly 1 for my living room lights. I flashed tasmota 6.4.1, and it works, but I’m getting a lot of ghost switching. I looked at the console and it appears that it is very frequently reconnecting. The rssi looks good though.

I followed the suggestions in this video, but I’m still getting the occasional ghost switch https://www.youtube.com/watch?v=31IyfM1gygo.

Here’s an example of a reconnect followed by a ghost switch (it should have been off)

11:53:14 MQT: Attempting connection…
11:53:14 MQT: Connect failed to 192.168.0.117:1883, rc -2. Retry in 10 sec
11:53:17 DNS: Initialized
11:53:28 MQT: Attempting connection…
11:53:28 MQT: Connected
11:53:28 MQT: tele/shellylr/LWT = Online (retained)
11:53:28 MQT: cmnd/shellylr/POWER =
11:53:28 MQT: stat/shellylr/RESULT = {“POWER”:“ON”}
11:53:28 MQT: stat/shellylr/POWER = ON (retained)
11:53:30 MQT: tele/shellylr/STATE = {“Time”:“2019-02-11T11:53:30”,“Uptime”:“0T23:47:27”,“Vcc”:3.568,“SleepMode”:“Dynamic”,“Sleep”:50,“LoadAvg”:19,“POWER”:“ON”,“Wifi”:{“AP”:1,“SSId”:“X”,“BSSId”:“X”,“Channel”:9,“RSSI”:86}}

Unfortunately, I’m just beginning with home automation, so my troubleshooting skills aren’t very advanced. Is there a configuration issue? Is there a problem with the Shelly 1 I installed?

Thoughts?

-Steve

Ghost switching is almost always caused by inadvertent or incorrect MQTT retain settings.

Looking at the log you posted, I can see there are some retained messages there, so I’d say that’s the cause.

Check the retain settings of the switch configuration in home-assistant, then take a look at this video for clarification of the retain options inside tasmota:

And the complementary blog post:

Personally, I use “powerretain 1” on tasmota (go to the tasmota switches local website, then choose console, type it in) and “retain: false” in the HA config for the switch.

I had done all of the suggested “retain” settings from the video last night. However, it does seem to have ghost switched at least 6 times in the past 4 hours.

Have you cleared the existing retained messages?

I believe this can be done by sending an empty string to the topic which has a retained message in it.

You may wish to try MQTT Explorer to confirm all retained messages are truly deleted. I described how to use it to delete retained messages in this post.

After deleting the retained messages from the topic(s), ensure Home Assistant publishes to the topic(s) using retain: false and not retain: true.

To avoid MQTT ‘surprises’, use retain: false when publishing to command_topics and retain:true for state_topics. That means the Tasmota device should use retain=true when publishing its status and Home Assistant should use retain=false when issuing a command to the Tasmota device.


EDIT
Corrected a critical typo!

Thanks, I’ll check that when I get home.

I hope I can get this figured out and not have to take out the Shelly. I’m having fun experimenting with this home automation stuff, but my wife was not impressed last night as the lights were turning on and off while we watched a movie.

I started automating my home in 2006. I highly recommend that you explain your new hobby to your wife, especially the part about there will be screw-ups. To maintain a happy household, it is best if your spouse is brought onboard in the capacity of official beta-tester as opposed to victim of your experiments. :wink:

If I’m understanding you correctly I think you have a typo in there. Shouldn’t that be retain=false when HA publishes to a command topic?

I noticed last night that, while I was pinging the Shelly I didn’t get any ghost switching. I tried setting sleep to 0 and I haven’t had any ghost switching in around 6 hours. I don’t know what issues doing this causes, though.

I did delete the retained message using MQTT Explorer so I’ll try setting sleep back to 50 and see what happens

Yes, definitely a typo! Thanks for catching it! I’ve corrected the error.