HA now failing to start

I was editing my ‘Automation.yaml’ file to change my morning turn off light event from this:

- 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_0

to this

- alias: Turn off Outside group when sun rises
  trigger:
    platform: sun
    event: sunrise
    offset: "00:20:00"
  action:
    service: homeassistant.turn_off
    entity_id: group.outside

After making the change and uploading the file, HASS failed to start when I restarted the service. I tried various permutations within the section until I put it back exactly the way it was and after that restart, still not starting.

When I looked in the home-assistant.log file, I found one entry (each time I restart HASS, the line stays the same except for the timestamp):
17-01-25 12:36:58 homeassistant.util.yaml: while parsing a block mapping
in “/home/hass/.homeassistant/configuration.yaml”, line 3, column 3
expected , but found ‘’
in “/home/hass/.homeassistant/configuration.yaml”, line 16, column 9

I didn’t touch my configuration.yaml at all, so I have no idea why it worked before and now decided not to, but this is my sanitized configuration.yaml:

homeassistant:
# Name of the location where Home Assistant is running
  name: Home
# Location required to calculate the time the sun rises and sets
  latitude: XX.XX
  longitude: XX.XX
  # Impacts weather/sunrise data
  elevation: X
  # metric for Metric, imperial for Imperial
  unit_system: imperial
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: America/Chicago
  customize: !include customize.yaml

 #Show links to resources in log air('blib', 'arch');
        if ($source eq $blib_lib and
            exists $from_to{$blib_arch} and
            directory_not_empty($blib_arch)
        ){
            $targetroot = install_rooted_dir($from_to{$blib_arch});
            print "Files found in $blib_arch: installing files in $blib_lib into architecture dependent library tree\n";
        }

        next unless -d $source;
        _chdir($source);
        # 5.5.3's File::Find missing no_chdir option
        # XXX OS-SPECIFIC
        # File::Find seems to always be Unixy except on MacPerl :(
        my $current_directory= $Is_MacPerl ? $Curdir : '.';
        find(sub {
            my ($mode,$size,$atime,$mtime) = (stat)[2,7,8,9];

            return if !-f _;
            my $origfile = $_;

            return if $origfile eq ".exists";
            my $targetdir  = File::Spec->catdir($targetroot, $File::Find::dir);
            my $targetfile = File::Spec->catfile($targetdir, $origfile);
            my $sourcedir  = File::Spec->catdir($source, $File::Find::dir);
            my $sourcefile = File::Spec->catfile($sourcedir, $origfile);

            for my $pat (@$skip) {
                if ( $sourcefile=~/$pat/ ) {          
         

Line 16 is this. column 9 is the ‘i’ in ‘if’:
if ($source eq $blib_lib and

I do not know what the ’ #Show links to resources in log air(‘blib’, ‘arch’);’ section is, I assume it’s something that HASS put in by default and it seems to be related to the log file as when I comment the entire section out and restart, the log file does not appear to be written to upon restart.

Any ideas why my HASS seems to have suddenly died?

Edit: I looked in my OZW_Log.txt and found this at the end. Not sure if it may be related:

2017-01-25 12:10:40.845 Info, mgr, Driver for controller /dev/ttyS0 removed
2017-01-25 12:10:41.856 Error, mgr, Manager::GetDriver failed - Home ID 0xc0c97f16 is unknown
2017-01-25 12:10:41.856 Warning, Exception: Manager.cpp:373 - 100 - Invalid HomeId passed to GetDriver
2017-01-25 12:10:41.856 Info, mgr, GetSendQueueCount() failed - _homeId -1060536554 not found

Again, prior to it failing, the ONLY thing I modified was my automation.yaml file.

It looks like you may have accidentally pasted some code in while you were editing.

Remove:

#Show links to resources in log air('blib', 'arch');
        if ($source eq $blib_lib and
            exists $from_to{$blib_arch} and
            directory_not_empty($blib_arch)
        ){
            $targetroot = install_rooted_dir($from_to{$blib_arch});
            print "Files found in $blib_arch: installing files in $blib_lib into architecture dependent library tree\n";
        }
        next unless -d $source;
    _chdir($source);
    # 5.5.3's File::Find missing no_chdir option
    # XXX OS-SPECIFIC
    # File::Find seems to always be Unixy except on MacPerl :(
    my $current_directory= $Is_MacPerl ? $Curdir : '.';
    find(sub {
        my ($mode,$size,$atime,$mtime) = (stat)[2,7,8,9];

        return if !-f _;
        my $origfile = $_;

        return if $origfile eq ".exists";
        my $targetdir  = File::Spec->catdir($targetroot, $File::Find::dir);
        my $targetfile = File::Spec->catfile($targetdir, $origfile);
        my $sourcedir  = File::Spec->catdir($source, $File::Find::dir);
        my $sourcefile = File::Spec->catfile($sourcedir, $origfile);

        for my $pat (@$skip) {
            if ( $sourcefile=~/$pat/ ) {

and restart. Is that your whole configuration.yaml? It looks like everything from the customize line down may have been replaced by that accidental paste.

That should be my entire config. Everything is broken out into Automation,yaml, customize,yaml, groups.yaml, sensors.yaml and scenes.yaml. The thing is I have never seen that code before and it was there when it opened in Notepad++ after right clicking it in Filezilla and clicking ‘view/edit’. No idea where it came from but there is zero chance of me having pasted it in the file. A URL or random text from something I had been working on would be possible, but that code, not a chance.

Have you tried to remove it?
It should not be part of the config file.

I originally tried commenting it out with no change, and after rpitera’s suggestion cut it out and put it in a separate Notepad++ tab in case I need it again, but still no change (although commenting it out SHOULD have the same effect as removing). With it removed or commented out, HA is still failing to start, but the homeassistant.log file is not being updated.

Have you tried hass --script check_config ?
And read this https://home-assistant.io/getting-started/troubleshooting-configuration/

I think you’re missing a fair bit of your configuration.yaml there. You mention having includes, but I don’t see them anywhere. All I see is the one for customize.

Any chance you have a backup?

Just one thing I spotted that differs between my automation.yaml and yours are dashes before platform & service. Worth a go? Perhaps their absence is causing a syntax ‘hairball’ for want of a better term?

- alias: "Kitchen Lamp Off at Sunrise"
  trigger:
    - platform: sun
      event: sunrise
  action:
    - service: homeassistant.turn_off
      entity_id: switch.wemo_switch_grey

Without the necessary includes for his automations, changing this won’t matter at this point.

Need to address the missing includes and the rest of the configs first.

I had added the following to the config following removing the mystery code:

automation: !include automation.yaml
group: !include groups.yaml
sensor: !include sensors.yaml

Upon restart, it errored on the ‘automation’ line. Commented that out and it now errored on the ‘group’ line. Commented that out and it then errored on the ‘sensor’ line.

I have a backup I made of the SD card in December before upgrading from 0.27.2 to the version I’m on now (3.22, I think), I just need to figure out how to open the img file inside it. 7-zip doesn’t recognize the img file made by Win32DiskImager.

Could you post your config and the error message?

17-01-25 13:58:12 homeassistant.bootstrap: Invalid config for [homeassistant]: [automation] is an invalid option for [homeassistant]. Check: homeassistant->automation. (See /home/hass/.homeassistant/configuration.yaml:2). 

[code]
homeassistant:

Name of the location where Home Assistant is running

name: Home

Location required to calculate the time the sun rises and sets

latitude: XX.XX
longitude: XX.XX

Impacts weather/sunrise data

elevation: XX

metric for Metric, imperial for Imperial

unit_system: imperial

Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

time_zone: America/Chicago
customize: !include customize.yaml
automation: !include automation.yaml
group: !include groups.yaml
sensor: !include sensors.yaml[/code]

automation should not be under “homassistant”
So remove the spaces in front of automation, group and sensor

2 Likes

I got it back up. I was able to mount the image from December and pull the files from it (which were largely unchanged except for the ones referencing zwave devices since the IDs changed)

You guys were right - a lot was missing. But that’s VERY bizarre. I updated to 34.3 back in December (I can now see the version since it started) and all I changed then was the data related to the Z-Wave IDs, since they changed between 27.x and 34.x. Since that point, I changed nothing at all until this morning, when I opened the ‘automation.yaml’ to change the portion that I posted in my OP. Saved that and restarted the homeassistant service and it failed to start. As I indicated, I figured I did something wrong and that portion of the automation config was making it very unhappy, so I returned it to the original values, at which point it STILL wasn’t starting. When I found the reference to the configuration.yaml file in the homeassistant.log file, that was the first point at which I touched that file.

This is my entire (complete) configuration.yaml:

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: XX.XX
  longitude: XX.XX
  # Impacts weather/sunrise data
  elevation: XX
  # metric for Metric, imperial for Imperial
  unit_system: imperial
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: America/Chicago
  customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

http:
  # Uncomment this to add a password (recommended!)
  # api_password: PASSWORD

# Checks for available updates
updater:

# Discover some devices automatically
discovery:

# Allows you to issue voice commands from the frontend in enabled browsers
conversation:

# Enables support for tracking state changes over time.
history:

# View all events in a logbook
logbook:

# Track the sun
sun:

# Weather Prediction
#sensor:
#  platform: yr

mqtt:
  broker: 127.0.0.1
  port: 1883
  client_id: home-assistant-1
  username: XXX
  password: XXX
  
zwave:
 usb_path: /dev/ttyS0
 config_path: /srv/hass/hass_venv/lib/python3.4/site-packages/libopenzwave-0.3.1-py3.4-linux-armv7l.egg/config
 polling_interval: 60000
# polling_intensity: 1

input_boolean:
 vacation_mode:
   name: Vacation Mode
   initial: off
   icon: mdi:security-home
#################################################################
## Includes
#################################################################

automation: !include automation.yaml
group: !include groups.yaml
scene: !include scenes.yaml
sensor: !include sensors.yaml

And before you ask about not having a password set, this is not accessible from outside my network unless I connect a VPN and access it by it’s private address. So unless there’s there’s some kind of back door that allows it to be accessed from the internet without opening any ports on the firewall, there is no way for anyone to access it unless they are physically connected to my network or VPNed to my firewall.

Any ideas how in the world it got changed?

Thanks for the input.