Just to be clear: this is not about the Initial State, because that controls whether the automation reverts to the last state or not.
Let’s assume that an automation controls a light to be either on or off.
Like I understand it now, if this automation itself is switched off (either manually through the Configuration web interface or via a Service call), than the light keeps its current state, so either on or off.
Now let’s assume that I want the light to be off by default, and that it only should go on temporarily when the automation tells it to.
Is it possible to configure the automation such that the light is automatically set to the default state when the automation is turned off?
So basically there should be an attribute “default_state” in the automation configuration that defines the default state of the controlled device(s), and it should be possible to trigger that default_state when the automation is turned off.
Does this exist in Home Assistant?
And what if you have multiple automations that use the same light ?
No and it’s unlikely there ever will be. You have based your entire argument on a non-existent association of an entity’s default value to an automation’s default value and/or state. There is no such association.
-
On startup, an automation’s state is determined by the
initial_state
option but only if it is defined. Without the option, the automation’s state is whatever it was prior to the restart. -
On startup, an entity’s state is determined by its specific integration.
Interesting! I never thought about that possibility.
But I don’t understand yet why that would make my assumptions invalid.
Isn’t this always the case? We don’t want to initiate a “war of the automations“
I can still imagine that in specific cases this might be an interesting option.
Let’s assume that we have several automations that control lights, but occasionally we want to keep the lights off independent of any other trigger or condition.
Then there could be a button on the HA Dashboard that switches off all the applicable automations, which in turn switch-off all these lights before they switch-off themselves.
Or more generally spoken: A Button on the Dashboard that (temporarily) switches some specific devices to a Default State and keeps them in that state independent of any other trigger or condition.
Thanks Taras, that’s clear.
So this doesn’t exist yet in HA.
I will give it some more thoughts, and maybe I will make it a Feature Request if I still think it might be useful.
That’s achievable with an automation. I don’t see the justification for avoiding the use of ‘trigger or condition’.
Example:
I have automations to control sprinklers and pool lights based on a schedule. These entities should not be turned on during the off-season (mid-October to mid-May for where I live). To prevent it, I hide their controls in the UI during the off-season (automatically).
However, it’s still possible to ask Alexa to turn on sprinklers and pool lights. If a spoken command turns them on, the automations are designed to immediately turn them off … and Alexa replies “I can’t do that because it’s off-season.” (to remind the user why their request was denied). It’s the automation’s logic that can be used to determine an entity’s state (not some concept of a default value).
Thanks for the example, and nicely done with your Alexa setup.
I think that in your case it is easy to preclude with some time constraints, but what if the automatic off-season switch would happen while the sprinklers are running due to their schedule?
Are the sprinklers than still be switched off automatically?
Of course it would be possible in general to have a button on the dashboard that would switch-off some specific automations and then set the associated devices to a specific state.
But wouldn’t an automatic change to a default state be more easy?
It would mean that we need an (optional) default_state on the entity level (that probably already exists for many integrations?), and an (optional) default_state setting in an automation that when set to True would make sure that the entities are going to their default state when the automation is switched off.
It’s not a switch it’s a Template Binary Sensor. It’s state is on
if the current date is within a specified range. The only plausible way it could fail is if the system clock is misconfigured (and the result of that would be felt throughout Home Assistant).
Turning off automations as a way to control logic is an anti-pattern (i.e. an unrecommended practice). The automation’s logic should determine if and when it should perform any actions. There are valid reasons for turning off an automation but seasonality isn’t one of them.
Based on this proposal, and your follow-up questions, I get the impression you are fairly new to Home Assistant and haven’t quite fully grasped its concepts. Respectfully, I suggest you get more experience with it before submitting Feature Requests based on a misunderstanding of Home Assistant’s core concepts.
Thanks again Taras.
Yes, you are right: I am working with IoT for only a few months now, so am still learning a lot.
But on the other hand: inexperience can sometimes lead to fresh ideas that no longer occur to someone who has been working in a fixed way for a long time.
Anyway, I will not issue any Feature Request without first checking the opinions from pro’s like you in this community, so don’t worry