Getting List of All Devices, Capability of Any

Hello,

I am attempting to create a SmartApp which is capable of forwarding event data from any device. Unfortunately selecting devices of any capability seems impossible with the current API. Is there some secret that I am not aware of, or are there any plans to support this in the future?

Many thanks!
-Erik

The common workaround that I have seen is to use two inputs; “capability.sensor” and “capability.actuator”.

Every device is supposed to claim one of those two Capabilities in addition to more specific one(s).

2 Likes

Thanks for the info @tgauchat, that is a good work-around for now.

Also sent a support request asking to allow device input for all of the available devices, would be a nice feature to have.

1 Like

Thanks for this answer. I tried using these as inputs with mappings of /sensors and /actuators with methods for listing

def listSensors() {

def resp = []
sensors.each {
    resp << [name: it.name, value: it.currentValue("sensors")]
    log.debug "${sensors.displayName}, name: ${it.displayName}"
}

def listActuators() {

def resp = []
actuators.each {
    resp << [name: it.displayName, value: it.currentValue("actuators")]
}

}

but when I call /sensors and /actuators as ResT calls, I get 200 response but empty body.

you should return the resp at the end of the method

2 Likes

So, I tried that and I get an empty array :neutral_face:
Can someone please confirm this still works?

Here’s the code:

mappings {
path("/sensors") {
action: [
  GET: "listSensors"
]
}
path("/actuators") {
  action: [
    GET: "listActuators"
  ]
}
}

def listSensors() {

def resp = []
sensors.each {
    resp << [id: it.id, name: it.displayName, value: it.currentValue("sensors")]
    log.debug "${sensors.displayName}, name: ${it.displayName}"
}

return resp
}

def listActuators() {

def resp = []
actuators.each {
    resp << [id: it.id, name: it.displayName, value: it.currentValue("actuators")]
}

return resp
}

If you want help debugging, please – you’ll have to provide the FULL code for the SmartApp, including the input statements where you fetch the list of Sensors and Actuators from the user!