I still don’t know how to do this. It’s killing me. How do I make Sharptools know how many lights are on or off?
You’ll need to use variables, rules and a SuperTile. Assign a variable to each switch to reflect its status (0=off, 1=on). Craft a rule to make the variable properly reflect the light’s status.
In the SuperTile, use a variable/rule to add the values of the variables. The sum will reflect the number of lights on . . or off, etc.
The variable equation is where I’m lost. Let’s pretend I only have 3 lights, what’s the equation I would use to get the sum of how many are on?
Glad @josh split this off so we can elaborate w/o derailing that other thread.
- Create a variable (number) for each light and set the initial value to zero. You will manipulate these to reflect 0 when off and 1 when on.
- Create a rule that triggers whenever the switch attribute of any of your three lights changes
- In the Flow section, create three IF statements, one for each of your lights. IF the light is ON, set the variable to “1”, ELSE set it to “0”.
- Test to make sure your variables are updating as you turn any of the lights on or off.
- Create a fourth variable (number) to hold the sum of the three variables. Set the initial value to 0.
- Edit the rule and add a Set Variable action. The variable you are setting is the one you created to hold the sum of the other three. The source is an Expression which sums the three variables. This action sets the sum of the three variables to the value of the fourth variable.
- Create a Super Tile with a Label and the value of the fourth variable. Optionally, add an icon.
1 Like