Configuration invalid AAARGH

Hi, I copied the following code from the examples page and pasted it in my automations.yaml file, but get constant errors when checking config. Im not sure what I need to do, some guidance would be greatly appreciated. (hope i pasted the code correctly)

Configuration invalid

Error loading /config/configuration.yaml: while parsing a flow sequence in “/config/automations.yaml”, line 1, column 1 expected ‘,’ or ‘]’, but got ‘’ in “/config/automations.yaml”, line 2, column 5

[   alias: 'coop'
    trigger:
      platform: sun
      event: sunrise
      offset: '+00:00:00'
    action:
      service: switch.turn_on
      entity_id: sonoff1
    trigger:
      platform: sun
      event: sunset
      offset: '+00:00:00'
    action:
      service: switch.turn_off
      entity_id: sonoff1]

Make sure this is under the automation: section of your configuration.yaml file or if you are using automation: !include automations.yaml then put it in your automations.yaml file.

- alias: 'coop_on'
  trigger:
    platform: sun
    event: sunrise
    offset: '+00:00:00'
  action:
    service: switch.turn_on
    entity_id: sonoff1

- alias: 'coop_off'
  trigger:
    platform: sun
    event: sunset
    offset: '+00:00:00'
  action:
    service: switch.turn_off
    entity_id: sonoff1

the leading [ is incorrect

There’s also two action and two trigger keys for the one automation. I split it into two.

Indeed you are correct. However I am like an old style compiler - stop at the first error :slight_smile:

2 Likes

Hi Tom, thanks for the help, now i get an error for the configuration.yaml file.

Configuration invalid

Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 21). Please check the docs at https://home-assistant.io/components/automation/ Invalid config for [automation]: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’]. Got None. (See /config/configuration.yaml, line 21). Please check the docs at https://home-assistant.io/components/automation/


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

homeassistant:
    latitude: -33.800837
    longitude: 18.477636
    elevation: 5
    unit_system: metric
    time_zone: Africa/johannesburg
    name: Home

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

# Text to speech
tts:
  - platform: google_translate

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

switch:
  - platform: mqtt
    name: "sonoff"
    state_topic: "stat/sonoff1/POWER"
    command_topic: "cmnd/sonoff1/power"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

Please post the contents of your automations.yaml file.

Hi Tom

the contents of my automation.yaml file is my first post above, there is nothing else in the file.

But you had to change it as a result of Tom’s post, and mine. Please post the CURRENT contents.

Replace it with this:

- alias: 'coop_on'
  trigger:
    platform: sun
    event: sunrise
    offset: '+00:00:00'
  action:
    service: switch.turn_on
    entity_id: sonoff1

- alias: 'coop_off'
  trigger:
    platform: sun
    event: sunset
    offset: '+00:00:00'
  action:
    service: switch.turn_off
    entity_id: sonoff1

Explanation:

You can only have one trigger and action per automation. So I split your automation into two. One for on and one for off.

Also the the square braces [ ] that you had around your automation was not correct.

Hi
Sorry, wasn’t thinking, the contents below.

- alias: 'coop_on'
  trigger:
    platform: sun
    event: sunrise
    offset: '+00:00:00'
  action:
    service: switch.turn_on
    entity_id: sonoff1

- alias: 'coop_off'
  trigger:
    platform: sun
    event: sunset
    offset: '+00:00:00'
  action:
    service: switch.turn_off
    entity_id: sonoff1

This is not correct:

entity_id: sonoff1

Look up the actual entity_id in the development tools states menu.

It will be something like:

switch.sonoff1

Hi Tom
Thank you, configuration now working.
Learnt a lot today.

I keep a backup file. So in case of failures I revert to the previous state, until a solution is found.