SOLVED - Intermittent Success with Tasmota - Turning On and off

Hey all -
I installed my first Sonoff Basic R2 yesterday with Tasmota installed on it.

It’s showing up correctly in Home Assistant. I can Toggle the switch on and off. I can see the traffic via my MQTT Broker.

But…some times it takes multiple clicks for the switch to turn on or off. I cannot find any rhyme or reason as to why.

Anyone encounter something similar?

Screenshot from 2020-04-12 11-12-44

How is it integrated? MQTT switch? Or via an automatic discovery thing?

If you have a configuration, can you post it here?

What are your tasmota settings?

Does your switch have a good wifi signal? With MQTT, if you’re not using retain (which you shouldn’t be for cmnd topics!!!), if it doesn’t see the change, it won’t do anything.

Can you open the console and look at the log while you send the commands? Does it always notice the command? My guess is only sometimes.

IF (and I mean IF) you don’t have a reliable connection but want to continue using it, you can turn on MQTT retain for this cmnd topic, BUT it must be enabled from ALL devices that might control this. If there is any single device that doesn’t have retain setting enabled, you will have a problem where the switch will turn on/off randomly when it disconnects from wifi as the last state you told it wasn’t retained, so when it reconnects, the MQTT broker sends it the last retained message (the one actually marked retained).

This is why you should almost never use retain for cmnd topics (state topics from Tasmota device…certainly). But, if EVERYTHING that can send a cmnd to that device has retain on, it will work just fine…and can help in cases where the device has a poor connection. In this case, when the device reconnects, it will get that last cmnd sent to it and respond to it, so you might just have a slight delay in some commands.

Jim -
Thank you very much for the thorough reply.

Answers to your questions:

  • I did it via Auto-discovery, which I accomplished by following the directions here.

  • I initially tried it by manually creating a MQTT-Switch and saw the same behavior. I did not use retain in this configuration

  • WiFi is connected with the following: AP1 SSId (RSSI) xxMySSIDxx (100%, -39 dBm)

  • I don’t believe I’m currently using retain.

  • I am able to trigger it consistently by publishing a cmnd topic directly to the broker from my primary linux box.

Tasmota Settings:

Ok, can you trigger it by sending the same command from the Home Assistant mqtt tab in developer tools?

How is mqtt set up in home assistant? Have you had problems with that before?

Everything looks good from what you’ve posted!

As it turned out, I had much larger problems that just my Tasmota.

Fixed my issue in a separate thread, and all is good now.

Whoo hoo! Thank you again!