Error in automation from doc page copied example

Can anyone see a problem with this? HASS keep choking on the trigger lines, but they are essentially copied from the example on the triggers documentation page here: https://home-assistant.io/getting-started/automation-trigger/ under the section for template triggers.

Syntax looks valid and devices, etc. were checked against the dev panel names and check out.

# Idiot Alert - If doors are open and I leave, remind me
- alias: 'Door Minder'
  trigger:
    platform: template
    value_template: '{% if is_state('device_tracker.rpitera_rpitera', 'not_home') %}true{% endif %}'
  condition: or
  conditions:
    - condition: state
      entity_id: binary_sensor.front_door
      state: 'on'
    - condition: state
      entity_id: binary_sensor.side_door
      state: 'on'
  action:
    service: notify.pushbullet
    data:
      message: 'Robert, you left one of the entry doors open. Front Door is {{ state.binary_sensor.front_door }}.  Side Door is {{ state.binary_sensor.side_door }}.  '

This is the error I am getting; the lines refer to the trigger section:

16-09-06 18:35:44 homeassistant.util.yaml: while parsing a block mapping
in “/home/hass/automation.yaml”, line 181, column 5
expected , but found ‘’
in “/home/hass/automation.yaml”, line 182, column 38

I’m stumped. Is the documentation wrong? Because all I basically did was copy, paste and then change the device tracker name and the state from ‘home’ to ‘not_home’.

OK so I decided to simplify this by just using a state trigger and changed it to this:

# Idiot Alert - If doors are open and I leave, remind me

- alias: 'Door Minder'
  trigger:
    platform: state
    entity_id: device_tracker.rpitera_rpitera
    state:
    from: 'home'
    to: 'not_home'
  condition: or
  conditions:
    - condition: state
      entity_id: binary_sensor.front_door
      state: 'on'
    - condition: state
      entity_id: binary_sensor.side_door
      state: 'on'
  action:
    service: notify.pushbullet
    data:
      message: 'Robert, you left one of the entry doors open. Front Door is {{ state.binary_sensor.front_door }}.  Side Door is {{ state.binary_sensor.side_door }}.  '

Now HASS loads, but the automation load fails with the following error:

16-09-06 18:42:47 homeassistant.bootstrap: Invalid config for [automation]: expected a dictionary @ data['condition'][0]. Got 'o'
expected str for dictionary value @ data['trigger'][0]['state']. Got None
extra keys not allowed @ data['conditions']. Got [OrderedDict([('condition', 'state'), ('entity_id', 'binary_sensor.front_door'), ('state', 'on')]), OrderedDict([('condition', 'state'), ('entity_id', 'binary_sensor.side_door'), ('state', 'on')])] (See /home/hass/automation.yaml:179)

The line references to the "- alias: " line in the automation above. There is no other alias with the same name in the automation file.

I’m running out of ideas. I just want HASS to let me know I left the door open…

1 Like

You’re missing a condition: line. Try this:

  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.front_door
        state: 'on'
      - condition: state
        entity_id: binary_sensor.side_door
        state: 'on'
1 Like

Uggh! that’s what I get for copying and pasting - the documentation IS incorrect. It doesn’t show the top condition line. I’m restarting now and I’ll let you know. Thanks for replying!

Now I am getting this error:

16-09-06 19:44:04 homeassistant.bootstrap: Invalid config for [automation]: expected str for dictionary value @ data[‘trigger’][0][‘state’]. Got None (See /home/hass/automation.yaml:180)

Automation now looks like this:

- alias: 'Door Minder'
  trigger:
    platform: state
    entity_id: device_tracker.rpitera_rpitera
    state:
    from: 'home'
    to: 'not_home'
  condition:
    condition: or
    conditions:
      - condition: state
        entity_id: binary_sensor.front_door
        state: 'on'
      - condition: state
        entity_id: binary_sensor.side_door
        state: 'on'
  action:
    service: notify.pushbullet
    data:
      message: 'Robert, you left one of the entry doors open. Front Door is {{ state.binary_sensor.front_door }}.  Side Door is {{ state.binary_sensor.side_door }}.  '

If you use the from/to states elsewhere maybe try copying them and pasting over the text that’s getting the flag? It’s a longshot I know but perhaps some weird characters got copied from the documentation.

1 Like

Remove this line.

  trigger:
    platform: state
    entity_id: device_tracker.rpitera_rpitera
    from: 'home'
    to: 'not_home'
1 Like

That was it @AlucardZero! I wish I could understand these error messages better so I wouldn’t have to pester you!

But I really appreciate the responses from you, @fanaticDavid and @quantumpelvis. I spent all day at a client’s site worrying if I left my door open at home because I didn’t have a door sensor installed on the new front door yet. In finally figured out that since i had a multi sensor was near the door, if the door was open, the light readings would be high. They were at 0.0 so I rested a little easier and in fact the door was closed.

This was an attempt to prevent that from ever happening again so I just installed the sensor and started writing the automation. I really appreciate all the help guys!

2 Likes