…or do I need to put this in an automation which triggers from an input boolean or something like that?
From searching the forum I get the suggestions that a python script could resolve this but I’m reluctant to go down that rabbit hole.
I guess I can just duplicate the ‘actions’ I have in the automation as ‘actions’ in the script.
That would be the easiest, thank you for helping me work through this.
Since triggers are or’ed, you can add another trigger based on the state of say an input boolean, and have the script turn that boolean on.
However, if your conditions or actions depend on the trigger variable, this will get tricky.
… actually if there is a way of triggering an automation from a script that would be helpfull.
One of the automations has a condition which I need and I can’t include conditions in scripts.
I know I can trigger an input boolean which can then trigger an automation but it seems rather long winded when a simple “homeassistant.turn_on” will do the same?
and you’re trying to make a script execute an automation. Let’s look at this another way:
How about taking the action portion of the automation and making it a script?
Now you can make an automation whose action section executes the script.
That script can even be executed by another script.
As previously stated, turning an automation on or off just enables or disables the trigger/condition processing. However, no matter whether it’s on or off, or what the triggers or conditions are, you can always cause the actions to run by using the automation.trigger service. E.g.:
Be advised that an automation called by automation.trigger will ignore its trigger:and its condition: sections. In other words, only the automation’s action: section will be executed. If that’s what you’re after then all’s well.
Annoyingly, you are correct. The condition is ignored and the actions are triggered only. Urgh!
Looks like I’ll have to trigger a dummy switch (input boolean) which can then trigger the automation. Seems like quite a long winded way to trigger something that’s already been set up
It’s not really “mixing up the order of things.” It’s selectively using the options available – in this case, using the automation’s condition section and/or a script condition step. (Note that the action section of an automation is really a script.)
Hi Phil,
if I update the title of this forum with:
‘Runnin an automation within a “PYTHON” script’ could you be able to help me?
How can I call the automation.trigger within a pyhon script?
Hope you can help me.
Thank you in advance.
If you read the doc page on Python Scripts, and follow the links therein, pretty much you should find all the answers. The only thing that seems to be missing is the optional parameter to automation.trigger, which is skip_condition, but you can find info on that if you go to the SERVICES tab of the Developer Tools page (in the HA UI) and select the automation.trigger service.
If you want it to skip (i.e., ignore) the automation’s condition section, then either set skip_condition to True, or just remove that line from the call.
Ciao Phil, thank you so much for your prompt reply… I’m so new (I’m joking with HA in the last week) so today I’ve started giving a look to python scripts in order to front a binary sensor’s issue and I’m still trying to understand how to activate python scripts (at moment I’ve done it trought automations.yaml because I didn’t understand how to start them “calling the service” (inside configuration.yaml).
Thanks a lot, really appreciate an hand like yours. Cheers!