Check: automation->trigger->0->before

Hi,

My SD card got broken and I had to reinstall my HA. When I try to copy my previous configuration I get following error:

homeassistant@raspberrypi:~$ /srv/homeassistant/homeassistant_venv/bin/hass --script check_config
Testing configuration at /home/homeassistant/.homeassistant
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up mqtt
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up introduction
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up recorder
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up http
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up history
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up api
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up websocket_api
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up frontend
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up sun
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up discovery
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up sensor
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up zwave
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up group
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up scene
2017-04-12 06:23:20 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [before] is an invalid option for [automation]. Check: automation->trigger->0->before. (See /home/homeassistant/.homeassistant/configuration.yaml, line 149). Please check the docs at https://home-assistant.io/components/automation/
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up automation
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up switch
2017-04-12 06:23:20 INFO (MainThread) [homeassistant.setup] Setting up conversation
2017-04-12 06:23:21 INFO (MainThread) [homeassistant.setup] Setting up updater
2017-04-12 06:23:21 INFO (MainThread) [homeassistant.setup] Setting up config
2017-04-12 06:23:21 INFO (MainThread) [homeassistant.setup] Setting up tts
2017-04-12 06:23:21 INFO (MainThread) [homeassistant.setup] Setting up logbook
Failed config
automation:
- action: [source /home/homeassistant/.homeassistant/configuration.yaml:155]
data: [source /home/homeassistant/.homeassistant/configuration.yaml:158]
brightness: 130
entity_id: group.living_room
service: homeassistant.turn_on
alias: Rule 1 Light on in the morning
trigger: [source /home/homeassistant/.homeassistant/configuration.yaml:151]
platform: time
after: 06:30:00
before: 07:30:00
- action: [source /home/homeassistant/.homeassistant/configuration.yaml:164]
entity_id: group.living_room
service: homeassistant.turn_off
alias: Rule 2 - Light off in the morning
trigger: [source /home/homeassistant/.homeassistant/configuration.yaml:161]
platform: time
after: 07:30:00

Here’s my config (it was working before):

automation:
  - alias: 'Rule 1 Light on in the morning'
    trigger:
      platform: time
      after: '06:30:00'
      before: '07:30:00'
    action:
      service: homeassistant.turn_on
      entity_id: group.living_room
      data:
        brightness: 130
  - alias: 'Rule 2 - Light off in the morning'
    trigger:
      platform: time
      after: '07:30:00'
    action:
      service: homeassistant.turn_off
      entity_id: group.living_room

==========================

Any ideas what’s wrong?

Cheers
Slaw

First: when posting config parts you should use codeblocks if you want us to help see errors in formatting etc. Check the links in the blue box at the top.

Second: Since the SDcard got corrupt, it’s possible that you have bytes in the config files that looks ok but isn’t. You could try delete that portion from your config, and paste it from your post and fix the indentation. That should get rid of any weird symbols.

Or, you could try remove all non-ascii signs directly from the file. Example here:

You might want to make a backup of the file first though. Actually, make a copy, run the command on the copy, and use diff to see if the files are any different afterward. Good luck.

[SOLVED] I had to add below section after ‘alias’:

     initial_state: 'off'

It looks like it’s changed recently:

“As of version 0.42 you have to set an initial state in your automations in order for Home Assistant to restore them upon restart. text - alias: Automation Name initial_state: True trigger: …”

Thanks for the hints chrio!

Glad it worked out for you. I haven’t noticed the change you mentioned thought. I wonder what they mean about the part ‘restore them upon restart’… is that when you use the service automation.reload?

I don’t use an initial_state for most of my automations, only the ones I want off by default and activate later on.

which version do you use?