Can't read from Multipurpose sensor from a Smart App (Getting null)


(Scott Coleman) #1

I’ve got 2 Multiipurpose sensors configured,. I can read them fine in the official smart things app. But I can’t read them from my smart app.

I get this reponse:
[{“name”:“Open Sensor”,“value”:null},{“name”:“Multipurpose Sensor”,“value”:null}]

Note from the same app I can successfully control the outlet.

Here are the relevant parts of my code:
preferences {
section (“Allow external service to control these things…”) {
input “switches”, “capability.sensor”, multiple: true, required: true
input “outlets”, “capability.outlet”, multiple: true, required: true
}
}

mappings {
path("/switches") {
action: [
GET: “listSwitches”
]
}
path("/switches/:command") {
action: [
PUT: “updateSwitches”
]
}

path("/outlets/:command") {
action: [
PUT: “updateOutlets”
]
}
}

def listSwitches() {
def resp = []
switches.each {
resp << [name: it.displayName, value: it.currentValue(“switch”)]
}
return resp
}