So I have an app where use 8 or so events from a device type (thermostat). In the past I just subscribed at all of the events individually.
Based on this documentation (see link - void subscribe(Object thing, handlerMethod)), though, I think I should be able to not specify an attribute in the subscribe and subscribe to ALL events on the device in one subscribe entry.
I tried it, though, and it does nothing. No error, but the app also does not show the subscriptions (and the corresponding handler method never fires either).
I had asked @bravenel the same question a month or so ago but nothing he came up with worked for me either. I'd love to have an answer to this one as well. If you need refreshing Bruce, this is the thread I was talking about:
i've also tried subscribe(myDevices.each,eventHandler)
and that didn't throw errors or subscribe to any events.
Yeah, that's what I ended up doing as well. But I had the same question. Bruce never came back with something else to try. Maybe it was never implemented from a platform level. Glad I'm not the only one...at least I know it's not just something that I screwed up.
You subscribe to the events of an attribute.
You can subscribe to a specific event ie an attribute becoming a specific value OR you can subscribe to all events related to that attribute.
For example you can subscribe to a specific event of the switch attribute (switch.on) or all the possible values of the switch attribute (switch). The latter will subscribe to switch.on and switch.off
I dont believe you can subscribe to all events of a device..you have to specify the attribute to monitor changes in. I have never built a thermostat driver so I dont know the syntax for that one in particular but you would just need to look at the documentation to find the attribute events you want to subscribe to.
Regardless I believe you need to have
subscribe(device, "attribute", handler).
I believe you always need 3 parameter. The device, the attribute and the handler. The only "option" you have is to subscribe to a particular value of an attribute or all attributes. I "believe" being the key word
My guess based on the smartthings subscribe command documentation, is that you can subscribe to SOME things (like location) with only 2 parameters, but not device attributes.
For instance, this is valid in smartthings:
// shortcut for mode change handler
subscribe(location, modeChangeHandler)
But a 2 parameter call isn't valid for device events.