Mode change subscription bug, at least in docs


(Tony Gutierrez) #1

I have noticed that when using subscribe(location, “mode”, modeChangeHandler) it is sometimes hard to unsubscribe.

This subscribe format is in the documentation here
http://docs.smartthings.com/en/latest/smartapp-developers-guide/modes.html
under “Mode Events”, but does not match any of the subscribe signatures documented here:
http://docs.smartthings.com/en/latest/ref-docs/smartapp-ref.html#subscribe

Can we use the signature (Location location, String attributeNameAndValue, handlerMethod)? If so why isn’t it documented and why is it sometimes hard to unsubscribe?

Related question. Is the new mode id contained anywhere in the Event that is triggered? I can only find the mode name, in the value attribute.


Trigger on mode change
Executing code when a mode is changed from another mode
First app, detecting mode change
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #2

That signature doesn’t apply to Location Events, as show by the documentation, only eventName is valid as the second parameter.

And eventName for Location is something like “Mode”, “alarmSystemStatus”, and perhaps a few other secret ones.

Location is a very different Object than Device (and other objects that you can subscribe to). The signature is dependent on the Object Type.


(Tony Gutierrez) #3

Thanks, but that signature you quoted was missing from the docs as of two days ago (verified by google cache). I’m glad to see that it is official. However I do think there is an issue when unsubscribing from that signature. I will revert to it, as opposed to (Location, handler), and see if I can confirm.

Tony


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

I believe that the Docs are in a public GitHub repo… below; but that’s one way to verify you’re not going crazy :wink:.