RM Example: Selective Presence Notifications for Two Users

Purpose: to provide presence notifications for two users

Problem: I get too many messages to my phone as it is. I don't need a message telling me my wife has left the house when she is in the car with me. I already know that. The idea here is to have RM wait to evaluate the rule and make sure that we both haven't left the house at nearly the same time.

I managed to get this into 4 rules. for more than two users it will require quite a few more rules since you can only choose one switch to act as a restriction.

I also created two virtual switches:
vpresencechangeUser1
vpresencechangeUser2

I've been using it for the past couple of weeks and it seems to work pretty well.

@bravenel I'd also love to be able to refine my time delays to less than one minute. For some reason that is only allowed when turning on or off switches, but not when delaying rules.

Notify Presence User 1 Trigger
Trigger:User 1 arrives or User 1 leaves
Action:
On: vpresencechangeUser1
Delayed off: vpresencechangeUser1: 75 seconds
Rule Boolean True: Notify Presence User 1 Rule: Delay 1 min
Rule Boolean False: Notify Presence User 1 Rule: Delay 2 min
Run Rules: Notify Presence User 1 Rule: Delay 1 min

Notify Presence User 1 Rule
Conditions/Rule: User 1 present
True:
send message: User 1 has arrived!
set rule boolean false
False:
send message: User 1 has left.
set rule boolean false
Restriction:
Switch to disable Rule: vpresencechangeUser2
Enable/Disable with private Boolean

Notify Presence User 2 Trigger
Trigger: User 2 arrives or User 2 leaves
Action:
On: vpresencechangeUser2
Delayed off: vpresencechangeUser2: 75 seconds
Rule Boolean True: Notify Presence User 2 Rule: Delay 1 min
Rule Boolean False: Notify Presence User 2 Rule: Delay 2 min
Run Rules: Notify Presence User 2 Rule: Delay 1 min

Notify Presence User 2 Rule
Conditions/Rule: User 2 present
True:
send message: User 2 has arrived!
set rule boolean false
False:
send message: User 2 has left.
set rule boolean false
Restriction:
Switch to disable Rule: vpresencechangeUser1
Enable/Disable with private Boolean

This is available for "Delay these actions", but I understand your request. For some time I've wanted to make the entire delay thing more uniform. On the to-do list.

update: Although now one else seems interested in fewer notifications, I thought Iā€™d post an update as an exercise in RM logic as Iā€™ve completely rewritten these rules with RM 3.0. With some of the new capabilities of global variables, I can now directly measure exactly what Iā€™m interested in rather than flipping booleans on and off in sequence to measure time.

Iā€™ve used 3 global variables:
wife time
my time
time difference

here are my new rules:
First have to make note of when presence changes. then after a 45 second timeout evaluate another rule to see if weā€™ve both just left.

after that 45 second delay, one or both of these rules fire. Depending on if the other person is home or away, a message is sent.

This works pretty well. Iā€™m currently watching my ā€œpresence difference variableā€ to see how short I can make that 45 second delay. after just a few days of testing, that number has pretty much been in the single digits, but Iā€™m going to give it a bit longer before I trim it down. the only time that 45 seconds really matters is when one of us is home and the other arrives. otherwise its kind of irrelevant.

1 Like

...and RM4

Detect presence:

Send notifications: