Do you happen to know of any examples doing this?
void subscribe(InstalledAppWrapper app, handlerMethod)
void subscribe(Location location, handlerMethod)
void subscribe(DeviceWrapper device, String handlerMethod, Map options = null) (Since 2.2.1)
void subscribe(DeviceWrapperList devices, String handlerMethod, Map options = null) (Since 2.2.1)
void subscribe(DeviceWrapper device, String attributeName, handlerMethod, Map options = null)
void subscribe(DeviceWrapperList devices, String attributeName, handlerMethod, Map options = null)
void subscribe(Location location, String attributeName, handlerMethod, Map options = null)
But it's also a little unusual and not something I would do without a specific reason.
I do have a long-term goal of what I want to do with all of this but haven't exactly decided how far I want to take it. For now though I just want to play around with what can be done.
More specifically, I've got an Android dashboard app, HD+, which receives 'push' updates using the websocket ('eventsocket') locally. But, when away from home I have to poll the MakerAPI every few seconds and for years I've wanted to find a better / more efficient way to push updates to devices. I've opened a few threads about it: Access /eventstream from cloud? Or, alternative ways for hub to 'push' updates to a mobile device
I've finally got around to adding support for FCM (google push messages) to the app - so now I have a way to notify devices (removing the need to poll MakerAPI). The next step is detecting changes in devices and sending out updates via FCM. There's a lot more to it than that.. I don't actually want to send out updates for every device or attribute change -- just the important ones. But, I can have the app tell the driver to look for a list of device ID's so the user doesn't have to worry about any of it.
Certainly the subscribe()
method looks promising but I would love to see an example of how to do this for multiple devices. And/or how to do this for 'all' devices and I can do the filtering myself in the driver