Newbie needing YAML help in automations

I know this must be a spacing issue or something but I have tried to add a few of the example automation from looking at the docs and at some point I got something wrong now I can’t get any of them to work.

can someone help me out with this error? I have commented out all the new automations I am trying to put in and can’t even get the first one to work at this point.

Invalid config for [automation]: [state] is an invalid option for [automation]. Check: automation->trigger->0->state. (See /config/automations.yaml, line 195). Please check the docs at https://home-assistant.io/components/automation/

here is my automation file:

#####alarm beep when door opened or closed####
- alias: DoorChime
  initial_state: true
  trigger:
    - entity_id: binary_sensor.garage_door
      platform: state
    - entity_id: binary_sensor.front_door
      platform: state
    - entity_id: binary_sensor.1st_floor_windows
      platform: state
    - entity_id: binary_sensor.basement_door
      platform: state
    - entity_id: binary_sensor.basement_garage_door
      platform: state
    - entity_id: binary_sensor.basement_windows
      platform: state
    - entity_id: binary_sensor.breakfast_door
      platform: state
    - entity_id: binary_sensor.sliding_glass_door
      platform: state
    - entity_id: binary_sensor.sun_room_glass
      platform: state
  condition: []
  action:
    service: switch.turn_on    
    data:
      entity_id: switch.door_chime_2
#    - service: switch.turn_on    
#      data:
#        entity_id: switch.door_chime_2
#    - service: notify.simple    
#      data_template:
#        message : " {{ trigger.from_state.attributes.friendly_name }} has been Opened " 
#        title: "test alert"  

####sound alarm siren when armed home or away####
- alias: trigger alarm while armed home or away
  initial_state: true
  trigger: 
    - platform: state
      entity_id: binary_sensor.garage_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.front_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.1st_floor_window
      to: 'on'
    - platform: state
      entity_id: binary_sensor.basement_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.basement_garage_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.basement_windows
      to: 'on'
    - platform: state
      entity_id: binary_sensor.breakfast_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.sliding_glass_door
      to: 'on'
    - platform: state
      entity_id: binary_sensor.sun_room_glass
      to: 'on'
  condition:
    condition: or
    conditions: 
      - condition: state
        entity_id: alarm_control_panel.house
        state: armed_away
      - condition: state
        entity_id: alarm_control_panel.house
        state: armed_home
  action:
    service: alarm_control_panel.alarm_trigger
    entity_id: alarm_control_panel.house

#turn on siren when triggered
- alias: Alarm Triggered
  initial_state: true
  trigger: 
    - platform: state
      entity_id: alarm_control_panel.house
      to: 'triggered'
  action: 
    - service: switch.turn_on
      entity_id: switch.siren_2
    - service: notify.simple
      data:
        message: "ALARM TRIGGERED"
        title: "ALARM TRIGGERED"
    
- alias: Alarm Triggered
  trigger: 
    - platform: state
      entity_id: alarm_control_panel.house
      to: 'triggered'
  action: 
    - service: switch.turn_on
      entity_id: switch.siren_2
    - service: notify.simple
      data:
        message: "ALARM TRIGGERED"
        title: "ALARM TRIGGERED"
#    - delay: '00:05:00'
#    - service: switch.turn_off
#      entity_id: switch.siren

# Turn off siren when disarmed.
- alias: alarm_auto_noise_off
  initial_state: true
#  initial_state: true
  trigger:
    - platform: state
      entity_id: alarm_control_panel.house
      from: 'triggered'
      to: 'armed_home'
    - platform: state
      entity_id: alarm_control_panel.house
      from: 'triggered'
      to: 'armed_away'
    - platform: state
      entity_id: alarm_control_panel.house
      from: 'triggered'
      to: 'disarmed'
  action:
    - service: switch.turn_off
      entity_id: switch.siren_2

- alias: Alarm Disarmed
  trigger: 
    - platform: state
      entity_id: alarm_control_panel.house
      from: 'triggered'
      to: 'disarmed'
  action: 
    service: switch.turn_off
    entity_id: switch.siren_2

