Unable to read file with ° symbol if not in configuration.yaml

I recently split up my configuration.yaml file into many sub folders and they all worked fine except for my sensors.yaml folder. All these modules were a complete copy and paste from my working configuration so it was a little confusing as to why it’s all of a sudden throwing an error.

Feb 09 16:22:49 raspberrypi hass[31709]: ERROR:homeassistant.util.yaml:Unable to read file /home/hass/.homeassistant/includes/sensor.yaml: 'utf-8' codec can't decode byte 0xb0 in position 1191: invalid start byte

I eventually figured out that it was the ° symbol in the below that caused the error, even when it was commented out…

File -> configuration.yaml

sensor: !include includes/sensor.yaml

File -> includes/sensor.yaml

  # - platform: mqtt
    # state_topic: 'home/wemos/01'
    # name: 'Temperature'
    # unit_of_measurement: '°C'

Why does it do this?

Hmm, works fine here: https://github.com/Danielhiversen/home-assistant_config/blob/master/sensors.yaml#L42

I have no idea, but I’ve tried recreating the file, putting it in double quotes (like your example), commenting the line out and it throws the same error every time…

As soon as i remove it or copy the exact same text back into the configuration.yaml it works fine again.

The reason is that you didn’t save the file with an UTF-8 encoding, so python can’t decode the character.
You can use iconv to change the encoding.


EDIT: as a warning: do not try to redirect the output of iconv to the file it reads from.
That will most certainly remove all the contents from the file. Speaking from experience…


Right you are, thank you!

Couldn’t figure out how to use iconv, didn’t accept the ansi:
iconv -f ansi -t utf-8 sensor1.yaml > sensor.yaml
But I’m using Windows to make the changes and found that I can make notepad ++ do this automatically in the future with this:

Or even crappy old notepad can do it:

It’s probably a variant of iso8859, not ansi.
With some luck, “file sensor1.yaml” on the linux side will tell you the encoding.


I know this problem well; in fact when I had it HA would just die without even telling you which file had the problem.

The PR resulting from this properly identified the offending file but since then I moved over to SublimeText as an editor for just that purpose.

Ahh the journey, good to know your issue helped my diagnoses easier, cheers!

1 Like

Thanks for the posts… Made my life easier while playing with sensors!