What am I doing wrong? Basic Automation not working

I’m trying to build my first automation in the yaml file. It’s very basic, it just turns the outside lights on and off based on the sun.

I’m getting error codes on line 3 and 31 when I run the Check Home Assistant Config add on.

Line 3 is the line with: default_config:

Line 31 is the line with: - alias: LightsSunrise

Can someone point out what I’m doing wrong? Thanks!


ERROR:homeassistant.util.yaml.loader:while parsing a block mapping
in “/tmp/config/configuration.yaml”, line 3, column 1
expected , but found ‘-’
in “/tmp/config/configuration.yaml”, line 31, column 1
Failed config
General Errors:
- Error loading /tmp/config/configuration.yaml: while parsing a block mapping
in “/tmp/config/configuration.yaml”, line 3, column 1
expected , but found ‘-’
in “/tmp/config/configuration.yaml”, line 31, column 1


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
 http:
   base_url: https://xxxxxxxx.duckdns.org
   ssl_certificate: /ssl/fullchain.pem
   ssl_key: /ssl/privkey.pem

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

    
#Nortek/GoControl Z-Wave & Zigbee USB Adapter HUSBZB-1
zha:
  usb_path: /dev/ttyUSB1
  database_path: /config/zigbee.db

zwave:
  usb_path: /dev/ttyUSB0
    

#Front Eave Lights at sunrise/sunset
- alias: LightsSunrise
  trigger:
    platform: sun
    event: sunrise
    offset: '+00:15:00'
  action:
    - service: switch.turn_off
      entity_id: switch.front_eave_lights

- alias: LightsSunset
  trigger:
    platform: sun
    event: sunset
    offset: '-00:15:00'
  action:
    - service: switch.turn_on
      entity_id: switch.front_eave_lights
      
# Zones
zone:
  - name: School
    latitude: 38.888894
    longitude: -84.598863
    radius: 150
    icon: mdi:school

Spacing;
Drop the block http by two spaces and all should be good.

I donno what @skutter is talking bout.

Your problem is that your automations are not in an automation section.

You specify the automation section here:

automation: !include automations.yaml

Yet later down in configuration.yaml you place automations outside that file

    

#Front Eave Lights at sunrise/sunset
- alias: LightsSunrise
  trigger:
    platform: sun
    event: sunrise
    offset: '+00:15:00'
  action:
    - service: switch.turn_off
      entity_id: switch.front_eave_lights

- alias: LightsSunset
  trigger:
    platform: sun
    event: sunset
    offset: '-00:15:00'
  action:
    - service: switch.turn_on
      entity_id: switch.front_eave_lights

Those automations need to go in the automation section, which you called out to be ‘automations.yaml’. Therefore your automation.yaml file should contain those automations and ‘configuration.yaml’ should not.

Oops I sit corrected!

Bit of a lesson here - it pays to look beyond the obvious.
However, many time in diagnosing ‘complex’ issues I have seen that many miss the obvious.

Perhaps I should have read and understood deeply your config? Before offering a solution but the HTTP indentation is still too deep?

Aslo, your http section has incorrect indenting:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
 http:
   base_url: https://xxxxxxxx.duckdns.org
   ssl_certificate: /ssl/fullchain.pem
   ssl_key: /ssl/privkey.pem

should be

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
  base_url: https://xxxxxxxx.duckdns.org
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

Indentation matters alot in Yaml.

Maybe this is what you were talking about @skutter?

Yup it was!

Ok, that makes sense now. That was driving me nuts. Thank you.

So, one more question. I have some automatons I built using the “Automations” option in Config section of HA. That format looks much different than the format of the ones I’m manually typing out. Will that cause issues?

For instance, this one created using the Config option has ID, etc. My manual creations do not.

- id: '1578758011829'
  alias: Outside Garage Lights Off
  description: ''
  trigger:
  - event: sunrise
    offset: 00:21:23
    platform: sun
  condition: []
  action:
  - device_id: 786fd322df8c41b785c4d1ca8d3062f3
    domain: switch
    entity_id: switch.light_outside_garage
    type: turn_off

My Creation

  alias: 'Upstairs Heat'
  trigger:
    platform: time
    at: "12:30:00"
  action:
    - service: climate.set_temperature
      data:
        entity_id: climate.upstairs_ac_mode
        target_temp_high: 85
        target_temp_low: 66
        hvac_mode: heat_cool

That is because the GUI config creates a unique id. Perhaps you could do as I did and when creating automatons manually you could assign them a manually sequential ID in this way the automatons will be displayed whichever option you choose.

1 Like

The only time the id gets added is when you create an automation thru the editor. It uses that to define gui editable automation and so it shows up in the automation list in the editor. If you don’t plan on editing your manually created automation in the ui editor then you can leave it off. But it doesn’t hurt anything either way.

1 Like