Always need a second save in the secrets file to pass config check?

whenever I add something in the config, that needs a new entry in the secrets.yaml file, (and after saving both the new configuration entry And the relevant section in secrets.yaml) I need to re-save that for it to be able to pass the config check.

No need to change anything, a mere re-save does the trick and allows for the HA system to restart.
before, there’s a config error in the notification tray.

is this to be expected?

I’ve forgotten what flavour of HA you run but that is not what I experience with HA OS when using VSCode via SAMBA or the VSCode addon. One save of both files is sufficient.

1 Like

I’ve not experienced this either, and also am not sure that most editors allow the saving of a file that is unchanged do they? :thinking:

I am using Home Assistant OS, on a Rpi4.

using a fine text editor so that wont be it, since all changes are always real time and loaded immediately (eg in Lovelace cards)

Its only the secrets file causing this.

and about saving without changing. well, maybe I lied a bit, I do change the position of the cursor, or enter a space and a backspace somewhere …

hitting command-s

but you’re right, opening and not doing anything shows this (greyed Save) in the file menu:

Schermafbeelding 2020-12-01 om 21.19.48

So how are you saving it the second time?

Every time you edit secrets you have to restart homeassistant, as the secrets file is loaded, and therefore substituted into the locations in your configuration yaml, on startup. Unless something has changed and I didn’t notice.

Well, as explained above. Saving it a second time makes it pass the config checker.

Before that, I can’t restart HA from the configuration menu.
(Could using the shh cli, but I don’t want to, because it might not startup because of a config error… learned that the hard way.

Catch22.

Then it’s impossible to to do this…

yeah, as said, repositioning the cursor makes saving again possible.

so theoretically we would need to

  • first save the edited secrets file,
  • restart HA to have it load the new secret, and then
  • change the config needing the secret, which can now be referenced.

seems I have found myself a shortcut, without restart. Do this:

  • add secret_text: This is secret to the secrets file.
  • add:
input_text:
  secret_text:
    name: Secret text
    initial: !secret secret_text

to the config.

  • check config and it will fail complaining the secret doesn’t exist
  • reposition cursor, and save secrets.yaml.
  • check config and it will check ok
  • reload input_text

et voila:

without any restart :wink: