I’m having trouble understanding why my code isn’t sending email after door has close
The following if statement doesn’t seem to work but as the loginfo is telling me the values are matching.
if (GarageStateDoor2.state == “CLOSED” && OpenAlertDoor2 == “Y” )
…
2019-08-29 17:34:13.712 [INFO ] [.smarthome.model.script.garage.rules] - test door alert Door2 state=CLOSED alert=N
2019-08-29 17:34:23.452 [INFO ] [.smarthome.model.script.garage.rules] - test door alert Door2 state=OPEN alert=N
2019-08-29 17:35:23.552 [INFO ] [.smarthome.model.script.garage.rules] - Garage open Door2 for 1 mins
2019-08-29 17:37:15.946 [INFO ] [.smarthome.model.script.garage.rules] - test door alert Door2 state=CLOSED alert=Y
rule "check Garage door2 left open"
when
Item GarageStateDoor2 received update
then
door="Door2"
logInfo("garage.rules","test door alert "+ door + " state=" + GarageStateDoor2.state + " alert=" + OpenAlertDoor2 )
if (GarageDoorTimer2 !== null) {
GarageDoorTimer2.cancel()
}
if (GarageStateDoor2.state == "CLOSED" && OpenAlertDoor2 == "Y" ) {
logInfo("garage.rules","reset door alert "+ door )
OpenAlertDoor2 = "N"
open_duration = ((now.millis - doorOpenTime2) / 60000)
msg = "Garage closed "+ door + " was open for " + open_duration + " mins"
sendMail(email,"Garage closed " + door, msg)
}
if (GarageStateDoor2.state.toString == "OPEN") {
doorOpenTime2 = now.millis
GarageDoor2_Last_Opened.postUpdate(new DateTimeType())
// wait and alert if door left open
GarageDoorTimer2 = createTimer(now.plusMinutes(GarageOpenMax)) [|
open_duration = ((now.millis - doorOpenTime2) / 60000)
msg = "Garage open "+ door + " for " + open_duration + " mins"
sendMail(email,"Garage Open " + door, msg)
OpenAlertDoor2 = "Y"
logInfo("garage.rules",msg )
// second alert wait double time
GarageDoorTimer1 = createTimer(now.plusMinutes(GarageSecondAlert)) [|
open_duration = ((now.millis - doorOpenTime2) / 60000)
msg = "Garage open "+ door + " for " + open_duration + " mins"
sendMail(email,"Garage Open " + door + " Second alert", msg)
logInfo("garage.rules",msg )
]
]
}
end