Device Attribute.Value Syntax for subscribe()


(Eric R) #1

When you use subscribe(device, “capability.attribute”, “handler”), how do you handle attributes with multiple words. Example: subscribe(device, “sleeping.not sleeping”, “handler”) (this doesn’t seem to work)


(Mike Maxwell) #2

Don’t use spaces in your attribute names?


(Eric R) #4

Maybe I’m wrong with how the subscribe(device, attribute, handler) works…

From what I understand, you are listening to the device for the attribute. When that attribute changes, it calls the handler. For the attribute, you can add a specific value with the dot notation. (Now that I have written that out, my question should have stated attribute.specificValue rather than capability.attribute)

The specific value comes from the existing capabilities documentation. I’m not sure it can be changed like you suggest. I tried several variations, and they don’t seem to be working.


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

I found a SmartApp “Notify Me When” which uses this Syntax… didn’t test it; but it shows use of space in the Attribute Value

subscribe(departurePresence, "presence.not present", sendMessage)


(Eric R) #7

OK… So I just tested it with another app that was just a subscribe and listener and with the space does work. It must be something else in my code that isn’t allowing it to call the method.