Tasmota: 'ButtonRetain Off' clears retained cmnd messages, 'SwitchRetain Off' does not.

Created on 8 Sep 2018  路  5Comments  路  Source: arendst/Tasmota

I noticed last night when making a video that when you have 'ButtonRetain on' and then you issue the 'ButtonRetain off' command it sends a blank retained payload "" to the cmnd topic to clear previously retained messages. I think this is an awesome feature and probably prevents headaches for many users who don't fully grasp the concept of MQTT retain.

Unfortunately, SwitchRetain doesn't have the same feature. Any chance of getting that same protocol added when turning SwitchRetain off?

enhancement fixed

Most helpful comment

Ah. It should. Looking at the code I see why it fails. Must have failed for many versions...

Will solve soon.

Correction. Works as designed. If there is no switchtopic defined there won't be a un-retain message. If a switchtopic is defined it will un-retain all switches with that message.

All 5 comments

Ah. It should. Looking at the code I see why it fails. Must have failed for many versions...

Will solve soon.

Correction. Works as designed. If there is no switchtopic defined there won't be a un-retain message. If a switchtopic is defined it will un-retain all switches with that message.

See my correction above

It's the buttontopic that is at fault! It assumes a topic name that worked fine in previous versions but as the topic now has more options it only resets the default topic.

So I'll fix buttontopic (and switchtopic as it used a wrong topic but that is not the issue here).

Just pushed a fix for the buttonretain 0 function where it always used the default buttontopic which probably wasn't the last buttontopic used.

So:

buttontopic "
17:21:02 CMD: buttontopic "
17:21:02 SRC: Serial
17:21:02 RSL: Group 0, Index 1, Command BUTTONTOPIC, Data "
17:21:02 MQT: stat/ring2/BUTTONTOPIC = {"ButtonTopic":""}
17:21:04 CFG: Saved to flash at F9, Count 2349, Bytes 3584
buttonretain 0
17:21:08 CMD: buttonretain 0
17:21:08 SRC: Serial
17:21:08 RSL: Group 0, Index 1, Command BUTTONRETAIN, Data 0
17:21:08 MQT: stat/ring2/BUTTONRETAIN = {"ButtonRetain":"OFF"}
buttontopic button-hookup
17:21:25 CMD: buttontopic button-hookup
17:21:25 SRC: Serial
17:21:25 RSL: Group 0, Index 1, Command BUTTONTOPIC, Data button-hookup
17:21:25 MQT: stat/ring2/BUTTONTOPIC = {"ButtonTopic":"button-hookup"}
17:21:26 CFG: Saved to flash at F8, Count 2350, Bytes 3584
buttonretain 0
17:21:42 CMD: buttonretain 0
17:21:42 SRC: Serial
17:21:42 RSL: Group 0, Index 1, Command BUTTONRETAIN, Data 0
17:21:42 MQT: cmnd/button-hookup/POWER = 
17:21:42 MQT: cmnd/button-hookup/POWER = 
17:21:42 MQT: cmnd/button-hookup/POWER = 
17:21:42 MQT: cmnd/button-hookup/POWER = 
17:21:42 MQT: stat/ring2/BUTTONRETAIN = {"ButtonRetain":"OFF"}

and

switchtopic "
17:30:16 CMD: switchtopic "
17:30:16 SRC: Serial
17:30:16 RSL: Group 0, Index 1, Command SWITCHTOPIC, Data "
17:30:16 MQT: stat/ring2/SWITCHTOPIC = {"SwitchTopic":""}
17:30:18 CFG: Saved to flash at F5, Count 2353, Bytes 3584
switchretain 0
17:30:21 CMD: switchretain 0
17:30:21 SRC: Serial
17:30:21 RSL: Group 0, Index 1, Command SWITCHRETAIN, Data 0
17:30:21 MQT: stat/ring2/SWITCHRETAIN = {"SwitchRetain":"OFF"}
17:30:29 APP: Serial logging disabled
switchtopic switch-hookup
17:30:35 CMD: switchtopic switch-hookup
17:30:35 SRC: Serial
17:30:35 RSL: Group 0, Index 1, Command SWITCHTOPIC, Data switch-hookup
17:30:35 MQT: stat/ring2/SWITCHTOPIC = {"SwitchTopic":"switch-hookup"}
17:30:36 CFG: Saved to flash at F4, Count 2354, Bytes 3584
switchretain 0
17:30:40 CMD: switchretain 0
17:30:40 SRC: Serial
17:30:40 RSL: Group 0, Index 1, Command SWITCHRETAIN, Data 0
17:30:40 MQT: cmnd/switch-hookup/POWER1 = 
17:30:40 MQT: cmnd/switch-hookup/POWER2 = 
17:30:40 MQT: cmnd/switch-hookup/POWER3 = 
17:30:40 MQT: cmnd/switch-hookup/POWER4 = 
17:30:40 MQT: cmnd/switch-hookup/POWER5 = 
17:30:40 MQT: cmnd/switch-hookup/POWER6 = 
17:30:40 MQT: cmnd/switch-hookup/POWER7 = 
17:30:40 MQT: cmnd/switch-hookup/POWER8 = 
17:30:40 MQT: stat/ring2/SWITCHRETAIN = {"SwitchRetain":"OFF"}

Oops. Now the buttonretain 0 fails to reset power1 to 4.

Checking.....

Again as designed. If there are more buttons it will index them like POWER1, POWER2 etc.

Was this page helpful?
0 / 5 - 0 ratings