Rule machine %device% help

I have this triggered rule:

It actually caught an open window today, however, it said:
"Main Thermostat is open, please close it."

How do I get it to announce the rule failure, not the trigger? Is it possible?

You would need to switch it around so that it's not a Triggered Rule, but just a rule fired by one of the windows opening. Make the thermostat operating states conditions, and add them to your rule. So the rule becomes x, y or z opens AND (thermostat state heating OR thermostat state cooling).

BTW, the way you had it only checked when the thermostat operating state changed, not when a window opened. You want it checking every time a window opens.

Hmm. Let me take a step back.
Usage Model: I open the doors and windows to have cool air come in the house. I forget to close them and it gets warm outside. I'd like an alert that I forgot to close them when the AC starts.

Is that possible?

You would have to put the opened window in a global variable, not get it from %device% when the thermostat kicks on. This is tricky because you want the rule to run for any window opening, if only to gather the device name. So you should use the rule I showed above, but with changed for the thermostat state.

So the rule will run and be false whenever a window opens but the thermostat state didn't change. That gives you the chance to get the window device into a variable in the false actions. In the true actions, you know it became true because a window is open and the thermostat state changed. You have to test to see that the change to the thermostat is one of the two states you're looking for. Then you can put that variable into the message.

1 Like

I am really struggling with almost this same issue (really just wanting the device name to populate not from the trigger device). Thereโ€™s no way I can rewrite it to accomplish that with the below, is there?

A lot has changed in four years, including multiple new versions of Rule Machine rules, but the issue above still more or less is the same: the built-in %device% variable only gets populated with the name of the trigger device. So, a more direct answer to your question: there's no easy way to do it with what you have above. (There would be if you could re-work it to trigger on the devices instead, but I'm not sure that's easier--and it wouldn't really help if you have multiple device names you want in the variable.)

Two options: you could re-write your rule actions to build a string that you then send as a notification. You can build it using IF THENs (conditionals) based on current device states. I have an example of such a rule in the post I'm linking to below.

Alternatively, I wrote a custom app to do exactly this since I found such rules got hard to manage with large numbers of devices. That app is here:

If you don't want to use a custom app or aren't comfortable doing so, that post is also where I wrote an example of the kind of rule I mentioned above. Either option should work for you. (That was technically in Rule 4.x, but it would look basically the same in the current version, Rule 5.1.) Good luck!

1 Like