⏭ Simple Scene Toggle

Came here via google for something slightly different that I ended up making. To toggle between a scene and undoing a scene.

This is exactly what I have been looking for to integrate a Shelly Button to activate various Philips Hue scenes but it appears either the blueprint no longer works or I’m not doing something right.

I have added the blueprint and created a script with multiple scenes added to it. When I tie the script to an action such as a button press, the outcome is unpredictable. A random scene will be activated, sometimes one that is in the included scenes, sometimes not. Most of the time after this first scene activates, no other scenes will be cycled through even though several are in the included list. I’m at a loss as to where to go from here, does anyone have a suggestion?

I am running the following versions of Home Assistant.

Home Assistant 2022.12.6
Supervisor 2022.11.2
Operating System 9.4
Frontend 20221213.0 - latest

same here. triggering random scenes.
Home Assistant 2023.1.4
Frontend 20230110.0 - latest

I’ve created 4 test scenes and a script with the blueprint in order to toggle through the scenes. When triggering the script the scenes get activated as expected. I cant recreate that issue. Did you also get the issue when triggering the script manually in home assistant or just when you do a button press? Can you set transition time to 0 for testing?

Hey, thanks four your thoughts. I think it’s an idea for a new blueprint. Maybe I’ll find time in the next few days.

That would be a great one! Maybe alphabetic order?
Thanks for your script, its great!

1 Like

Hi,

First off all great script :+1: I know absoloutly nothing about code of any description so rely on community members like yourself to get my system/automations running as I would like. I’m 71 but love playing with HA even though I find it very frustrating at times.:rage:

The help I need is, I have 2 scenes for my group of outside lights one for on and one for off.
I am using the button card for this and the script works fine with any combination of the scenes apart from one thing.
When I toggle the button (the icon allways indicates its off) the icon briefly changes colour and indicates on but then turns back to off although the actual lights are operating as they should.
Have I done somthing wrong or am I expectiing to much?
Any help appreciated😏

This is normal behaviour, the script changes state to indicate if it is running. That is why it turns on during execution and off when it is done.

Ah, I’m expecting too much then , I was rarther hopeing that I woulď see the actual state so I would be alerted if they were left on.
Thanks for your assistance and quick reply. :slightly_smiling_face:

Hey, maybe there is a better way. If you just want to toggle lights you can directly map your group entity on the button. If you want some dimming you have to go with scenes. But you also can map your light group on the button and override you tap action where you can call the script. Then you are able to call the script but the button represents the state of your light group.

1 Like

Thankyou very much,
There’s an awful lot to take in with HA and the older you get the harder it becomes.

Hi @panhans

Great bp, and something I instantly got value from but now that I have created a whole series controlling all lights in my house, I can only get half of them to work well. Those that doesn’t work instantly after setup either only turns on a single scene or maybe just shifts between two scenes.

I have both tried to define the Area and let HA pick the Hue scenes by it self, define both the Area and insert the included scenes, and last only defined the included scenes. Same result unfortunately.

The complete setup is with a Friend of Hue automation which linkes to the script which runs the command, but I have also tried to run the script on its own directly from HA. Same result.

Would you know how to debug this, so I can get this to work for all lights?

Thanks for a great contribution.

““solved”” : all scenes has to have a timestamp. If state is unknown, it will never be triggered.

1 Like

@panhans

Could I suggest to add an inclusion/exclusion entities - not scenes but the actual lights - in a dropdown?

Thanks for your feedback. I will check the code again to handle scenes better which has no timestamp!

2 Likes

What do you want to achieve with it? Do you want to add entities to the scenes? This will be difficult, as entities can also be read-only or require other services to activate/deactivate.

I rewrote the code. For me it works fine. Would be great if someone reimport the blueprint and test it with some scenes especially one with the state unknown (never triggered).

2 Likes

I guess I will depend on the use case. For me, I’m trying to get away from multiple apps like Hue, Sonos, Eve, iRobot, Life360, Alexa etc etc. to control all I need from a HA dashboard app on my phone and on tablet on walls.

This scenario would be great for me to add all lights into a room so I can just make a single flow which triggers the lights and scenes I need. Otherwise I would need to build flows for each room multiple times for the ceiling light, bed lights, led light etc even though it’s all in the same room. And of cause I don’t want to activate it all at the same time.

So just curious if this flexibility could be added, and if not I can manage the multiple flows :wink:

Thanks

I would like to be able to toggle between scenes which activates different lights in a room, but also one of the states be the lights being all off. This way I can have a single button on a lovelace dashboard that tapping it will cycle through scene1, scene2, scene3, off.

This is the way an existing hue light switch in the room is setup to control those lights.

I can’t seem to find a way to define a scene in HA that has lights turning off and believe this is by design in HA. Given this blueprint, what is the right way to achieve this? Without this, I’ll need to have 2 buttons on a lovelace card: One to turn off the lights, and another one for scene toggle. Not end of the world but not ideal

I just put my lights in a scene, set them to off, saved it. Then I turned on the light and activate the off scene. And it works. :see_no_evil:

I tried this and couldn’t save the scene with the lights off! Every time I clicked save the scene wasn’t actually added. I’ll try again… :thinking:

@panhans thx a lot for this nice blueprint.
Currently want to migrate from deconz to Z2M.
On deconz i was using the scene toggle with Hue essentials app a lot.

There is an option to restart scene toggling the list from the beginning when a certain timeout expires (configuration option: ex. 10 seconds).

Is it possible to integrate such an feature in this nice blueprint?

thx
pOpY

1 Like