Button Pushes and parsing. Cycle until button is released


(Nick) #1

I’m writing a device type for the Osram Lightity Dimming Swtich which treats the device as a switch, rather than buttons.
(Thanks to @Motley for the existing device! I would have never had the time to do the parsing!!!)
I basically plugged the parsing from the existing device into the virtual dimmer switch and did a little tweaking.
While the existing device is excellent and opens a ton of possibility for the switch, I wanted the switch to appear as a switch, so it could be controlled by the App and also used with other SmartApps like Dim With Me and SmartLights.
I’ve got the basic functions working. The upper button press turns it on. The lower button press turns it off.
The upper button hold brightens the light by 10, the lower button hold dims the light by 10.

The annoying part is that a hold only registers once. It appears that while holding the button, the switch isn’t sending out any messages (like I’m still holding). The next parse happens when you let the button go.

I would like to have the device gradually dim or brighten while you hold the button, but have no idea how to do this.
I tried setting a state variable to capture the button release and having the level adjustment routine check the variable and if the button is still pressed do a runIn to the same routine, however, no matter what duration I put in, it runs the routine without any delay.

Any suggestions would be greatly appreciated.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

Unless I’m clueless, “hold” is simply unavailable functionality in the current Device Type Handler GUI. It’s pretty limited GUI, frankly, though has had incremental enhancements, like the “multiAttributeTile”.

Eventually SmartThings will release “HTML tiles” (or whatever to be called), which will permit the definition of much richer UI functionality inside the SmartThings App.


(Nick) #3

This doesn’t have to do with the GUI. The OSRAM Dimmer Switch is a ZigBee 2 button switch.
It distinguishes between a press and a hold, but while holding, the switch doesn’t send any new commands, so I can’t tell the button is still being held to continue increasing (or decreasing) the light level. I do get an event when the button is no longer pressed but it’s somewhat too late. I was hoping I could chain an incremental update of the level and then break it when I take my figure off the button, but that didn’t work.


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #4

Ah… sorry, I misunderstood. (Well… what I said is still useful, because someday, SmartThings will be “better” than that physical device!).

Yup – This is why there are some “double-tap” SmartApps, but no “hold” SmartApps. I don’t know if it is a part of the ZigBee (nor Z-Wave) specification to support any type of “send messages while held” feature.

It is not very practical from an implementation standpoint. Remember that mesh networking packets are not guaranteed to arrive in order … they arrive “eventually”: So if you have a device that is sending “hold, hold, hold, hold, hold, release”, it might arrive to the Hub (& SmartThings) as “hold, hold, release, hold, hold”. At least I think that is quite possible…

More likely, you’d get “hold, hold, (nothing), (nothing), (nothing), hold, hold, release”. So what if you are trying to steadily ramp up a light, what do you do with the “nothing” period? Assume the button is still being held? Or assume it was released? … Or pause the dimming until you get the next “held” message (meanwhile the user thinks that dimmer is stuck and releases the button…).

That’s why this type of functionality need to be handled as locally as possible (specifically: in the device itself).

###However:
It could be practical / possible for a device to send: [held, duration] as a single message. Then you could use this to dim or brighten by a specific delta based on the duration. Wonder if anything like this is in the ZigBee or Z-Wave spec; or it should be an enhance requiest.

…Terry.


[RELEASE] SmartBulb Power Outage handler
(Nick) #5

Thanks for the feedback.
I think I stumbled across somebody somewhere who figured out the duration the of how long a button was pressed, but since you are not getting feedback from the light you are controlling while you are holding it, it makes it pretty difficult to judge when to let go.

My thought was to start slowly incrementing the light when I get the “I’m holding” and then have the “I let go” interrupt the routine adjusting the level. Although I’m not having much luck with that. As I mentioned above, I tried a runIn of the routine called from itself if I didn’t get the “I let go”, but the runIn isn’t waiting to run. Even if I set the delay to 60 seconds, it cycles up to 100% in a split second. Maybe the runIn isn’t implemented in device types…

In the short term, I set the level adjustment to step up or down 20, which is 5 “holds” to go from low to high.