Setting up Automation

I was trying to get a simple automation set up using the ‘Your first automation’ guide, which is more or less what I want to to - set up an automation that turns on a switch a bit before sunset and then off a bit after sunrise.

I have ‘automation: !include automation.yaml’ in the bottom of my configuration file, and in that ‘automation.yaml’ file, I have:

#################################################################
## Automations
#################################################################
  - alias: Turn on driveway lights when sun sets
    trigger:
      platform: sun
      event: sunset
      offset: "-00:20:00"
    action:
      service: switch.turn_on
      entity_id: switch.leviton_unknown_type1c02_id0334_switch_4
  - alias: Turn off driveway lights when sun rises
    trigger:
      platform: sun
      event: sunrise
      offset: "00:20:00"
    action:
      service: switch.turn_off
      entity_id: switch.leviton_unknown_type1c02_id0334_switch_4

The errors I’m getting under the ‘About’ menu under ‘Developer Tools’ are:

16-09-05 
14:32:02 homeassistant.bootstrap: Error during setup of component 
automation
Traceback (most recent call last):
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/bootstrap.py",
 line 157, in _setup_component
    result = component.setup(hass, config)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/automation/__init__.py",
 line 105, in setup
    success = (_setup_automation(hass, config_block, name, config) or
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/automation/__init__.py",
 line 116, in _setup_automation
    action = _process_if(hass, config, config_block, action)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/automation/__init__.py",
 line 173, in _process_if
    checks.append(condition.from_config(if_config))
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/condition.py",
 line 37, in from_config
    return factory(config, config_validation)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/condition.py",
 line 155, in state_from_config
    config = cv.STATE_CONDITION_SCHEMA(config)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/validators.py",
 line 264, in __call__
    raise e if self.msg is None else AllInvalid(self.msg)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/validators.py",
 line 262, in __call__
    v = schema(v)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/schema_builder.py",
 line 192, in __call__
    return self._compiled([], data)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/schema_builder.py",
 line 625, in validate_callable
    return schema(data)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/schema_builder.py",
 line 192, in __call__
    return self._compiled([], data)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/schema_builder.py",
 line 486, in validate_dict
    return base_validate(path, iteritems(data), out)
  File 
"/srv/hass/hass_venv/lib/python3.4/site-packages/voluptuous/schema_builder.py",
 line 324, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ 
data['state']

Does anyone have any thoughts?

Try not indenting your aliases in your automation.yaml

Very strange… Despite the errors in the log, the automation appears to be working - the lights came on when they should have, and we’ll see if they shut off when they should (I haven’t changed anything with it yet)…

So after letting things go this AM , despite the errors that appeared after trying to set up automation, the automation worked as intended - the lights turned on before sunset and turned off after sunrise. So I changed it to remove the indents, and so far it still seems to be working as intended… If we assume that automation is working as intended, any ideas why I am getting these errors only after setting up automation?