The button card in the lovelace UI has the ability to call a service and that service can be automation.trigger. That would be a useful feature for initiating activity from the UI with no switch or boolean input needed. Unfortunately automation.trigger seems somewhat broken in that automations which have been externally triggered then ignore their internally defined conditions. That means the automation.trigger is not really a trigger. It only executes the action and is the equivalent of the execute switch on the configuration/animations page.
I don’t see the usefulness in having an automation ignore it’s internally defined condition but, even if I am missing something, whether or not to ignore conditions could be made selectable.
Already possible
You can have it respect the conditions by specifying skip_condition: False
in the data section of the services page. Assuming of course you’re on a vaguely recent version of HA.
Conditions can reside in an automation’s action.
If you relocate them there, they will be evaluated when the automation is executed by automation.trigger
.
Ideally, the button should not call automation.trigger
. The primary difference between an automation and a script is the automation has a trigger. If your use-case has no need for the trigger then it’s best to use a script. The button can call the script directly. Scripts can also contain conditions.
How long has that been possible?
I recall reading the PR for it a few versions ago … and then promptly forgot all about it.
I hunted through the documentation for it and found nothing.
This section doesn’t mention it:
It’s not in the Automation integration page:
Nor here:
Not sure how that PR introduced a new feature without updating the docs.
BTW, where you can see it is in the Developer Tools > Services page when you select automation.trigger
.
I found it. It was merged in January.
Thanks everyone for the prompt reply.
That solves my problem.
A correction
Adding skip_condition: False with the developer tools-states page did not work. Adding a condition as the first action solved my problem.
Are you SERIOUS?
(Not you 123, the global ‘You’)
This is a major improvement! How on earth does a project which is so ‘grown-up’ about most things allow this to be implemented and undocumented?
Because… sometimes the devs forget/don’t think about it and nobody else steps up.
Many of us have contributed to the docs to cover things like this, and more. Nothing is stopping somebody adding this to the docs somewhere, other than the usual problem that it’s assumed somebody else will
Yeah, I get that but I just thought it was part of the acceptance process that the docs were updated but if I’m wrong then fair enough (but maybe if it isn’t it should be?).
And yeah, I get that too. I’ve made a few changes to the docs myself
Yeah, it’s the old : -
‘somebody’, ‘anybody’, ‘nobody’ story !
But to be fair, we have contributors from all over the world and perhaps their language skills are far less important than their coding skills, in which case perhaps they should be paired with (say) a native English language speaker from this forum. Maybe moderator or higher ?
The reason why the documentation was not updated is revealed within the PR. It’s not a very compelling reason but it does explain why this new feature has no description.
I couldn’t find any service description of
automation.trigger
within the docs.
As for the feature itself, I have not tried it yet but do plan to test it especially since harvey reported it failed to work.
That just makes no sense …
“I couldn’t find a hook to hang my coat on, so rather than make the hook and hang my coat (all the work I’ve just done). I decided to drop it all on the floor so that everyone could ignore it.”
I actually put in a feature request a while back to have the pop-up window for the automation have an “execute with conditions” and “execute skipping conditions” button so you could do it right there without having to resort to setting up the service call.
It got a couple of votes but we all know that the “feature requests” section is where feature requests go to die.
here it is if anyone would like to vote on it and exercise their futility muscle :
That makes more sense than having to decide in advance of needing it
Me + 1
Revisiting this old thread, since I have problem related to what exactly was described here…
So, I have and automation that applies scene, then checks what is over light level and if dark aditionally turns on LED candles. Clearly for this automation condition is within the action. When triggered from Aeotec Wallmote works perfectly:
- id: 'mood_lights_on'
alias: Mood Lights On
trigger:
- event_data:
node_id: 43
value: "KeyPressed"
label: "Scene 004"
event_type: zwave_js_value_notification
platform: event
action:
- service: scene.turn_on
entity_id: scene.mood_lights
- condition: numeric_state
entity_id: sensor.light_state
below: 0
- service: switch.turn_on
entity_id: switch.ledcandlelights
initial_state: true
Now, I also want to be able to trigger this automation from UI, by just by pressingg the button. Here is the code (part of glance card):
- entity: scene.mood_lights
icon: mdi:music-circle
name: Music
tap_action:
action: call-service
service: automation.trigger
data:
skip_condition: false
service_data:
entity_id: automation.mood_lights
Unfortunatelly it does not work… It applies the scene, but skips part after condition (regardless of skip_condition option setting), so as result LED candles are never turned on. Is it a bug or I’m using this incorrectly? Or skip_condition applies only to the top level automation conditions, not to specific action one?
I know I can overcome this using script, but since automation already exists it is simpler to reuse it (especially that given numner of scenes, I want to apply this concept to, I’d need to create several new scripts, not just one). Any advice?
It’s my understanding that it should perform everything in the action section - including the conditional stuff - unless the condition (or any other thing) references a trigger property (trigger.id, etc).
skip_condition should only be applicable for the condition section.
as far as I know…
if not then submit an issue and see if you get an answer there.
Correct, it skips the condition:
section, not condition:
in the actions.
So fact that HA always skips part of automation after condition inside action is a bug… ?
The condition
in the action will always be evaluated, it shouldn’t be ignored. If it is being ignored that sounds like a bug.