Ah ok. Didn’t read it properly I guess.
Hi,
I’m having a similar issue.
I have yaml files in esphome root and the secret.yaml
node1.yaml
node2.yaml
secrets.yaml
and i included some packages in node1.yaml:
packages:
wifi: !include common/wireless.yaml
tempsensor: !include components/sensors/dht/dht11.yaml
Now i’m unable to reach secrets.yaml located in esphome root from common/wireless.yaml
I tryed this in wireless yaml
<<: !include ../secrets.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
but the log reports that is still searching the secrets.yaml inside the /common folder instead of the secrets.yaml located in root.
Could you please help me?
thank you
Your only option is to compile your own version of esphome with the change i mentioned above.
Thank you, I hoped something changed in the meanwhile.
The strange thing is that in this official guide:
Configuration Types — ESPHome
The above example about packages it suggest that may work.
Am I wrong or it is an error of the documentation?
hi, unfortunately I’m unable to reach the esphome secret file from any subfolder.
I’ve tried to do so packages but without success.
The way I’m doing this is to assign the secrets to substitutions in my main file and then just use the substitution variables everywhere else.
That works. Mostly. I think I found one case where it didn’t work and that was for the esphome.build_path
.
could you please write an example?
thank you
Hi, I provided most of the files in another post.
I see you put secrets.yaml in a subfolder with wifi.yaml. In this way works also for me. What I’m unable to do is reaching secrets.yaml from a subfolder (/common/wifi.yaml).
The secrets file has to be in the same folder as the yaml.
I’ve changed my config now so that all the secrets are in the root. The root yaml accesses them in substitutions. Other yaml files can use substitutions more easily.
I’m curious why the documentation has an incomplete example showing it is possible:
Configuration Types — ESPHome
I can’t see any references to secrets in subfolders on that page. Packages yes. Packages in subfolders work fine and I make extensive use of them so that I can keep my main YAML as simple as possible and reusable across multiple device types.
sorry I meant I can’t reach secrets from a package in a subfolder:
I cannot reach secrets in a parent folder from a package in a subfolder.
<<: !include ../../secrets.yaml
I hope i did explain better
No, I don’t think that works. Instead use the root file to assign secrets to substitutions and use those.
since it’s/ I’m on a linux OS, I solved this by creating a symbolic link. Login through ssh and cd into the correct folder.
ln -s ../secrets.yaml
I am only using that secrets file for Esphome. I am not sharing secrets between HA and ESPH.
However, I can see this should also work in that scenario.
I do not know (yet) if this will survive any updates.
Now that HASSIO bought ESPHOME it would be interesting to integrate secret files.
I’m not comfortable moving those files in subfolders. I suppose there might be security reasons.
well all this was supposed to make order in root files
Create a new secrets.yaml file in the common folder and include the single line <<: !include ../secrets.yaml
in that file.
Don’t add this include to your device configuration.
You can use links on Windows and Mac as well.
that’s a great tip however it’s curious we still need to use a workaround also after 2021.12 update that uses the wizard to import wifi credential from the main secret file.