Probably simple - my first RM attempt, but struggling

I want to make a rule that checks to see if my front door has been opened in the last 24 hours, and alert if not. (trying to make sure my Konnected is reporting in...)

I have a rule set up to populate a global variable when the state changes on the contact, but I am not sure how to make a rule that checks to make sure that has been updated in <=24 hours. Could someone point me in the right direction, please? It's probably pretty simple, but didn't find a good example to copy from.

Thank you!!

-randy

If you wanted to keep going down the path you've started, I think you're on the right track. Something like this might work for one part:

Rule 1:

Trigger: Door opens

Actions:

Cancel Delayed Actions
Set Global Variable recentDoorOpen to true
Delay 24:00:00 (cancelable)
Set Global Variable recentDoorOpen to false

Then, you could have another rule like:

Rule 2:

Trigger: recentDoorOpen becomes false

Actions:

Notify "Door not opened for 24 hours!"

However, if you don't care to also use the door status in other rules (or display it somewhere like on Dashboard), then you probably don't need the global variable and could use a different technique to just do it all in one rule:

Single-rule alternative:

Trigger: Door opened

Actions:

Cancel Delayed Actions
Delay 24:00:00 (cancelable)
Notify "Door not opened in 24 hours!"

Note that I'm taking your request pretty literally and only looking for "open" events. If you want a change of status, open or closed, the above rule could be rewritten to use a "changed" trigger instead of just "opened." However, since most doors would have both events in quick succession, I don't see a reason to prefer anything other than exactly what you said here.

Alternatively, you could use a "Wait" instead of a delay. Unlike delays, waits are cancelled any time a trigger event matches. You can put a timeout on the wait, and then test to see whether the rule actions moved on because the event happened or just because time has elapsed:

Single-rule alternative with "Wait":

Trigger: Door closed

Wait for events: door opened --> timeout 24:00:00
IF (Door closed) Notify "Door not opened in 24 hours!"

That being said, if you aren't trying to learn Rule Machine, the built-in Notifications app should be able to handle this, too. :slight_smile: Just choose a contact sensor, choose to get notified when it remains opened, and use 1440 for the "for how long (minutes)?" value (24*60=1440).

1 Like

Wow, thank you so much for the detailed reply! It is amazing to me how many different ways there are to think about solutions to problems! I tried some of each just to learn. Is there any reason for option 2 that the following would not work? I want to trigger on contact status change, not specifically open or close. It looks to me like for this to start working though, I need to go cycle the contact to kick things off? (Going to go test this right now though. :))

Single-rule alternative:

Trigger: Door contact status ā€œchangedā€

Actions:

Cancel Delayed Actions
Delay 24:00:00 (cancelable)
Notify "Door status not changed in 24 hours!"

That works, too! I figure that with a door, you're likely to get open and close events in quick succession and probably don't care which you use to determine whether Konnected still "sees" it, so there's no need to use both (but also no harm, aside from a tad more work for the hub that is unlikely to matter in the real world).

You are correct that, regardless of how you write the rule, you'll need to trigger the actions. (Technically, you could kick it off manually by hitting the "Run Actions" button in the finished rule, but in actual usage, it's normally going to be one of your trigger events; actions do nothing on their own unless the rule is triggered via a matching trigger event, invoked via the actions of another rule [that's a kind of action you can do], or manually run via the UI.)

1 Like