secrets.yaml – what is it for?

Home Assistant has a secrets.yaml file in the root folder of the configuration. The purpose of this file is to store usernames and passwords instead of having these set directly in the different YAML files. You can also store other things in the file, like IP-addresses, tokens etc. In your other YAML files you can then reference to the secrets listed in secrets.yaml.

You basically only need this if you share your Home Assistant configuration with others, or if you want to backup your configuration towards GitHub or other providers.

You can read about secrets.yaml in the official documentation here.

secrets.yaml is quite easy to use, so I would deep dive into an explanation, so you get the short version.

In my configuration.yaml I have multiple places where I write !secret followed by a name. Consider the “name” as a variabelname. So if I for example write !secret ihc_username, Home Assistant then expect that “ihc_username” is defined with a value in my secrets.yaml.

Look at the example below:

configuration.yaml:

secrets.yaml:

This makes it easy for me to share code on my blog without worrying if I forgot to remove a username, password or token. Furthermore I can without issues backup my configuration to GitHub and also make it a public repository on GitHub for everybody to look into.

Super cool and extremely easy to use.

Leave a Reply

Your email address will not be published.