Essentially, tell me which one of the two presence sensors left.
I’ve been looking at the Greeting Earthlings app which allows for the selection of multiple presenceSensors.
When I run the code below in Sim it still outputs the name of both cars instead of the one that triggered the event.
preferences {
section("Available Sensors") {
input "auto", "capability.presenceSensor", title: "Select sensor to configure...", multiple: true
}
section("Available iPhones") {
input "phone", "capability.presenceSensor", title: "Select phone to ping...", multiple: true
}
}
def installed() {
log.debug "Cars = ${auto.collect{it.label + ': ' + it.currentPresence}}"
subscribe(auto, "presence", pingHandler)
}
def update() {
log.debug "Cars = ${auto.collect{it.label + ': ' + it.currentPresence}}"
unsubscribe()
subscribe(auto, "presence", pingHandler)
}
def pingHandler(evt) {
def car = getCar(evt)
if(evt.value == "present") {
def phoneState = phone.currentState("presenceSensor")
sendPush("${auto.displayName} is here, I will update iPhone locations.")
} else if (evt.value == "not present") {
def phoneState = phone.currentState("presenceSensor")
sendPush("${auto.displayName} has left, I will update iPhone locations.")
}
}
private getCar(evt) {
auto.find{evt.deviceId == it.id}
}