Below is the code I am using to notify myself of a presence change event. However, if multiple presence sensors are selected, i get notifications for both being either away or present. For example, when I left this morning, a notification came through for my phone leaving AND for my smartsensor being away which it was already away, I would like just what changed or triggered the event to occur.
How can I correctly code the notification for what caused the change?
A little background on how it is supposed to function - a presence change event occurs (notification) example to come home - then it goes and sees if anyone else is home - if someone is already home, then do nothing, if not then perform actions.
def presence(evt) {
for (person in people) {
if (evt.value == “present”) {
if (person.currentPresence == “present”) {
/////not perfect would send push telling you who all is home when you get home.
log.debug “${person.label ?: person.name} has arrived at the ${location}“
sendPush(”${person.label ?: person.name} has arrived at the ${location}”)
} else {
if (person.currentPresence == “not present”) {
log.debug “${person.label ?: person.name} is not at ${location}”
}
}
}
if (evt.value == "not present") {
if (person.currentPresence == "not present") {
/////not perfect would send push telling you who all is home when you get home.
log.debug "${person.label ?: person.name} has left the ${location}"
sendPush("${person.label ?: person.name} has left the ${location}")
} else {
if (person.currentPresence == "present") {
log.debug "${person.label ?: person.name} is at ${location}"
}
}
}
}
///sendPush("${evt.name}: ${evt.value} Current mode ${location.mode}")
presencecheck()
}
PS this forum has changed ALOT since I was here last, glad to see the community growing, but damn what a confusing layout to a fourm!