The first trigger work without issue, the second part however doesn’t. Whenever the automation is being enabled I see the trigger being activated, but it does do the thing it should do.
Sorry, tried that and tried it again but that didn’t do the trick.
It might be that the trigger is the automation itself, so whenever this automation is turned on this automation should do something.
Ok, explain your use case more. What is running the automation apart from your contact sensors and under what situation are you looking for it to notify the automation is turned on?
Oh, actually i think i get the issue. You are looking to send a notification when the automation is enabled? Ie goes from disabled to enabled? This is not the same as the automation being on or off. On means the automation is running, not that it is enabled. There is no event that happens when you enable automations to trigger from.
I think your best best is to have an input boolean helper that defines if your automation is enabled/disabled and use this as a condition in your automation so that it will not notify if your input boolean is On when a contact sensor triggers it. Then have another automation that triggers when your input boolean is turned on to notify automation is enabled and maybe again when turned off to notify disabled etc.
I hope there is some other option than creating more sensors.
The first three triggers are the doors of our children and the automation will warn us that our private time is going to be interupted by one
I could implement a helper “private time” and use it as a condition in the automation, that way I never have to turn on/off the automation.
Yes, had a bit of a play and you are right, however, i think then it is because you cannot do thisnon itself. If i try with another automation it works but not itself. Probably because the trigger maybe runs before the automation is re-enabled.
I would def use the private time helper method and then you can have as a switch on a dashboard to enable/disable.
Alternatively just put padlocks on the outside of their doors!
the automation state of on means that the automation is enabled. not that the automation is currently running.
And to the OP, yes, I think you need a second automation to detect the first automation is enabled (to the ‘on’ state).
Or better yet try to work out a way that the first automation shouldn’t need to be disabled and actually use logic to do what disabling the automation accomplishes for you.
Go to Developer Tools > States and check the states of your automations. Unless you have disabled any, they’ll all be on which means that they’re enabled.
An automation that’s running (i.e. is busy executing its actions) will have its current attribute set to 1 (or higher if multiple instances of it are running).
When an automation is disabled, none of its triggers are functional. They become functional only after the automation is enabled. That’s why an automation cannot detect when it has been enabled.
Which is what I had suspected. The automation never triggered when it was turned on.
An automation cannot detect itself being turned on because the trigger responsible for detecting it isn’t functional until after the automation is turned on (at which point it’s too late to be useful).
I have to agree to you on that. I also think that I’m the only one looking at this as an “issue”, it would be nice if one could include some actions that happen aftere the automation has been enabled?
I could think of some usecases: One could have some automations running during the year, but when going on holiday you enable the holiday automation; a message will confirm that the regular automations have been disabled and the holiday automation has been enabled. Ofcourse you could place a switch on your desktop that does the same, but why be reminded the entire year of that single event
It’s the way the system is expected to work. And by the very nature of the way automations work it HAS to be that way.
There is no way to sense an automation that is enabled in the automation itself because as mentioned several times the automation is disabled when the trigger comes that it has been enabled.
Again, try to come up with a way that doesn’t require the automation to be disabled because that is generally bad practice.
Please explain the general bad practice part of turning on and off an automation.
From my point of view for each automation there is a process monitoring entities, services, etc. How limited they might be in resources, why should you take up these resources when not needed? Again from my point of view doing some actions when an automation is being restarted is nothing more than executing some commands after an IOT device has been woken up. I can create an automation that monitors the state of the automation and will execute some actions when states change (like broadcasting a message what automations have been turned on).
Optimally, an automation should work only when required. In other words, its designed to execute its actions only for specific reasons and not execute them for all other reasons. It should make decisions without manual intervention.
It shouldn’t need to be taken in and out of service as part of its normal operations. Reserve the act of disabling an automation for maintenance purposes. More here: