Thanks for PM’ing the Rule ID! You’ll need to add whatever events that you want to trigger the rule in the Rule Triggers section.
So if you wanted the rule to be triggered when any of your relays changed to on or off, you would need to add both the ‘on’ and ‘off’ triggers for all the devices into the Triggers section.
As a side note, you could just set the $poolspeed
variable with text directly rather than copying the value from another variable if you want. I wasn’t sure if you had some other reason for storing the speeds in variables though as perhaps you are using those some other way.
–
I mentioned it briefly before, but this might be a situation where capturing the Device Statuses to variables and then running an expression might simplify things. It would also be slightly more efficient as it would have fewer calls to SmartThings to retrieve statuses. Otherwise with each of the nested IF conditions, the system has to ask SmartThings for the status of each device for each condition, so it asks for the values multiple times and adds some minor delay (probably not noticeable, but I figured I would mention it).
Do I understand correctly that the relay mappings are as follows:
On |
Speed |
R4 |
off |
R2 |
2800 |
R1 |
3100 |
R1+R2 |
1850 |
If so, you could do something like the following:
I understand that everyone has their own preferences and each person will find one approach more intuitive than the other, so do what makes sense to you!
The overall concept in my rule screenshot above is the rule is triggered when any of the switch statuses change (on/off), then I snapshot each of the switches into text variables so I can use their values in an expression.
In the expression, the first thing I do is map the switch statuses (“on” or “off”) to a boolean value where "on" = true
so I can more easily use them in the comparison. Then the last thing I do is a series of comparisons (ternary conditions: condition ? trueExpression : falseExpression
). I start with the heaviest weighted scenario (Relay 4 is on), into compound scenarios (R1 + R2), and work my way toward the least weighted scenarios.
The last step of the expression is assigning the value to an expression local variable aribitrarily named speed
. This variable only exists within the expression, but the output of it will be assigned to your variable (in my screenshot that’s $AATmp
, but you would select $poolspeed
in your dropdown).
The output text in my example was just to make it clear what the result was… of course you would want to change those to your descriptive speeds.