Sequential condition in automation?

HI,

been told one can add extra conditions after an action, to have a next conditional action.

trying to setup I have several correct yaml automations that wont pass the Hassio parser…

please help me in correcting this: desired order: get a (unconditional) message when wife is coming home, and, following that, condition: if the boolean is on, action: announce it over the notify.ios

- alias: Wife came Home
  id: '1511601478134'
  trigger:
    platform: zone
    event: enter
    zone: zone.home
    entity_id: device_tracker.iphone
  condition: []
  action:
    service: notify.notify
    data:
      message: Wife came home
    condition:
      condition: state
      entity_id: input_boolean.notify_announcement
      state: 'on'
      action:
        - service: notify.ios_telefoonmhb
          data_template:
            title: "Activity Speech"
            message: "Please listen"
            data:
              push:
                sound: US-EN-Morgan-Freeman-Wife-Is-Arriving.wav

thanks!
Marius

think the issue is the multiple actions, you can only have 1.
So it would go like this:

action:
  service: notify.notify
  data:
    message: Wife came home
  condition: state
      entity_id: input_boolean.notify_announcement
      state: 'on'
  service: notify.ios_telefoonmhb
    data_template:
      title: "Activity Speech"
      message: "Please listen"
      data:
        push:
          sound: US-EN-Morgan-Freeman-Wife-Is-Arriving.wav

Note I’m not doing this from my usual computer so the indentation is most likely messed up, but hopefully you get the idea…
The way it works is it will run each step under action in order as long as each condition in between is true. If one condition is false, the automation will stop/end and all following actions will not run

thanks!

following the last example on https://www.home-assistant.io/docs/automation/action/

I changed into this:

- alias: Wife came Home
  id: '1511601478134'
  trigger:
    platform: zone
    event: enter
    zone: zone.home
    entity_id: device_tracker.iphone
  condition: []
  action:
    - service: notify.notify
      data:
        message: Wife came home
    - condition:
        condition: state
        entity_id: input_boolean.notify_announcement
        state: 'on'
    - service: notify.ios_telefoonmhb
      data_template:
        title: "Activity Speech"
        message: "Please listen"
        data:
          push:
            sound: US-EN-Morgan-Freeman-Wife-Is-Arriving.wav

which passes all yaml testers, but again halts hassio parser…

will check for the differences in your technique… and report back

green lights on all:

- alias: Wife came Home
  id: '1511601478134'
  trigger:
    platform: zone
    event: enter
    zone: zone.home
    entity_id: device_tracker.iphone
  condition: []
  action:
    - service: notify.notify
      data:
        message: Wife came home
    - condition: state
      entity_id: input_boolean.notify_announcement
      state: 'on'
    - service: notify.ios_telefoonmhb
      data_template:
        title: "Activity Speech"
        message: "Please listen"
        data:
          push:
            sound: US-EN-Morgan-Freeman-Wife-Is-Arriving.wav

it was the

condition:
  condition

bit that blocked correct syntax…
Thanks!

1 Like

If i want the friendly name of the triggering device in the title or message, what would be the correct syntax for that template? Something like " {{states.triggering_device.attributes.friendly_name}} arrived home"

Something like this:
message: ‘{{ trigger.to_state.attributes.friendly_name}} entered {{ trigger.zone.attributes.friendly_name }}’

my uncertainty arose from exactly that: there’s no ‘to’ trigger, only a zoning trigger.

It’s a combined trigger. your device and the zone are both triggers.
Anyway, this is how I’ve got it with exactly your same type of trigger and it works.

thanks! ive setup accordingly, will see what happens tomorrow :wink:

not much documentation on this subject though, zoning and templating. Any suggestions for that you might have would be appreciated. Next to this of course: Automation trigger variables - Home Assistant

cheers,
Marius