I was wondering whether it was possible to adjust the below code to switch between different scenes, maybe in a specific order, but I just don’t know how to accomplish that.
My thoughts came across an automation that triggers some different colors in the kids room everytime the Cube is flipped.
Let’s say you have flipped the cube and it sets scene1.
You wait 1 hour and then flip the cube again.
Should it set scene 2 or simply set scene 1 again?
In other words, should it keep track of how many flips have occurred, regardless of how much time has passed between flips, or there is some sort of time duration you have in mind after which it resets the number of flips back to zero?
Ah yes - good thoughts and a good question.
I was actually thinking that we should do some measuring with conditions, but maybe I have the answer there and then go with the “choose” option.
So if all lights are off, then do this, but if light 1 and 2 is on then do that and finally if all lights are on then do this third thing. Hmm.
That’s different behavior from what you described in the first post which simply tracks the number of flips and is independent of the state of various entities.
Once you decide how you want the cube to operate, I can help you implement it.
I haven’t decided yet, I just thought that it was a good idea
My initial thought was to switch between the 3 scenes I had in mind; 1,2,3 and then start over even though xx time has passed. But it could make sense to introduce that after 1 hour it should reset.
Create an input_select containing the names of the three scenes. Make the third option the initial option.
Create an automation with an Event Trigger that triggers whenever the cube is flipped. Its action should simply execute input_select.select_next.
Create an automation with a State Trigger that triggers whenever the input_select changes state for 5 seconds. Its action should use the input_select’s current selection to determine which scene to activate.
If you want, the two automations can be consolidated into one.
Finally, create the following automation. Each time the cube is flipped, the input_select is stepped to its next option. If the input_select’s chosen option remains unchanged for 3 seconds, the automation will activate the scene specified by the input_select.
I used scenes because that’s what you requested in your first post. However, the example in your first post doesn’t contain a scene but uses a service call to set a random color. I don’t believe that is possible with a scene. If you want to use the cube to select different service calls or scripts (instead of scenes), I can show you how to do that as well.
The automation in my first post was just used as an example, as I thought it might be doable calling the scenes somehow.
I believe the scene thing as you’ve showed is the right path for me. I’m trying to keep the different light setting as scenes, because I can reuse them in the different rooms.
Currently I have also other automations with the cube turning different media things on, starts stream and also volume control. Nice Little ‘controller’