Hey guys, I just started with Home Assistant. For now I made 2 scenes. One for when watching a movie, and one for just the evening chill. The evening chill scene turns on automatically at sunset. The problem however, is it also does this when i am watching a movie and the movie scene is on. This is annoying. Therefore I would like to edit the automation such that the evening chill scene only turns on if the movie scene is not on.
I read that the state of a scene is always “Scening”, so this can not be used as a condition.
Do you guys have any idea how I can accomplish this?
As you have already discovered, a scene’s state is simply scening. Effectively, it is stateless so you cannot tell if a scene has been applied (i.e. “on”) or not.
You’ll have to keep track of that using another entity, such as an input_boolean, turning it on whenever you activate the scene and turning it off when appropriate (you’ll have to determine what constitutes a scene not being in effect).
Here is a suggestion that employs a Template Switch. This is modeled on something I use to provide an “artificial state” for a scene.
The idea is to create two Template Switches, one for each scene. The result will be:
switch.movie
switch.chill
How it works:
When you turn on switch.movie, it will store the current state of various entities (that you have predefined; basically they are the entities in your existing movie scene) in a temporary scene called scene.before_movie and then activate your existing movie scene. (The temporary scene is lost after a restart.)
When you turn off switch.movie, it will turn on scene.before_movie, effectively restoring the state of the predefined entities.
Each Template Switch’s state is stored by an accompanying input_boolean. You must create the following two input_booleans:
input_boolean.movie
input_boolean.chill
So when you want to activate the chill scene, you turn on switch.chill. It has a state value so you know when it it on. Now when you compose your automation, you can easily determine if either the movie or chill scenes are activated by examining the current state of switch.movie and switch.chill, respectively. Example:
In the following example, the entities you see listed in snapshot_entities should match the ones used in your scene. They are the entities whose current states will be stored to scene.before_movie and then restored to those states when the switch is turned off.
Your suggestion is a clean and easy way to keep track of one scene at a time.
The advantage of my admittedly more complex suggestion is that it can handle multiple concurrent scenes (i.e. more than one scene can be active at the same time). In fact, if scenes have entities in common, this arrangement allows you to “stack” scenes.
For example, let’s say two scenes have light.tv in common. One scene is handled by a Template Switch called switch.movie and the other scene by another Template switch named switch.doorbell.
Turning on switch.movie sets light.tv to 25% and deep blue.
Someone rings the doorbell which turns on switch.doorbell which sets light.tv to 75% warm white and pauses media_player.tv (if currently playing).
After you are done with the visitor, you turn off switch.doorbell. That restores entities to their pre-doorbell states so light.tv goes back to 25% and deep blue and media_player.tv plays again.
Throughout all of this, switch.movie remained on. Turning it off will restore entities to their pre-movie states.
Dude, this is great! It took me some time to comprehend everything you said and putting it in my files the right way. But eventually it is working, exactly as you said!