Help with secrets.yaml esphome

Just realize that I should add secrets.YAML and base on information the way to do it is adding esphome/secrets.YAML with this <<: !include ../secrets.yaml

I reboot my HA and the ESPHome Addon, on my ESPHome I already see secrets editor,
however, when I add !secret on my ESPHome device I got a red X on the first line saying it did not find secrets.YAML or error.

So I did not dare to go through worrying my device will become disabled.

Does anyone know what I did wrong?

Running HA 2021.7.4 with supervised + ESPHome AddOn. The ESPHome Directory is inside the config directory.

That’s not the issue. He was referring to this:

https://esphome.io/guides/faq.html#how-do-i-use-my-home-assistant-secrets-yaml

Others have problems with this too. See https://community.home-assistant.io/t/accessing-home-assistant-copy-of-secrets-yaml-from-esphome/179053

Basically the advice in the ESPHome documents on using the Home Assistant secrets file don’t seem to work.

Ah yes, misunderstood the question. Deleting my post.

I got that problem and I know how to used !secret

@tom_l spot on any advice on how to solve the issue?

no… I’m just saying that I already create secrets.yaml inside the yaml on esphome directory which confirms on that file appears on esphome apps.

any solutions? Its say he need to modified the ESPHome code? Which files?

No idea I use two secret files.

put a “secrets.yaml” file in /<ha_config_dir>/esphome
I’ve added a single line to that file like as follows:

wifi_pw: Password123

Then in your esphome yaml for the device
it refers to the above like this:

wifi:
  ssid: "MySSID"
  password: !secret wifi_pw
  manual_ip:
    static_ip: 192.168.86.101
    gateway: 192.168.86.1
    subnet: 255.255.255.0

Sorry for necroposting, but I faced some problems with this issue too. But it seems to only be a problem with the add-on “File editor” for me, not an actual problem. I run a supervised instance.

As soon as I enter the required <<: !include ../secrets.yaml in the /config/esphome/secrets.yaml file through File editor, a red exclamation pops up in File editor with a weird message:

cannot merge mappings; the provided source object is unacceptable (1:29)

 1 | <<: .include ../secrets.yaml "
---------------------------------^ 

Initially I thought I had the same problem with the others and tried to debug. But I gave up and just thought to try to compile and upload to a node. YAML was validated, compilation completed without any errors and as soon as the firmware was uploaded, the node connected to wifi just fine. I had initially replaced the wifi_ssid name only, and went on and tried with wifi_passw after that. It worked too. So in my case it’s just a false positive on the File editor’s GUI, nothing more than that.
If someone has figured out what that message means, please let us know.

1 Like

Hello!

I have the same problem posted by @Tryfos. Is there a solution that the HA File Editor does not complain as described? Even knowing that it works nevertheless, it is a bit “disturbing”. :wink:

Home Assistant 2023.4.6
Supervisor 2023.04.1
Operating System 9.5
Frontend 20230411.1 - latest

PS/EDIT: Unfortunately, with this …

<<: .include ../secrets.yaml

… in /config/esphome/secrets.yaml

… I cannot update, because the update quits with this error message:

Updating /config/esphome/esp32-ha1.yaml
------------------------------------------------------------

INFO Reading configuration /config/esphome/esp32-ha1.yaml...
ERROR Error while reading config: Invalid YAML syntax:

While constructing a mapping
  in "/config/esphome/secrets.yaml", line 1, column 1:
    <<: .include ../secrets.yaml
    ^
Expected a mapping or list of mappings for merging, but found <class 'esphome.helpers.EStr'>
  in "/config/esphome/secrets.yaml", line 1, column 5:
    <<: .include ../secrets.yaml
        ^
========== [ERROR] /config/esphome/esp32-ha1.yaml ==========

Thanks for sharing your thoughts! :slight_smile:

! not .

<<: !include …/secrets.yaml

You should see the syntax highlighting change the color of the include statement when you get it right.

That’s all inspiring, but I just kept 1 secrets.yaml file and put a symbolic link from my extended folders back to the original in config/esphome.
Then the secrets thing works in the addon, the fussy include thing can be ignored, and all is well in Mudville.

cd {to the folder trying to reference the secrets.yaml}
ln -s {Path to your esphome folder}/secrets.yaml secrets.yaml