How to Toggle between 2 LIFX Scenes using a button press


#1

1) Give a description of the problem
I’ve been trying to figure out how to Toggle between 2 LIFX scenes using a Hank 4-button switch.

2) What is the expected behavior?
When the button is pressed light turns on/off (this is easy, no problem there)
When the button is held toggle between ‘LIFX scene 1’ and ‘LiFX scene 2’
So that each time button is held it switches to one scene or the other

3) What is happening/not happening?
I tried setting if conditions to control it with no luck, I’m newish to coding so I’m a little lost to be honest. I’m sure there is an easier way to do this. Any help would be greatly appreciated!!!


#2

The problem you are going to run into is keeping track of which scene you are in. One way to accomplish this would be through a variable. So, your piston would be set so that when variable scene is 1 and the button is held, it changes to scene 2 and then sets the variable to 2. When the variable is 2 and the button is held, the scene changes to 1 and then changes the variable to 1.


#3

I agree with Ryan. Just be aware that if you toggle either Scene outside of webCoRE, (LIFX app, for example) then your variables will get out of sync.