Double action in automation

Hi all,

I’m kind of having a hard time, sending a double notification on a specific trigger/condition.

I’m trying to send a notification via telegram to 2 different chatids, so basically 2 notifiers.
I figured out how to use an AND statement in the condition, but this somehow doesn’t work the action does it?

action:
action: and
actions:
- service: notify.telegram_wife
data:
title: Doorbell pressed!
message: Doorbell pressed!
data:
photo:
- url: REDACTED
caption: ‘Deurbel!’
- service: notify.telegram_me
data:
title: Doorbell pressed!
message: Doorbell pressed!
data:
photo:
- url: REDACTED
caption: 'Deurbel`

Above the config I’m trying right now. BTW how to paste a config with indentations?

1 Like

You can just use a list for

action:
  - something
  - somthing

Same for triggers btw.

Edit:
This is a OR tho not a AND

Also, just FYI, when pasting code examples here in the forum, use the “Preformatted text” option and not the “Blockquote”, that way we can see your layout in case it is something as simple as a spacing issue that is causing the problem. Also, its just easier to read and find the problem.

Blockquot is better for a single line, such as drawing attention to something someone should type at the command line, such as:

sudo systemctl restart home-assistant

But it does not retain the format of your text, such as the layout of spaces in YAML code, so for that, you would use “Preformated text”, so it looksl like this:

action:
  - service: notify.telegram_wife
    data:
      title: Doorbell pressed!
      message: Doorbell pressed!
      data:
        photo:
          - url: REDACTED
            caption: 'Deurbel!'
  - service: notify.telegram_me
    data:
      title: Doorbell pressed!
      message: Doorbell pressed!
      data:
        photo:
          - url: REDACTED
            caption: 'Deurbel'

This is an action statement, so it is indeed an AND. It would only be an OR if a list was used in the trigger, but the action in list form is always an AND unless you have conditions, such as:

action:
  - condition: or
    conditions:
      - condition: template
          value_template: '{{ states.sun.sun.attributes.elevation < 4 }}'
      - condition: template
          value_template: '{{ states.sensor.sensorluz_7_0.state < 10 }}'
  - service: scene.turn_on
     entity_id: scene.DespiertaDespacho

I assume PhyberApex that you were saying that if it was in a trigger it would be an OR and not an AND, but it was a little confusing, as it could have been interpreted that you were saying a list under actions would be an OR scenario.

2 Likes

Thanks for clearing that up! It was indeed what I tried to say :slight_smile:

Ok tnx all, makes sense now.
The thing is: it’s kinda hard to find the syntax for specific things, except from examples or asking.

Is there any documentation how to use yaml syntax with HA or should I just look into more generic documentation?

I have this bookmarked… it goes into syntax.

1 Like