2024-08-21 12:17:14.418 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘e4a7ff3c07’ failed:
No further info is provided to help me debug. It works fine without the 3rd item so I think it is related to the (Insteon_Device_37B29B__Motion_Contact.lastUpdate.isBefore(now.minusMinutes(5).millis)
part of the statement.
This for the quick reply. I did find an errent parenthesis from me trying to debug. Removed and still errored. Then I removed the .millis part as you suggested, still same error. Here is what I have now:
val pushoverActions = getActions("pushover", "pushover:pushover-account:7a989ab46c")
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Checking if guests are gone. Front door:" + Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state + " Side Door:" + Insteon_Device_329F9A__Side_Door_Sensor_Contact.state + " Motion: " + Insteon_Device_37B29B__Motion_Contact.lastUpdate)
if ((Insteon_Device_329F9A__Side_Door_Sensor_Contact.state == CLOSED) && (Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state == CLOSED) && (Insteon_Device_37B29B__Motion_Contact.lastUpdate.isBefore(now.minusMinutes(5))) {
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Guests are gone!")
pushoverActions.sendMessage("It appears that your guests have departed", "openHAB - Cottage")
} else {
pushoverActions.sendMessage("It's check out time and it appears that your guests have not yet departed", "openHAB - Cottage")
}
I should note, removing the isBefore part of my if clause makes the rule work:
val pushoverActions = getActions("pushover", "pushover:pushover-account:7a989ab46c")
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Checking if guests are gone. Front door:" + Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state + " Side Door:" + Insteon_Device_329F9A__Side_Door_Sensor_Contact.state + " Motion: " + Insteon_Device_37B29B__Motion_Contact.lastUpdate)
if ((Insteon_Device_329F9A__Side_Door_Sensor_Contact.state == CLOSED) && (Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state == CLOSED)) {
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Guests are gone!")
pushoverActions.sendMessage("It appears that your guests have departed", "openHAB - Cottage")
} else {
pushoverActions.sendMessage("It's check out time and it appears that your guests have not yet departed", "openHAB - Cottage")
}
Ah, I found it! It was a parenthesis issue. Got messed up with modifying for debug.
Rule is working now:
val pushoverActions = getActions("pushover", "pushover:pushover-account:7a989ab46c")
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Checking if guests are gone. Front door:" + Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state + " Side Door:" + Insteon_Device_329F9A__Side_Door_Sensor_Contact.state + " Motion: " + Insteon_Device_37B29B__Motion_Contact.lastUpdate)
if ((Insteon_Device_329F9A__Side_Door_Sensor_Contact.state == CLOSED) && (Insteon_Device_32A0C7__Front_Door_Sensor_Contact.state == CLOSED) && (Insteon_Device_37B29B__Motion_Contact.lastUpdate.isBefore(now.minusMinutes(5)))) {
logInfo("Guest Check", "!!!!!!!!!!!!!!!!!!!!!! Guests are gone!")
pushoverActions.sendMessage("It appears that your guests have departed", "openHAB - Cottage")
} else {
pushoverActions.sendMessage("It's check out time and it appears that your guests have not yet departed", "openHAB - Cottage")
}
I am using OH 4.2.2 and I have 2 PIR sensors near the house main entry door:
The first is outside near the main entry door (MainEntry_Door_Out_Motion_Alarm)
The second is in-house near the main entry door (MainEntry_Door_In_Motion_Alarm)
I am using the first sensor to turn on lights when someone is near the door after sunset (there is a dedicated rule for that).
The second sensor is used for OH as a home alarm system (there is a dedicated rule for that, too) - it checks if someone is at the entrance patio once the alarm function is on.
I decided to add another function of checking if someone came in or out of that door (I know there is a door/window sensor for that but this is only a backup).
Here is my working rule:
var Timer Timer_SomeOne_Went_In
when
Item MainEntry_Door_In_Motion_Alarm changed to ON
then
if (MainEntry_Door_Out_Motion_Alarm.changedSince(now.minusMinutes(5)))
{
SomeOne_Went_In.sendCommand(ON)
Timer_SomeOne_Went_In = createTimer(now.plusSeconds(5), [|
SomeOne_Went_In.sendCommand(OFF)
logInfo(“Entry_Door_Automation”, “Some One Went In- 5 min in between”)
])
}
end
P.S
You can use the expire function to make the rule look nicer:
The “SomeOne_Went_In” item would look like:
when
Item MainEntry_Door_In_Motion_Alarm changed to ON
then
if (MainEntry_Door_Out_Motion_Alarm.changedSince(now.minusMinutes(5)))
{
SomeOne_Went_In.sendCommand(ON)
logInfo(“Entry_Door_Automation”, “Some One Went In - 5 min in between”)
}
end