Automation not working with a for action

I am having an issue with a automation to turn off the lights after 10 min

I get this error Invalid config for [automation]: required key not provided @ data[‘action’]. Got None
required key not provided @ data[‘trigger’]. Got None. (See /config/configuration.yaml, line 70). Please check the docs at https://home-assistant.io/components/automation/

With this configuration

- id: '1529481576101'
- alias: Turn off livingroom light 10 minutes after last movement
  trigger:
    entity_id: binary_sensor.fibaro_system_fgms001zw5_motion_sensor_sensor  
    from: 'on'  
    platform: state
    to: 'off'
    for:
      minutes: 10
  condition: []
  action:
  - alias: ''
    data:
      entity_id: light.vardagsrum
    service: light.turn_off

What am i doing wrong

Try dropping the from:

Here is how I format mine for a similar automation. (Second one, couldn’t pull the direct link while on my phone)

Remove the hyphen at the start of line 2.

Remove the whole line

  - alias: ' ' 

4 from the bottom.

Hi,

It seeems like the for: is the problem when i remove this i get a valid configuration and with it in i get

Error loading /config/configuration.yaml: while parsing a block mapping
in “/config/automations.yaml”, line 32, column 5
expected , but found ‘’
in “/config/automations.yaml”, line 35, column 7

  • id: ‘1529472764772’
    alias: Turn off livingroom light 10 minutes after last movement
    trigger:
    • entity_id: light.vardagsrum
      platform: state
      to: ‘on’
      for:
      minutes: 5
      condition:
      action:
    • data:
      entity_id: light.vardagsrum
      service: light.turn_off

Can you post your code using the instructions in the blue bar at the top of the forum?

It’s really hard to check the code without the formatting retained.

Also, please identify which lines are 32 and 35.

Try this. Make sure you always have the same spacing for each level in yaml. Also, to me the alias does not fit your code. looks like you are always turning the light off after 5 minutes of it being on. So I adjusted the code based on what I think you want it to do. I added the from on to off in because your alias claims that you want to shut the light off after movement is gone for 5 minutes. Movement = on, off = no movement. So with that, you should be looking for the on to off transition, not off to on.

- id: '1529472764772'
  alias: Turn off livingroom light 5 minutes after last movement
  trigger:
    - platform: state
      entity_id: binary_sensor.fibaro_system_fgms001zw5_motion_sensor_sensor
      from: 'on'
      to: 'off'
      for:
        minutes: 5
  action:
    - service: light.turn_off    
      data:
        entity_id: light.vardagsrum