Trigger %value% in IF

I had a RM rule as follows:
Trigger: Switch1 changed
Actions: If Switch1 on then do this.
If Switch1 off then do that.

I had to change the trigger to a different switch. When I went to edit the actions I couldn't edit the If part. I had to delete them and reenter with the new switch. Wasn't too big a deal as it was minor.

2 Questions. Why couldn't I change the IF? Is there some way to use the %value% (Which I understand is the trigger value) in an IF statement?

1 Like

When I have an IF statement I want to edit I add an AND plus the new condition and then delete the AND and the old condition. It's a bit of a pain but it works.

And yes you should be able to use %value% in a conditional

1 Like

Does that mean I can? If so How? Or did you mean it would be nice to do so?

Well... I thought you could but apparently not. Let me play with it for a bit.

OK. I couldn't figure out how to use it directly but you can store %value% in a variable and then use the variable in a conditional... I guess the reason is why not just use the current value of the event that triggered the rule? Unless you expect it to change while the rule is processing...

Would seem to me that this is conditional easier and equivalent, and wouldn't require the use of an intermediate variable.

  1. You can directly edit an IF statement and that allows you to add/remove conditions.
  2. If you want to edit the conditions of the IF statement, then you use the "manage conditions" box below the actions table. This would have allowed you to just change the switch out without modifying any other part of the rule.
  3. You can certainly use a variable, but I don't think %value% would have been any benefit here since it would just be "on" or "off".
  4. For a rule like this, a switch can only have one of two states (on or off) so you can simplify the rule to:
IF(switch on) THEN
Stuff.....
ELSE
Other stuff...
END-IF
2 Likes

The Manage Conditions would work. I didn't see that I guess.

Still the whole point was If I change the trigger switch I have to change the actions. If I could just use the value of the trigger, either on or off in this case, then I wouldn't have to change the actions.

Again, no big deal, but kinda wondered if it was possible.

2 Likes

So, %value% is the value of the attribute. The attribute in your trigger is "switch"...so the value is either "on" or "off".

What you want is "Last event device".

Trigger: 'Switch1' turns *changed*
Action:
IF(Last Event Device switch on) THEN
     Do Stuff
ELSE
     Do other stuff
END-IF

That’s it. Never realized that was there before. Thanks

1 Like

Download the Hubitat app