What am I doing wrong with my automation?

I’m trying to do what I hope is a pretty simple automation. With the alarm is set to home, lock the doors to the house. This is what I’ve done so far but it doesn’t seem to be working. Any guidance? This is my first automation.

- id: '1547594185509'
  alias: Secure the House
  trigger:
  - entity_id: alarm_control_panel.2304_main_line_blvd
    platform: state
    to: armed_home
  condition: []
  action:
  - condition: state
    entity_id: lock.front_door
    state: lock
  - condition: state
    entity_id: lock.rear_door
    state: lock

you have conditions in your action. not correct. they should be service calls.

ie:

  action:
    - service: homeassistant.turn_on
      entity_id: lock.front_door
      state: lock
    - service: homeassistant.turn_on
      entity_id: lock.rear_door
      state: lock

however I’m not familiar with lock states so best to check the docs on that one.

EDIT: plus there are some indentation issues. See my (updated) example. ie: 2 spaces then the dash, then another space

FYI, that is the conventional way to do it, but lining up the dashes with the item above it is legal for YAML lists, too.

1 Like

I thought the same thing for a long time but that syntax is also correct. It’s not user-friendly for readability but it will pass the config check.

1 Like

Fair enough. I guess I have just got myself into the habit of setting up my config so that entries are all like a list to make it easier to add entities later on and kinda forgot that when posting

Not sure we’re understanding each other. Just to be perfectly clear, I’m saying:

  abc:
    - 1
    - 2

is equivalent to:

  abc:
  - 1
  - 2

They are both lists, and they’re both legal YAML. I tend to do the former, too, but the latter (at least to me) is just as readable and has the advantage of being more compact. But, in the end, it’s really just a question of style. :slight_smile:

oh ok. yep, I get you. Not sure what I was thinking when I wrote that… I should really stop trying to do too many things at once! (or perhaps get off this forum while I’m at work :stuck_out_tongue_winking_eye:)

1 Like

But, getting back to the OP, I don’t use locks either, but according to the docs, I think you need this:

  action:
    service: lock.lock
    entity_id:
    - lock.front_door
    - lock.rear_door