smartthings-mqtt-bridge icon indicating copy to clipboard operation
smartthings-mqtt-bridge copied to clipboard

Retain flag per device

Open marc-gist opened this issue 7 years ago • 2 comments

Is there anyway to set if the retain flag should be true/false for a particular device?

I have buttons in SmartThings, that i don't want the "press" action to be retained in the broker.

Thanks,!

marc-gist avatar Aug 22 '18 12:08 marc-gist

I'm running into the same challenge -- button presses (events) get published with retain which causes downstream consumers (like Home Assistant) to trigger whenever they are restarted because it thinks a new event was fired. Turning retain off globally would fix his problem but introduce sync issues with all the stateful devices. Perhaps the configurable precision should be down to the type/property level. For example, I have devices that expose both a switch and a button. I'd want "smartthings/device/switch" to be published with retain and "smartthings/device/button" not to be.

Looking at the code, this would need to be implemented in the nodejs component. I see two viable options:

  1. Extend the configuration to allow specification of retain by device, property, or device and property.
  2. Add logic for "button" and other event-type properties to always publish retain = false. (Why would someone ever want a button press event to be retained anyway?) Other portions of the code have intelligence for specific properties (switch and level) so I don't see this as a major SOC issue.

Thoughts on the approach? I'm learning more to the second option because it would be far simpler to implement and can work on a PR if others agree. :)

andrewsayre avatar Nov 03 '18 15:11 andrewsayre

Also running into this issue. Was resetting the docker container every night at 11 pm, coincidentally lights were turning on-off off-on at that time which I wasn't sure why until I realized the retain flags send the press or push along on the restart of this docker container.

Agreed @andrewsayre #2 seems to make sense

rwarner avatar Jan 04 '21 15:01 rwarner