Possible to get all devices with any capability via input?

(tbeseda) #1

Is it possible to have a preference input list all devices from a location despite capability and type?

Something like:

input "items", "device.*", title : "Devices To Use", multiple: true


(tbeseda) #2

Similarly, is it possible to retrieve an object’s entire state?

So, instead of iterating over known attribute names

def temp = device.currentValue("temperature")
def contact = device.currentValue("contact")
// ...

it’d be nice to

def state = device.currentState()

This sort of functionality would be immensely helpful to metaprogramming SmartApps, as to better serve a more diverse and mutable set of devices.

(tbeseda) #3

I was able to answer my second question re: the whole state of a device.
Using #supportedAttributes I can get all attributes, loop through them, and build my own total state object.

def all_attributes_of_device = device.supportedAttributes
// loop over all_attributes_of_device...

I was reading the SmartDevice class summary instead of the Device docs. Oops.
Sorry, if I’m over documenting, just hoping it may help someone else down the line.

(Matty & Troy) #4

I don’t know if the code here (originally for switches) will be any help to you - but it does loop over the attributes.

(tbeseda) #5

Thanks! That’s very similar to what I ended up doing:

def device_state = [:]
for (attribute in device.supportedAttributes) {
  device_state."${attribute}" = device.currentValue("${attribute}")

Now if I could only get all devices as options for an input…

(DawgOnKing) #6

Are you working on a ST App or accessing the API (OAuth)? Just wondering why you’d want to access every device for a single input.

(tbeseda) #7

I’m writing a SmartApp with the web based IDE. No external application.

I’m trying to push the state of each device to an external service.

Is that a use-case for a “SmartThings Web Service”? For now I am just trying to keep it self-contained as a SmartApp while I play around, and not involve other appliances yet.

(Brian Steere) #8

Someday the Core API will be available and SmartApps like these won’t be needed anymore. I look forward to that day.

(Barry Murphy) #9

Thanks for this, its exactly what i want but how do i implement this into a smart app?
Do you have any example code?

(Steve Nemeth) #10

I’m also looking for a way to get all devices. (not based on capability)
I’d like to know when the Core API will be available.

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

Yah… We really need this for SmartTiles V6.


Yea, we really need this for developer sanity, I wonder how many of us are spending hours building almost the same exact thing which just about every IOT platform gives you out of the box… a basic RESTful API. Instead of working on our unique app ideas were busy hacking together something that will work which waiting on Samsung to provide something that should have been a day one deliverable. Shame