Device Wildcards

I am new to Hubitat from SmartThings and have had everything moved over for about 2 weeks now. So far everything is working much better and so much faster. However, I am having issues trying to get a notification working correctly using wildcard %device%. I am using Mode Manager to set the mode to Away when everyone leaves and then Rule Machine runs some automations when the mode changes. One of them being to alert me via push if a window was left open. I was hoping %device% would give me the name of the window that was left open but instead it is giving me the name of the Hubitat hub. From what I have found this is due to the fact that the trigger is the hub’s mode so the %device% is reporting the hub name. How do I rewrite this to give me the window name instead?

Here is a list of what the rule does.
Trigger: Mode becomes Away
Actions to Run
Off: Living Room TV, Lights, etc.
On: Living Room Camera
IF: (Bedroom Window, Living Room Window any open THEN
Notify David, Kaitlin: %device% was left open.

A while back, I had the exact same problem. Addressed it by creating a Global Variable that would list the windows that are open. The notification sent by the rule was then the value of the Global Variable.

Not home at the moment, but I can post the rule when I get home if you need help creating a Global Variable that lists the windows that are open.

%device% and %value% always refer to the trigger that kicked off the rule. So you will need to do something externally, like Stephan mentioned, to get a list of non-trigger devices that meet the criteria.

2 Likes

Thanks for the quick reply. I will do some research on creating a global variable. If you have time to post what you did that would also be very helpful.

Sure thing, should be home in 2-3 hours.

Here is my rule for when I am arming my system. A bunch of lights are turned off immediately, some lights turn off after 55 seconds (gives me time to leave the house). And my stereo system will turn on and notify me of the windows that are open. If you would rather have a phone notification simply change the type of notification.

As you can see in my rule, I created a string variable called "WindowOpen". The way the rule is written I will only be notified of the windows that are open. At the end of the rule the Global Variable is reset to "-" and is ready to be evaluated the next time I activate my alarm. In your case your trigger will be mode becomes "away" and the window condition will reevaluate every time the mode becomes "away"

I remember asking for some help when creating this rule, so the credit is not mine, it was a while back so I can't remember who it was that helped me.

3 Likes

This is one area where I feel like Webcore might be the way to go. I have it check all the devices and save a list in a variable, and then send one notification with the entire list. (Unless someone can tell me a way to build a list in RM that does this as efficiently)

The Rule I posted above builds a list in RM. I just created a Rule Machine Global String Variable (that I called "WindowOpen", the rule shown above will populate that string variable with a list of windows that are open when the trigger takes place. Once you have the list you can do whatever you want with it, in my case I have my stereo system tell me which windows are open.

The trigger for my rule is: arm-away button pushed. When I push this button on my dashboard (on the wall in my foyer). The rule executes, it starts by turning every light in the house off, except for a few lights that the rule turns off after a delay. Then it does the window checks and writes to the Global Variable. Then if there is a window open it sends a command to another custom app (squeezebox integration) that speaks out the windows that are open.

The time it takes between me pressing the button and my stereo system starting to list the windows that are open is less than a second. Less than a second is efficient enough for me.

I am curious to know if webcore is faster than RM, although in this case I am not sure how I would compare times that are under a second. I do notice that you have a wait 5 minutes in your webcore post above. If you remove the wait condition how long would it take before your system speaks out the windows that are open?

This worked great, exactly what I needed. Thank you.