If you ever share your Home Assistant config, paste it in a forum or put it in Git, you do not want passwords in it. !secret moves them to a separate file.
In configuration.yaml:
rest:
- resource: https://example.local/api
password: !secret rest_password
And in secrets.yaml in the same configuration folder:
rest_password: "YOUR_PASSWORD"
Home Assistant looks for secrets.yaml next to the file that uses the secret first, and then in the parent folders up to the main configuration folder. So split configs in subfolders work too.
Debugging a secret that does not load? Put logger: debug in secrets.yaml. The docs say Home Assistant then logs where it looks up secrets, without printing the actual values.
I run Home Assistant on my Unraid server, and this is the first thing I’d set up before the config grows. Add secrets.yaml to .gitignore if the folder is a Git repo.
Caveats. It is not encryption: both files are plain text on disk, readable by anyone with access to the config folder. The docs also say secrets are not supported in the UI YAML editor for automations and scripts, and that secrets used in automations are visible to administrators in the YAML view and the trace viewer. So keep them for integrations in YAML, and don’t think of it as a vault.
Further reading: Home Assistant: storing secrets
Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more