Hi,
I build a contact on my letterbox, and a rule send a popup message to smartphone if new post receive. Works.
Sometimes the postman open the flap 3 times to fill in the letters, and I get three popups …
So looking for a “simple” timer rule that only one event is triggered.
“Send immediatly a popup after first open Letterbox_Filling and ignore all further events the next 60 sec.”
Actual:
rule "Briefkasten: Einwurfklappe wurde betaetigt" // Fill in
when Item Letterbox_Filling changed from CLOSED to OPEN
then
String Letterbox_Last_Filling = now.toString("HH':'mm' Uhr ('E')'")
Letterbox_Full.postUpdate(ON)
sendPushoverMessage(pushoverBuilder("Post kam, Einwurf! " + Letterbox_Last_Filling)
.withSound("bugle").withApiKey("axxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
Letterbox_String.postUpdate("EINWURF: " + Letterbox_Last_Filling)
end
Thanks Rich,
I try example 1 from your link, maybe it’s “normal” but when saving the rule I get:
2019-02-26 18:52:40.475 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'latch_test.rules', using it anyway:
Constant condition is always false.
Assignment to final field
Assignment to final field
2019-02-26 18:52:40.491 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'latch_test.rules'
My test-rule is this now:
val Timer latchTimer = null
rule "Briefkasten: Einwurfklappe wurde betätigt" // Filling
when Item Letterbox_Filling changed from CLOSED to OPEN
or Item Switch_Socket09 changed from OFF to ON // for testing/debugging only !!
then
logInfo("letterbox.rules", "AAAAAA Letterbox FILLING start line")
if(latchTimer !== null) return; // skip this event if the timer exists
latchTimer = createTimer(now.plusMinutes(1), [ | latchTimer = null ]) // set the Timer back to null after the given time
logInfo("letterbox.rules", "BBBBB Filling end rule")
end
(the rule self is working, I get only max. one message (here: logInfo “BBBBBB…”) per minute)
I wrote Concept 1 in response to this posting and indeed it has an error. rossko57 correctly points out, latchTimer needs to be defined as a var, not a val.