[Reactor] Help with screne controller cycling logic
-
I’ve added a couple of Shelly Wave i4 as scene controllers and I’m planning to add more, since I can just use standard buttons instead of battery-powered scene controllers, which also looks better aesthetically.
That said, I’m struggling to figure out how to write a simple rule that cycles between states every time I press a button.
Example: Light 1 ON → OFF, then Light 2 ON → OFF.The part I can’t get right is handling the case where Light 1 or Light 2 might already be ON independently of the rule.
Maybe it’s just too much sun and relaxation clouding my brain, but any hint would be appreciated.
-
So, my solution, based on the logic, is this the following.
Cycle Logic (pseudo-blocks)
Trigger: Button press (scene controller state changes)
Variables:
- fan1 = getEntity("zwavejs>13-1").attributes.power_switch.state
- fan2 = getEntity("zwavejs>13-2").attributes.power_switch.state
- skip (default = false)
- lastTurnedOff (text)
Group 1 – Both OFF → Fan1 ON
Condition: skip == false AND fan1 == OFF AND fan2 == OFF AND lastTurnedOff <> "fan1"
Action:- Turn Fan1 ON
- Set skip = true
Group 2 – Fan1 ON → Fan1 OFF
Condition: skip == false AND fan1 == ON
Action:- Turn Fan1 OFF
- Set lastTurnedOff = "fan1"
- Set skip = true
Group 3 – Fan1 just OFF → Fan2 ON
Condition: skip == false AND fan2 == OFF AND lastTurnedOff == "fan1"
Action:- Turn Fan2 ON
- Set skip = true
Group 4 – Fan2 ON → Fan2 OFF
Condition: skip == false AND fan2 == ON
Action:- Turn Fan2 OFF
- Set lastTurnedOff = "fan2"
- Set skip = true
Notes
- The skip variable ensures only one group runs per button press.
- lastTurnedOff lets Reactor know which fan was just turned off by this rule (so it can toggle the other fan on next).
I'll make some other tests and see if it's working as expected. I used Chat GPT 5 giving the Reactor Docs as context and deep reasoning and it helped me a lot. I just had to explain my logic, provide a couple of screenshots and ask for logic blocks instead of script action. YMMV.