What this does
It allows you to toggle a scene on and off with a single input. Without this blueprint, there is no easy way to ‘undo’ a scene activation in home assistant.
How it works
When triggered it saves the current state as a new scene scene.my_scene_store_previous_state
before then activating the scene e.g scene.my_scene
. When triggered again it simply activates scene.my_scene_store_previous_state
. It alternates between the 2 by seeing which of scene.my_scene_store_previous_state
& scene.my_scene
was the last to be triggered.
Once the timeout has passed since scene.my_scene
was activated it assumes a new session has started and will start by saving the state and activating scene.my_scene
. Even if it was due to activate scene.my_scene_store_previous_state
next.
After a restart the first activation will always be to implement scene.my_scene
as the pre-scene state is lost at restart.
Of course if the state before you activate the scene is identical or similar to the scene then it will toggle between 2 identical states and you won’t notice any difference.
Requirements
- At least one scene
- A second automation to trigger this one.
How to uses
- Click the link below to import the blueprint and create it with the desired settings.
- Run it by calling the service
Automation: Trigger
from automations, UI buttons or the developer tools. - More advanced users can fire an event. The automation listens for a custom event
event: scene_toggle
event_data:
entity_id: scene.my_scene
Change log
2022-11-24 Version 1.0
Help wanted - I do not know how to do these things
- Allow the user to specify triggers and conditions within the blueprint - How to have user configurable triggers and conditions in blueprints?
- Create a helper within the blueprint to store the state and toggle Extend Blueprints to include Helpers, multiple Automations/Scripts and Lovelace - #21 by brianewman
- Allow the user to listen for events as a trigger. There doesn’t seem to be an events input for blueprints
- It may be more elegant to check if the current device states match the scene and then decide whether to toggle on or off based on that. I am not sure on how to achieve this though.