LED Strip - Tasmota - Reconnect Turns Lights On

I am having an issue with my Tasmota flashed LED Strip where it turns on randomly to bright pink.

I found a few topics on this, seems to be a combination of the ‘retained’ flag in HomeAssistant and the ‘PowerRetain’ setting in Tasmota that might be causing this? Although as I write this it seems that because it is always bright pink it might be a previous item stuck on the MQTT topic?

I currently have ‘retain’ set to ‘false’ in my configuration.yaml, ‘PowerRetain’ set to ‘on’ in Tasmota.

Here are some instances of the power coming on unexpectedly.

21:45:02 MQT: tele/DeviceName/STATE = {“Time”:“2018-10-31T21:45:02”,“Uptime”:“3T03:24:22”,“Vcc”:3.534,“POWER”:“OFF”,“Dimmer”:20,“Color”:“330000”,“HSBColor”:“0,100,20”,“Channel”:[20,0,0],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:90,“APMac”:“MAC”}}
21:46:45 MQT: Attempting connection…
21:46:45 MQT: Connected
21:46:45 MQT: tele/DeviceName/LWT = Online (retained)
21:46:45 MQT: cmnd/DeviceName/POWER =
21:46:45 MQT: stat/DeviceName/RESULT = {“POWER”:“OFF”}
21:46:45 MQT: stat/DeviceName/POWER = OFF (retained)
21:46:45 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”,“Dimmer”:20,“Color”:“51,0,12”,“HSBColor”:“346,100,20”,“Channel”:[20,0,5]}
21:46:45 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25]}
21:50:02 MQT: tele/DeviceName/STATE = {“Time”:“2018-10-31T21:50:02”,“Uptime”:“3T03:29:22”,“Vcc”:3.535,“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:92,“APMac”:“MAC”}}

04:07:55 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”,“Dimmer”:20,“Color”:“330000”,“HSBColor”:“0,100,20”,“Channel”:[20,0,0]}
04:07:55 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”}
04:07:55 MQT: stat/DeviceName/POWER = ON (retained)
04:10:01 MQT: tele/DeviceName/STATE = {“Time”:“2018-11-01T04:10:01”,“Uptime”:“3T09:49:21”,“Vcc”:3.533,“POWER”:“ON”,“Dimmer”:20,“Color”:“330000”,“HSBColor”:“0,100,20”,“Channel”:[20,0,0],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:96,“APMac”:“MAC”}}
04:10:08 WIF: Connect failed as no IP address received
04:10:08 WIF: Connecting to AP1 MyRemovedSSID in mode 11N as DeviceName-2524…
04:10:30 WIF: Connect failed with AP timeout
04:10:52 WIF: Connect failed with AP timeout
04:10:53 WIF: Connecting to AP1 MyRemovedSSID in mode 11N as DeviceName-2524…
04:11:09 WIF: Connected
04:11:09 DNS: Initialized
04:11:10 MQT: Attempting connection…
04:11:10 MQT: Connected
04:11:10 MQT: tele/DeviceName/LWT = Online (retained)
04:11:10 MQT: cmnd/DeviceName/POWER =
04:11:10 MQT: stat/DeviceName/RESULT = {“POWER”:“OFF”}
04:11:10 MQT: stat/DeviceName/POWER = OFF (retained)
04:11:10 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”,“Dimmer”:20,“Color”:“51,0,12”,“HSBColor”:“346,100,20”,“Channel”:[20,0,5]}
04:11:10 MQT: stat/DeviceName/RESULT = {“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25]}
04:15:01 MQT: tele/DeviceName/STATE = {“Time”:“2018-11-01T04:15:01”,“Uptime”:“3T09:54:21”,“Vcc”:3.535,“POWER”:“ON”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:86,“APMac”:“MAC”}}
04:15:49 MQT: stat/DeviceName/RESULT = {“POWER”:“OFF”}
04:15:49 MQT: stat/DeviceName/POWER = OFF (retained)
04:20:01 MQT: tele/DeviceName/STATE = {“Time”:“2018-11-01T04:20:01”,“Uptime”:“3T09:59:21”,“Vcc”:3.534,“POWER”:“OFF”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:90,“APMac”:“MAC”}}
04:25:01 MQT: tele/DeviceName/STATE = {“Time”:“2018-11-01T04:25:01”,“Uptime”:“3T10:04:21”,“Vcc”:3.534,“POWER”:“OFF”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“MyRemovedSSID”,“RSSI”:90,“APMac”:“MAC”}}

Any help appreciated. Luckily this is in a room we aren’t currently using, otherwise I would have a very annoyed wife by now! Can’t imagine she would appreciate bright pink at 4am.

It’s most likely because the MQTT server has a retained message already. If you clear that message, by sending a empty message (or NULL message) with a retain flag on the same topic as the light, this will be solved.

1 Like

I thought this might be it. Is there a way to view retained messages? I would ideally like to verify before I remove it.

Also, are my settings around Retain/PowerRetain correct?

