Automation.yaml nightmare [Solved]

automation.yaml nightmare

Still new to Home Assistant
Trying to make my first automation.yaml.
Unfortunately, it is not as expected.

automation:
  trigger:
    platform: time
    seconds: 10
  action:
    service: switch.turn_on
    entity_id: switch.light_in_the_office

Triggers the following error log:

2017-06-08 18:08:07 
ERROR (MainThread) [homeassistant.config] 
Invalid config for [automation]: [automation] is an invalid option for [automation]. 
Check: automation->automation. (See /home/homeassistant/.homeassistant/configuration.yaml, line 55). 
Please check the docs at https://home-assistant.io/components/automation/

Line 55 is the line before Include automationyaml in configuration.yaml:

Have followed the examples from


But nevertheless it did not succeed.
Hope a sharp super user can figure out my mistakes and make me happy.

You need some "-"s…

 - alias: 'Refresh Owntracks'
   trigger:
     - platform: time
       minutes: '/15'
       seconds: 0
   action:
     - service: script.kick_owntracks

and remove automation: as it’s already specified in the config.yaml and add an alias:

do you have a seperate file named “automations.yaml” located in the same directory as the configuration.yaml file?

In the automations.yaml file do not include the “automation:” line. It is not needed and will break the config. Start with trigger.

Perhaps one step closer.

Automation: Removed

The new code:

- alias: 'Switch on automaticaly'
  trigger:
    - platform: time
      seconds: 10
 
    action:
      - service: switch.turn_on
        entity.id: switch.light_in_the_office

The new error log:

The following errors have been logged this session:

2017-06-08 18:46:16 ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 3, column 5
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 6, column 5

2017-06-08 18:46:16 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 3, column 5
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 6, column 5

Still incomprehensible talk to me :frowning:

action should be under the t of trigger

and i think seconds: 10 should be seconds: ‘/10’ if you want to turn on the lamp every 10 seconds

yaml is very dependent on the spacing and it won’t work if it isn’t right :stuck_out_tongue:

It helped, now the lamp turns on after 6 seconds.
But automation 2 does not work?

- alias: 'Switch on automatically'
  trigger:
    - platform: time
      seconds: '/6'
  action:
    - service: switch.turn_on
      entity_id: switch.light_in_the_office
      
automation 2:
  trigger:
    - platform: time
      seconds: '/12'
  action:
    - service: switch.turn_off
      entity_id: switch.light_in_the_office

Error log

The following errors have been logged this session:

2017-06-08 20:27:21 ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 1
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 9, column 1

2017-06-08 20:27:21 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 1
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 9, column 1

Only Automation and not Automation 2 is displayet in frontend:

Format automation 2 the same as your first automation.

Start with the alais, then trigger.

- alias: 'Switch on automatically'
  trigger:
    - platform: time
      seconds: '/6'
  action:
    - service: switch.turn_on
      entity_id: switch.light_in_the_office
      
automation 2:
- alias: 'Switch off automatically'
  trigger:
    - platform: time
      seconds: '/12'
  action:
    - service: switch.turn_off
      entity_id: switch.light_in_the_office


The following errors have been logged this session:

2017-06-08 20:45:37 ERROR (Thread-1) [homeassistant.util.yaml] while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 1
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 9, column 1
2017-06-08 20:45:37 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block collection
  in "/home/homeassistant/.homeassistant/automations.yaml", line 1, column 1
expected <block end>, but found '?'
  in "/home/homeassistant/.homeassistant/automations.yaml", line 9, column 1

remove “automation 2”

edit: perhaps an example from my config will help

  - alias: 'Turn Off Outside Lights'
    trigger:
      platform: sun
      event: sunrise
    action:
      - service: homeassistant.turn_off
        entity_id: group.outside_lights
      - delay: 0:01
      - service: homeassistant.turn_off
        entity_id: group.outside_lights
      

  - alias: 'Turn On Outside Lights'
    trigger:
      platform: sun
      event: sunset
      offset: '-00:15:00'
    action:
      - service: homeassistant.turn_on
        entity_id: group.outside_lights
      - delay: 0:01
      - service: homeassistant.turn_on
        entity_id: group.outside_lights
1 Like

You can’t have automation 2: as automation has been specified in the config.yaml, please peruse the docs

Thank you very much
So drive my light show :slight_smile:

I was inspired by this example

TIME TRIGGER

Time can be triggered in many ways. The most common is to specify at and trigger at a specific point in time each day. Alternatively, you can also match if the hour, minute or second of the current time has a specific value. You can prefix the value with a / to match whenever the value is divisible by that number. You cannot use at together with hour, minute or second.

automation:
  trigger:
    platform: time
    # Matches every hour at 5 minutes past whole
    minutes: 5
    seconds: 00

automation 2:
  trigger:
    platform: time
    # When 'at' is used, you cannot also match on hour, minute, seconds.
    # Military time format.
    at: '15:32:00'

automation 3:
  trigger:
    platform: time
    # You can also match on interval. This will match every 5 minutes
    minutes: '/5'
    seconds: 00

:smiley: + ten chars :stuck_out_tongue:

1 Like