Indentation error adding delay

Hi guys,

Trying to setup a simple greeting automation to play a custom sound on my Xiaomi Aqara Gateway when a user enters home .

Having some issues trying to setup a delay before the action takes place .

Here’s my code :

- alias: Greet user when entering Home
    trigger:
      - platform: state
        entity_id: binary_sensor.motion_sensor_158d0001d66669
        from: 'off'
        to: 'on'
    action:
        delay: '00:00:05'
        service: xiaomi_aqara.play_ringtone
        data:
          gw_mac: 34ce008b0000
          ringtone_id: 10002
          ringtone_vol: 70

From what I’ve seen in other examples it’s ok to have delay inside action but in this case I think there is some indentation error with the delay line, as it all works properly when I remove it .

What do I need to change here ? Please bear with me, just started using HASS 2 days ago :slight_smile:

Thanks

Try the following:

    action:
      - delay: '00:00:05'
      - service: xiaomi_aqara.play_ringtone
        data:
          gw_mac: 34ce008b0000
          ringtone_id: 10002
          ringtone_vol: 70

The docs on YAML will be a good read also.

1 Like

Thanks that worked perfectly !

Definitely need to do some reading on the subject :blush:

Its a steep learning curve if your not used to YAML.

A good text editor will highlight YAML errors. Visual basic with the HA extension is fantastic.

This is a clumsy analogy but think of action as being a bulleted to-do list. Each task starts with a bullet-point (a hyphen).

Things to do:
- Buy groceries.
- Get a haircut.
- Pay bills.

Additional information for each task typically does not use bullet-points unless that’s a list as well.

Things to do:
- Buy groceries.
    dairy: milk
    meat: chicken
    fruits:
    - apples
    - oranges
- Get a haircut.
- Pay bills.
    credit_card: 125
    utilities:
    - electric: 45
    - gas: 65
1 Like