Automation Invalid config

hey,i have encounter a problem!
i use the automation editor to create an automation,but it still shows invalid config,plz help me with this!

- id: '1548077128573'
  alias: Open light at night
  trigger:
  - platform: state
    entity_id: binary_sensor.door_window_sensor_158d0001e15654
    from: 'off'
    to: 'on'
  condition:
  - condition: sun
    after: sunset
    before: sunrise
  action:
  - service: switch.turn_on
    data:
      entity_id: switch.light1
  - delay: '00:01:00'
  - service: switch.turn_off
    data:
      entity_id: switch.light1

For one, you need to format your code for the forum. Look at the blue box at the top of the page.

Second, what SPECIFICALLY does the error message say? This is important information.

sorry about my code format
the error message just shows invalid config in the web,the log shows nothing,because i use the automation editor generate this code

It has to show something. It doesn’t just say ‘invalid’ without information about the line/character/entity

1
that is what confused me!
i upload 2 pictures

2
this picture show no issues!

But did you go into the configuration pages and check the config?

1 Like

yes i checked the configuration pages,still no error

Your code is still improperly formatted for yaml.

Is this EXACTLY as it looks in your config?

You ran the code checker on it??

this is exactly as it looks in my config.

Then this is the problem. Your yaml is incorrectly spaced

look this link: https://www.home-assistant.io/docs/automation/editor/
the code here:

# Example automations.yaml entry
- id: my_unique_id  # <-- Required for editor to work.
  alias: Hello world
  trigger:
  - platform: state 
    entity_id: sun.sun
    from: below_horizon
    to: above_horizon
  condition:
  - condition: numeric state
    entity_id: sensor.temperature
    above: 17
    below: 25
    value_template: '{{ float(state.state) + 2 }}'
  action:
  - service: light.turn_on

the demo shows the same space

That’s not the same as your config you posted.

my mistake when paste the code,
now it looks the same,right?

What about the automation section in your configuration yaml?