Is it possible for an automation to contain a trigger that fires when the automation itself is turned on and each time it is turned on [after off] during a single HA persistence session (i.e. not each time HA starts but each time the automation is started).
How would i define such a trigger in yaml?
Reason:
I have an automation “A” that can be turned on by a number of other automations, “B”, “C”, “D”, and so on. I’d like to set up a trigger in “A” such that it fires whenever turned on by “B”, “C”, “D” or any other mechanism.
Yes. Automations are entities. Add an entity triggered automation that uses the automation you want to run with a state to “On” as the trigger.
The trick is - if you are creating it with the gui, use a different automation entity when you create it, then go back in and change it to the one you created.
in yaml:
- id: new_automation
alias: New automation
description: ''
triggers:
- trigger: state
entity_id:
- automation.new_automation
to: 'on'
conditions: []
actions:
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.floor_lamp
mode: single
Why are you turning off automations?
Add conditions to them instead.
But in this case I believe you should use a script instead.
Makes no sense to have one automation trigger another automation by enabling it.
Because I do and that is how I have modelled the smart home. It is completely “legal” and within the native capabilities of HA, it is my choice, and importantly it works and operates how I want to operate. Your argument would appear to pivot around a personal view on how others should model their smart home, based on well founded rationale no doubt. However at the moment I am learning and there is much to learn, not easy, but I am getting there. I have neither time nor inclination to finesse or aesthetically please others, I just need to model the home so it works. In good time I may do as you suggest although I anticipate that someone will have an even better way as there is no right and wrong in design, everyone will have their own view and those views are perfectly valid even when I do not share them. Thank you for sharing your wisdom. @zoogara has answered the OP
Unsubscribed before floods of negativity arrive in … TTFN .
EDIT:
Actually @Hellis81 you are offering 101% sound advice, I just read up on Conditions and I can implement the on/off of automations with conditions. My model includes a number of automations that I manually turn on/off depending on time of day , whether I am leaving home, arriving home - that type of thing. Now, with hindsight and reflection based on your suggestion, I rescind all pushback and accept that your proposal is indeed more than esthetical , it is more appropriate. I am implementing conditions henceforth.
Please accept my apologies borne out of ignorance.
Even the one who has solved it for you has acknowledged the answer of which you responded so negative on.
You might have gotten a far more better solution for your automations, that’s how this forum works.
I have much to learn with HA - only been using this 2 weeks from a position of complete ignorance and awareness of the internals/config and so much to read and learn.
(I keep replying-to but the post isn’t linked to the commenter so I have to delete and try again - seems to work 2nd time around)
Wow you seem like such a great guy.
Do whatever you want. But when you do change things it’s going to be much much worse.
If you want to play tennis with a golf club then we won’t stop you but using the correct tool makes it easier in the long run.