-
Platform information:
- Hardware: Raspberry Pi 3B+
- OS: Linux openhab 4.19.97-v7+
-
Issue of the topic: please be detailed explaining your issue
Trying to have the rule progress through to send a telegram message when a personal phone leaves the wifi but a work phone remains present on the wifi 30 seconds later
It doesn’t seem to progress past the comparison between the two being ON and OFF
CODE:
rule “Adam Leaves his work phone at home”
when
Item Adam_Personal_Presence changed to OFF
then
logInfo(“Telegram rule”, “Personal phone left”)
if (Adam_Work_Presence == “ON” && Adam_Personal_Presence == “OFF”) {
logInfo(“Telegram rule”, “Work phone still home - starting 30s timer”)
if (timer === null) {
timer = createTimer(now.plusSeconds(30), [ |
logInfo(“Telegram rule”, “30 seconds over”)
if (Adam_Work_Presence == “ON”) { // Phone is still home after 30s
logInfo(“Telegram rule”, “Work phone still home”)
logInfo(“Telegram rule”, “Trying to send telegram msg”)
val telegramAction = getActions(“telegram”,“telegram:telegramBot:XXXXXXX”)
telegramAction.sendTelegram(“Have you left your Work Phone behind?”)
}
])
} else {
if(timer !== null) {
timer.cancel
timer = null
}
}
}end
Logs:
2020-05-22 10:17:29.674 [vent.ItemStateChangedEvent] - Adam_Personal_Presence changed from OFF to ON
2020-05-22 10:17:36.076 [vent.ItemStateChangedEvent] - Adam_Work_Presence changed from OFF to ON
2020-05-22 10:20:27.346 [vent.ItemStateChangedEvent] - Adam_Personal_Presence changed from ON to OFF
==> /var/log/openhab2/openhab.log <==
2020-05-22 10:20:27.368 [INFO ] [smarthome.model.script.Telegram rule] - Personal phone left