- alias: DoorOpen
  initial_state: true
  trigger:
    - entity_id: binary_sensor.garage_door
      platform: state
      to: 'on'
    - entity_id: binary_sensor.front_door
      platform: state
      to: 'on'
    - entity_id: binary_sensor.basement_door
      platform: state
      to: 'on'
    - entity_id: binary_sensor.basement_garage_door
      platform: state
      to: 'on'
    - entity_id: binary_sensor.breakfast_door
      platform: state
      to: 'on'
    - entity_id: binary_sensor.sliding_glass_door
      platform: state
      to: 'on'
  condition: []
  action:
    service: notify.simple    
    data_template:
      message : " {{ trigger.from_state.attributes.friendly_name }} has been Opened " 
      title: "Door Alert"
      
- alias: Wicky Home
  initial_state: true
  trigger:
    - entity_id:  person.wicky
      platform: state
      from: 'not_home'
      to: 'home'
  action:
    service: notify.simple
    data:
      message: "Wicky home"
      title: "Wicky"

- alias: Wicky left
  initial_state: true
  trigger:
    - entity_id:  person.wicky
      platform: state
      from: 'home'
      to: 'not_home'
  action:
    service: notify.simple
    data:
      message: "Wicky is not home"
      title: "Wicky"
      
- alias: Notify if any doors left open for 10 minutes ****THIS IS LINE 195***
  initial_state: true
  trigger:
    - entity_id:
        - binary_sensor.garage_door
        - binary_sensor.front_door
        - binary_sensor.1st_floor_window
        - binary_sensor.basement_door
        - binary_sensor.basement_garage_door
        - binary_sensor.basement_windows
        - binary_sensor.breakfast_door
        - binary_sensor.sliding_glass_door
        - binary_sensor.sun_room_glass
      platform: state
      state: 'on'
      for:
        minutes: 1
  action:
    service: notify.simple
    data_template:
      message: "The {{ trigger.to_state.attributes.friendly_name }} was left open"
      title: "Something's still open"
        
###send alert for new version of HA###
#- alias: Update notifications
#  intial_state: true
#  trigger:
#    - platform: state
#      entity_id: updater.updater
#  action:
#    service: notify.simple
#    data_template: 
#      title: 'New Home Assistant Release'
#     message: "Home Assistant  {{ states.updater.updater.state }}  is now available."

        
####send notification if doors left open after Dark####
#- alias: Doors/windows open after Dark
#  initial_state: true
#  trigger:
#    platform: state
#    entity_id:
#      - binary_sensor.garage_door
#      - binary_sensor.front_door
#      - binary_sensor.1st_floor_window
#      - binary_sensor.basement_door
#      - binary_sensor.basement_garage_door
#      - binary_sensor.basement_windows
#      - binary_sensor.breakfast_door
#      - binary_sensor.sliding_glass_door
#      - binary_sensor.sun_room_glass
#    state: 'on'
#  condition:
#    condition: and
#    conditions: 
#      - condition: state
#        entity_id: sun.sun
#        state: below_horizon
#      - condition: state
#        entity_id: 
#          - binary_sensor.garage_door
#          - binary_sensor.front_door
#          - binary_sensor.1st_floor_window
#          - binary_sensor.basement_door
#          - binary_sensor.basement_garage_door
#          - binary_sensor.basement_windows
#          - binary_sensor.breakfast_door
#          - binary_sensor.sliding_glass_door
#          - binary_sensor.sun_room_glass
#        state: 'on'
#  action:
#    service: notify.simple    
#    data_template:
#      message : " {{ trigger.from_state.attributes.friendly_name }} has been left Open after dark " 
#      title: "Don't forget to close doors"

the last two automations I am working on as well. but I have commented them out to try to troublshoot line 195

I tried to highlight line 195 in the automation.yaml file. I have it surrounded by ***

- alias: Notify if any doors left open for 10 minutes ****THIS IS LINE 195***

I can’t which line you are referring to… which automation is it under?

EDIT: found it

all three of the bottom automations are not working. I think it’s actually something I messed up in the 4th from the bottom automation but Ican’t figure it out.

I know the automatino editor muddles things up and to some extent HA doesn’t care, but the way the platform is meant to be written is like this example:

