How to use secrets.yaml in addons

So I’m just starting to evaluate Home Assistant (currently openHAB power user).

I like that you can seperate the passwords into a secrets.yaml file. However it does not seem to work for addons, only in configuration.yaml.

I have an entry in my \\192.168.40.32\config\secrets.yaml saying

  • samba_password: 1234567

and on the page http://pi-homeassistant:8123/hassio/addon/core_samba/config I try with

  • password: !secret samba_password
  • password: “!secret samba_password”
  • password: ‘!secret samba_password’

None of these work for me. Error message on save is:

Failed to save add-on configuration, Unknown secret 'samba_password' in Samba share (core_samba). Got {'workgroup': 'WORKGROUP', 'username': 'xxxxxxxxx', 'password': '!secret samba_password', 'allow_hosts': ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fe80::/10'], 'veto_files': ['._*', '.DS_Store', 'Thumbs.db', 'icon?', '.Trashes'], 'compatibility_mode': False}

I do have restarted Home Assistant (http://pi-homeassistant:8123/config/server_control > Restart) and tried with the various quotation mark variants.

I have seen users mentioning here that it works for them, so… what am I doing wrong?

3 Likes

I’ve encountered this with several add-ons when setting a friends Home Assistant.
It’s not Home Assistant that needs to be restarted, it’s the add-on. It’s like the copy of secrets.yaml that it has access to, is cached. Write anything in for now as the username and password just so you can start the add-on. Then go in to the config and replace the password with !secret samba_password and then when you hit save it will ask if you want to restart the add-on with the new configuration. It should work after that.

13 Likes

Wow, that was a fast solution, thank you! Indeed I had to first restart the addon (http://pi-homeassistant:8123/hassio/addon/core_samba/info > Restart) and then restart it again after putting in !secret … in the configuration.

1 Like

Not sure what has changed, none of the add-ons previously exhibited this weird behaviour in the past, it’s a recent change. Glad to have helped you sort it though.

Good the HA community is out there - I finally also figured how this works. Thank you!

Hello,
You can also consider this solution to edit the file in YAML directly:

Hi guys,

I Know i am a little bit late but maybe someone get this as a result of search …

You can use the way explained above:

  • set something as user & pass
  • start addon
  • edit user & pass to !secret samba_user & !secret samba_pass

But you also just can type it in correctly dont mind yaml or frontend mode just type it into quotes…

username: “!secret samba_user”
password: “!secret samba_pass”

then it throws no error message while saving config file

1 Like