RM 4 - %device% variable

I have a "Goodnight" RM 4 rule that is triggered when mode switches to "Sleep". I have an "IF" statement setup to check all contact sensors and if a contact is open I have an action setup to send a notification saying "%device% is still open at %time%. The rule runs ok except that when a device is detected as opened the %device% variable is my location vs the actual contact device so the notification says "My Home is still open at 11:00pm". What am I doing wrong on this? Screen shot of rule attached.

You're not doing anything wrong. %device% resolves to the device that triggered the rule (Mode is actually location.mode in Groovy code).

I believe they are working on a change to that to allow for what you are trying to do.

Got it! Thanks!!!

1 Like

I don't think so.

%device% refers to the last event device. For this rule, triggered by mode, there is no last event device. There have been a number of topics that discussed how to construct a rule like this, one that warns about devices open at a certain time. This one won't work as desired.

1 Like

Ahhh, gotcha. Yeah, I wasn't 100% certain on if you were working on it or not, but I've seen a lot of chatter about it.

This looks like it would probably work for what your trying to do:


Yes..I'm back to searching the forums on how to set this up as a rule but if I can't locate where this has been discussed in the past, I will punt to the app. I've already got it installed and ready to run. :slight_smile: Love the flexibility and power of RM 4.0 but definitely has been a learning curve for me.

Ok..I will continue my forums search now that I know what I'm looking for.

Use a HSM custom monitoring rule, %device% correctly sets. Credit to @Ken_Fraleigh for this tip. This is my "Door Left Open" notifier.


Hi there - I had a related problem (I think) and found a workaround by setting a global variable within the conditional rule set.

In your particular case, you probably could have simply used %value%, as it should contain the value of the trigger event that caused the rule to run.


Thanks - I did try that at first, but it came up with 'null'.

What was the event? Take a screenshot of the Events from the Openweather device (top of device page).

1 Like

Here you go - it looks like "Temperature" is an attribute value below an event.

I will look into this a bit... Not sure why %value% was not set properly.