Condition ignored in one automation

Hi

can some one help me saying me why my automation isn´t working as desire?

I have this automation:

- id: '1582257001151'
  alias: Apagar Cuarto Luis
  description: ''
  trigger: []
  condition:
  - condition: zone
    entity_id: person.luis
    zone: zone.home
  action:
  - data:
      payload: LVOFF
      topic: LV-Automation/cuarto/luis/apagador
    service: mqtt.publish

And I trigger with this button:

cards:
      - entity: switch.portones_luis
        tap_action:
          action: call-service
          service: automation.trigger
          service_data:
            entity_id: automation.porton_test
        type: entity-button

I want that only when I´m home the automation make that mqtt publish, but in this moment this don´t happend, it no matters were I´m it always make the mqtt publish.

Why have you created an automation without a trigger?

Automation Basics

The first line is the trigger of the automation rule. Triggers describe events that should trigger the automation rule.

Because I only want to trigger it with that button…

should I create a dummy trigger?

Create a script instead of an automation then make tap_action call the script. Scripts can contain conditions and runs services (they don’t have triggers).

script:
  example_script:
    sequence:
    - condition: zone
      entity_id: person.luis
      zone: zone.home
    - service: mqtt.publish
      data:
        payload: LVOFF
        topic: LV-Automation/cuarto/luis/apagador
cards:
      - entity: switch.portones_luis
        tap_action:
          action: call-service
          service: script.example_script
        type: entity-button

thanks, but isn´t working…

I only remplace script.example for script.1582513110015

I don´t know if the problem is that the script is off in the State page:

Try it like this:

cards:
      - entity: switch.portones_luis
        tap_action:
          action: call-service
          service: script.turn_on
          service_data:
            entity_id: script.1582513110015
        type: entity-button

Thanks! now it is working!

Using a script as @123 suggested is the right way to do this. But just to answer your initial question, when you use the automation.trigger service, by default it ignores the conditions. If you want it to not ignore the conditions (i.e., only run the actions if the conditions are met), then you need to specify the skip_condition parameter with a value of false:

service: automation.trigger
service_data:
  entity_id: automation.XYZ
  skip_condition: false
3 Likes

Oh nice to know it, thanks!

when was that added?

Man, I thought I read the release notes OK but these things keep popping up that I didn’t existed. :neutral_face:

2 Likes

In PR 28484, which made the 0.104 release. I didn’t see it in the release notes either, but discovered it while working on the script & automation integrations (and the “script helper” they use.) You can also see it if you select the automation.trigger service on the SERVICES tab of the Developer Tools page. It’s shown in parameter list. Honestly, I can’t find where the automation.trigger service is documented.

2 Likes

thanks for that.

I poked around the docs as well and there aren’t any docs I could find on any of the automation services either.

You would have thought that change in functionality to a base use of any home automation system wouldn’t have been buried way down deep in the “all changes” section of the release notes but would have had it’s own section in the main section. Having that available is kind of a big deal when troubleshooting your (or others) automations.

1 Like

I definitely saw it announced publicly - in 0.104 release notes (search for “Trigger automation without skipping condition”)

Well, I tried to convince Frenck to change and formalise the automations documentation some time ago but it looks like they are not ready for that just yet. Agree, that bits of docs would benefit from updating.

Out of curiosity, where?

edited my post

Yeah, I saw that. I thought you meant something more obvious. I tend to agree with what @finity said above. :slightly_smiling_face:

Well, I do read release notes (and some PRs they implement) because it gives me some kind of up-to-date-ish information (as docs are not always updated in sync with the code).
Don’t know how it should and will be organised but the current state of docs on automation falls behind the majority. I pointed it out to devs and offered some help/ideas but apparently they have their own secret plan. So we can say anything…
Have you recently tried to find a page about command line binary sensor? It does exist in code and in docs but one can’t easily find the docs unless they go to Github and open an appropriate .markdown
WIP