Yes any MQTT client would suffice. Connect to the MQTT server and subscripe to the topic (or subscribe to # to view all messages). Then publish a empty message with retain flag to clear the unwanted message.
HA has a build in MQTT client, but I personally don’t use it. I use a client for osx, named MQTT.fx. There is also a HASSIO MQTT sever and client combo addon, but again I don’t use it.

Depends on what you want. I would set the retain off on Tasmota and retain on in HA, because in my case HA is leading.

1 Like

I have set both settings back to false and published a retained empty message to cmnd/devicename/power. We will see if I get any more pink illuminations.

Unfortunately still having issues. I can now reproduce this by simply rebooting the device from the Tasmota web interface.

I have viewed/cleared the topic (I am assuming it is the right topic?):

core-ssh:~# mosquitto_pub -h 192.168.0.98 -u userName -P password -d -n -r -t cmnd/deviceName/power
Client mosqpub|79-core-ssh sending CONNECT
Client mosqpub|79-core-ssh received CONNACK
Client mosqpub|79-core-ssh sending PUBLISH (d0, q0, r1, m1, ‘cmnd/deviceName/power’, … (0 bytes))
Client mosqpub|79-core-ssh sending DISCONNECT
core-ssh:~# mosquitto_sub -h 192.168.0.98 -u userName -P password -t cmnd/+/power
[nothing returned]
core-ssh:~# mosquitto_sub -h 192.168.0.98 -u userName -P password -t cmnd/deviceName/power
[nothing returned]

This publish command gives the following in the Tasmota console:

11:54:29 MQT: stat/nurseryStripRGB/RESULT = {“POWER”:“OFF”}
11:54:29 MQT: stat/nurseryStripRGB/POWER = OFF

I have also tried various combinations of PowerOnState and PowerRetain in Tasmota, currently set to:

11:55:33 MQT: stat/deviceName/RESULT = {“PowerOnState”:0}
11:55:40 MQT: stat/deviceName/RESULT = {“PowerRetain”:“OFF”}

Here is the Tasmota console output from a reboot:

00:00:00 Project sonoff Sonoff (Topic deviceName, Fallback DVES_E3A9DC, GroupTopic sonoffs) Version 6.2.1-2_4_2
00:00:00 WIF: Connecting to AP1 SSID in mode 11N as deviceName…
00:00:10 WIF: Connected
00:00:10 DNS: Initialized
00:00:10 HTP: Web server active on deviceName.local with IP address 192.168.0.121
12:00:09 MQT: Attempting connection…
12:00:09 MQT: Connected
12:00:09 MQT: tele/deviceName/LWT = Online (retained)
12:00:09 MQT: cmnd/deviceName/POWER =
12:00:09 MQT: tele/deviceName/INFO1 = {“Module”:“Generic”,“Version”:“6.2.1”,“FallbackTopic”:“DVES_E3A9DC”,“GroupTopic”:“sonoffs”}
12:00:09 MQT: tele/deviceName/INFO2 = {“WebServerMode”:“Admin”,“Hostname”:“deviceName”,“IPAddress”:“192.168.0.121”}
12:00:09 MQT: tele/deviceName/INFO3 = {“RestartReason”:“Software/System restart”}
12:00:09 MQT: stat/deviceName/RESULT = {“POWER”:“OFF”}
12:00:09 MQT: stat/deviceName/POWER = OFF
12:00:17 MQT: tele/deviceName/STATE = {“Time”:“2018-11-02T12:00:17”,“Uptime”:“0T00:00:19”,“Vcc”:3.537,“POWER”:“OFF”,“Dimmer”:100,“Color”:“255,0,63”,“HSBColor”:“345,100,100”,“Channel”:[100,0,25],“Scheme”:0,“Fade”:“OFF”,“Speed”:1,“LedTable”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“SSID”,“RSSI”:92,“APMac”:“MAC:ADDRESS”}}

Anyone got any other ideas?

It should be POWER in the topic, not power. It is case sensitive! I would recommend that you subscribe to the topic to view the messages that are retained. This will make it easy to troubleshoot.

mosquitto_sub -h 192.168.0.98 -u userName -P password -t cmnd/+/POWER
ON
ON
OFF

Not sure what topics these relate to, as if I include the device name I don’t see anything?

core-ssh:~# mosquitto_sub -h 192.168.0.98 -u userName -P password -t cmnd/deviceName/POWER

Is there a way to tell that?

I would use a gui client, not mosquitto_sub. Subscribe to # to view all messages on the MQTT server and look for the messages that are retained and you don’t want.

1 Like

So using MQTT.fx I can see a retained message on the cmnd/deviceName/POWER topic of OFF but… cmnd/deviceName/Color2 is retained with a value of “the pink color” and cmnd/deviceName/Dimmer is retained with a value of 100.

Cleared out all of the above from the server and I can now reboot the device without it turning on pink!

I have one more issue that I hoped clearing the retained cmnd/deviceName/Dimmer value might fix is that when I change colours in HomeAssistant the set brightness is ignored and set back to 100%. But I guess that is a HomeAssistant configuration issue.

@Pippyn - Thank you so much for all your help on this.

I’m glad it worked! I’m not able to help you with your other question sadly.