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
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.
# 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?
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.
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.
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.