How do I convert my automations.yaml from ANSI to UTF-8?

Hello fellow Home Assistant enthusiasts,

I have a peculiar problem ever since I updated my Home Assistant Core installation on my Raspberry Pi 4 to version 2022.5.1: I can’t edit any of my automations from the UI, all I get is “Error loading automation (500)”. Additionally, my YAML config check tells me “Error loading /home/homeassistant/.homeassistant/configuration.yaml: ‘utf-8’ codec can’t decode byte 0xfc in position 3057: invalid start byte”.

After some research I found that my automations.yaml is (for some reason) ANSI-encoded and not UTF-8-encoded - I have no idea why. I did not change anything other that updating.

My problem is that I am no Linux expert and I’m trying desperately to change the encoding back to UTF-8.

The thing that confuses me the most however, is that all my current automations are working fine. I just can’t edit them or add any new ones.

Any help would be greatly appreciated! If my post is lacking any crucial information please let me know!

Greetings from Germany.

You can use the iconv tool for that, from the command line:

mv configuration.yaml configuration-backup.yaml
iconv -f iso-8859-1 -t utf-8 < configuration-backup.yaml > configuration.yaml

Then run the config check again.

1 Like

Hello robertklep,

thank you so much for your speedy reply!

I tried and indeed after running the command my config is reported as valid. However, as soon as I try to edit any automations I can’t hit save (nothing happens) and after a page refresh I keep getting the error message I got before “Error loading automation (500)”.

If I try to validate my config I get the same error as before.

And it seems that my automations.yaml is again saved as an ANSI file.

What editor are you using?

1 Like

I use nano. I access my HA core installation via SSH (PuTTY).

Make sure both nano and PuTTY are configured to use UTF-8.

1 Like

Thank you so much!

PuTTY is set to UTF-8. How do I check if nano is using UTF-8? I just run “nano automations.yaml” heh. As I am no expert, how would I go about checking the settings of nano?

10 seconds on Google:

1 Like

Thank you!

I tried it but still no luck :(. My automations.yaml continues to be encoded in ANSI.
What gives me pause is that if I edit my configuration.yaml using nano it saves as UTF-8.

What do you see when you type: nano --version

Here’s mine:
nano

1 Like

This is the output I get:
nano

Just be aware that you should convert the file to UTF-8 using iconv first before trying to edit it with nano for the first time (in other words, nano may not fix the file for you once it’s “broken”).

What does the command locale return?

1 Like

I’m not sure if I understand it correctly: I used iconv as per your instructions. After the conversion I validated my config using HA and it passed. After that I tried to edit my automations.yaml using nano. Was that wrong?

I also suspected that my automations.yaml is simply corrupt or broken but I can’t seem to replace it using File Zilla as I lack permission, apparently.

locale returns the following:locale

Yes, Nano seems to convert the file back to ISO-8859-1 when you save it.

That’s not right, they should all be en_US.UTF-8. See this page on how to set up the default locale on an RPi.

1 Like

Hm okay, but how else would I edit my configuration files?

Also, setting my locale to en_US.UTF-8 did not work for some reason, here is the error message: locale.1png

Still with nano, but you need to tell it it has to save files in the correct encoding. From what I can see, this requires setting the correct locale (but I don’t use nano, so perhaps there’s a configuration option or command line flag that you can set).

Perhaps you need to log out and back in. It’s telling you the en_US (without .UTF-8) is invalid.

1 Like

You can use notepad ++ and convert it very easily.

1 Like

I see. tried logging out and back in again, still the same error.
I’m currently generating all locales, maybe this will help.

@bschatzow : yes, I know but unfortunately I am not able to upload my converted file back to my Rasperry Pi as I seem to be lacking the proper permissions :(.

Thank you all for your help, I really do appreciate it!

I use samba and edit the file in home assistant. I don’t need to upload or download the file.

I am running Home Assistant OS which automagically exposes the configuration folder to Samba. I mount the folder in Windows then use Notepad++.

I am also using the File Editor add on in Home Assistant: (Advanced Configuration - Home Assistant). (er, you DO have advanced Configuration enabled, don’t you?) I can’t imagine the editor in Home Assistant not saving the files in a compatible encoding.

You can also use FTP (Filezilla) to view/edit the files, but that can be confusing. I only use Samba when I must.