trigger:
  - platform: state
    entity_id: binary_sensor.passage_multi_sensor_sensor
    to: 'off'
    for:
      minutes: 45

where the ‘state’ part is what has the ‘-’ before it, not the entity_id. This is how the docs show it but not what the editor creates and I don’t think it should matter. I don’t see other issues but I’m sure someone will…

1 Like

[quote=“GaJeep94YJ, post:1, topic:115502”]

  • alias: Notify if any doors left open for 10 minutes *THIS IS LINE 195 initial_state: true trigger: - entity_id: - binary_sensor.garage_door - binary_sensor.front_door - binary_sensor.1st_floor_window - binary_sensor.basement_door - binary_sensor.basement_garage_door - binary_sensor.basement_windows - binary_sensor.breakfast_door - binary_sensor.sliding_glass_door - binary_sensor.sun_room_glass platform: state state: ‘on’ for: minutes: 1

I’m pretty sure it’s because of the line in that trigger

state: 'on'

can only be used in conditions not triggers, triggers should just have something like

from: 'off'
to: 'on'

also in the first automations you do not have to have platform state for each entity, you can just list use

- alias: DoorChime
  initial_state: true
  trigger:
  - platform: state
    entity_id:
     - entity_id: binary_sensor.garage_door
     - entity_id: binary_sensor.front_door
     - entity_id: binary_sensor.1st_floor_windows
     - entity_id: binary_sensor.basement_door
     - entity_id: binary_sensor.basement_garage_door
     - entity_id: binary_sensor.basement_windows
     - entity_id: binary_sensor.breakfast_door
     - entity_id: binary_sensor.sliding_glass_door
     - entity_id: binary_sensor.sun_room_glass

Also… I know there is a way for it to trigger on ANY state change… I just can’t remember if it’s just by having platform -state like you have without a from on to off or if there is another method, I really don’t use that so maybe someone else can chime in.

1 Like

Yep, thats it!

that was it! I changed the platform to the top and changed from to to and it worked!

- alias: Notify if any doors left open for 10 minutes
  initial_state: true
  trigger:
    - platform: state
      entity_id:
        - binary_sensor.garage_door
        - binary_sensor.front_door
        - binary_sensor.1st_floor_window
        - binary_sensor.basement_door
        - binary_sensor.basement_garage_door
        - binary_sensor.basement_windows
        - binary_sensor.breakfast_door
        - binary_sensor.sliding_glass_door
        - binary_sensor.sun_room_glass
      to: 'on'
      for:
        minutes: 10
  action:
    service: notify.simple
    data_template:
      message: "The {{ trigger.to_state.attributes.friendly_name }} was left open"
      title: "Something's still open"

thanks for the help you guys!

don’t go anywhere, I am going to try to add back the bottom ones I ahve commented out and see if I can get them to work… :smiley:

Cool glad it helped
Also… I know there is a way for it to trigger on ANY state change… I just can’t remember if it’s just by having platform -state like you have without a from on to off or if there is another method, I really don’t use that so maybe someone else can chime in.

so I uncomented out the lines for the updater notifcations and got the same type error, but I think I have it the right order?

###send alert for new version of HA###
- alias: Update notifications
  intial_state: true
  trigger:
    - platform: state
      entity_id: updater.updater
  action:
    service: notify.simple
    data_template: 
      title: 'New Home Assistant Release'
      message: "Home Assistant  {{ states.updater.updater.state }}  is now available."

the error:
nvalid config for [automation]: [intial_state] is an invalid option for [automation]. Check: automation->intial_state. (See /config/automations.yaml, line 219). Please check the docs at https://home-assistant.io/components/automation/

typo: initial

correct, it can just be:

trigger:
  platform: state
  entity_id: blah

which will trigger on that entity changing state, no matter what to or from

dang… it’s getting late here…

now going to try to fix the last one. the goal was to send me an alert if any doors were left open after dark.

Also It’s possible that “service” line under action needs a hyphen . (Sorry on mobile now hard to check formatting)

I think I will start a new thread for this last automation idea. I don’t think my logic is working anyway…

thanks again for the help.

Thats an easy one, just create an automation with the trigger being ‘sunset’ and then have conditions ‘your sensors’, ‘on’ and finally the action being the notification.