Passing a string from SmartApp to Device Handler

smartapp

(Freddy) #1

I’m trying to pass the sunset/sunrise times as strings to a custom device type (spark core / Photon).
The reason I’m doing this is because I want to use the getSunriseAndSunset method which is not accessible by the device handler.

How would I go about passing a string from a SmartApp to a custom Device?
Originally I was thinking of using capabilities but the only capability that allows a string is the notification capability.

Thanks in advance!


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

If you are writing a custom DTH, you can add any number of custom (“ad hoc”) Commands and/or Attributes of many data types (including string).

To update the Attribute from a SmartApp, you could call the custom Device Command that takes a String as an argument.

Do note that an Attribute is not a variable. An Attribute can only be updated via the sendEvent() method (or the implied sendEvent() that occurs at end of parse() or in any action Tiles of the Device.

If you want to work with a shadow-variable solely inside the scope of a Device or SmartApp, use a state.* variable.