Time-based notification

I am trying to create a rule to check if my 3 garage door sensors are open at a certain time of day (or when mode changes to Night) and notify me if any are 'open'. I cannot seem to make this happen because Notifier needs a change to trigger and Rule Machine doesn't generate push notifications. I have been stuck on this basic automation for weeks and it just seems like it shouldn't be this hard, this should be a basic if X is true let me know (or do something about it) and I'm perplexed. Looking for some of the experts to help guide me please!

This is wrong. RM will do any notifications you want. See Send Message...

1 Like

Found that - don't know how I've been missing that!

Thanks! This got me much closer, what's odd is the notification is not accurate - %device% simply gives me 'Triggered' in the notification, %value% is blank and the date is formatted different than standard notifications I usually get MM/DD/YYYY and this is giving me DD-Mon-YYYY I'm guessing the date is hardcoded that way but device and value are more concerning.

@bravenel any thoughts on the notification variables?

%device% refers to the triggering device, which you don't have. %value% refers to the trigger device value, also which you don't have.

If you want to know which door is open, you would need to test each door separately, and report accordingly. Like this:

IF(Door - Front Door) open Set whichDoor to "Front Door"
IF(Door - Patio Door) open Set whichDoor to "Patio Door"
IF(Door - Storage) open Set whichDoor to "Storage"
Notify Pushover ..." %whichDoor% is open"

Where "whichDoor" is a local variable for the rule. Note those are Simple Conditional Actions.

If you want to know about multiple doors, you could append the door name in the second two, to whichDoor.

2 Likes

This rule uses the variable to keep track not only on which door(s) is open, but also whether any are open at all. It is initialized to ".", and returned to that value after the rule runs.

1 Like

What happens if all 3 are open, can you add to the string?

Edit i see it dose
Just no end if!

Got it makes total sense - what would happen if 2 doors were open though? I imagine it would only have the second door set in the notification and I wouldn't get notified about the first?

For now I am only looking at notification so if any are open it's good enough to simply know to go check, ultimately I would actually build automation in and that's where it's critical to know what device to trigger to close. Is there a way to do it in this type of rule or do I just need to build a separate rule for each door which is manageable with only 3.

Those are all Simple Conditional actions, which is a single condition and a single action. I left off the third door out of laziness. It would look just like the second door.

It will build up the string in whichDoor to include each open door.

Here it is with 3 doors.

By including %whichDoor% in each one except the first one, it is adding the name of the door onto the message to be sent. Not elegant, but you'd end up being told about each door that is open in one message.

Got it - thanks for all the help @Carl and @bravenel - I knew that I was trying to do something wrong but couldn't get on the right path. Works like a champ now!

2 Likes

If the front door is closed and the back door is open the notify will be '. Garage Back Door'. Not something that would cause an issue in the notify message but something to keep in mind.

Which makes me curious why you are setting whichDoor to '.' instead of ''? Does an empty string behave differently in RM?

Because the variable requires data - when setting up the variable initially it doesn't allow a blank value so the '.' is used as the default and then allows for the not equal to evaluation to occur so that no message gets sent if all are closed.

Meh, it was just intended to show an approach to this problem. It's by no means a polished solution. You can have an empty string, but a variable can't start out that way. So you'd have to have the rule empty it at the beginning, instead of at the end (by removing itself from itself).

Yeah I get that, just wanted to point that out for anybody coming along later and wondering why a rule wasn't working as expected. :wink:

It also made me curious as to how RM was handling the strings. Interesting that it needs a value to initialize but can later be empty. A bit of an unusual behavior but I can see where that would come from. I could see that tripping me up at some point. Thanks for the info.

Uninitialized variables are the source of lots of errors, so RM forces them to be initialized. However, there is no current way to specify the empty string, which is a valid value for a string. But, using an empty string implies a degree of sophistication, so I figured one could figure that part out if it was really needed.

In the rule I showed above, delete the last action and insert this one at the beginning:

Remove '%whichDoor%' from whichDoor

Yup, my question was really about learning more about RM. I could see that tripping me up at some point.