Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Support !secret in YAML #161

Open
PaulSD opened this issue Feb 24, 2025 · 2 comments
Open

[FR] Support !secret in YAML #161

PaulSD opened this issue Feb 24, 2025 · 2 comments

Comments

@PaulSD
Copy link

PaulSD commented Feb 24, 2025

From #159 (comment)

2. Is it possible to make this scenario
variables:
  xxx: !secret my_super_secret

supported?

@PaulSD
Copy link
Author

PaulSD commented Feb 24, 2025

We can use secrets in lovelace yaml like:

type: history-graph
hours_to_show: !secret xxxxxx

so I thought may be it could be possible to use them inside variables.

I'm not able to reproduce this ... Your history-graph example gives me:

Configuration error
Error in parsing YAML: unknown tag !<!secret> (line: 2, column: 37)

Am I missing something?

@ildar170975
Copy link
Collaborator

Thanks for creating this FR!

I'm not able to reproduce this

Are you trying to use secrets in a storage-mode dashboards?
Secrets only work in yaml files.
Try a yaml-mode dashboard.


Some information:
Secrets are usually used as "secrets", i.e. to HIDE data when posting configs in github or sharing then in forums.
A more real-life example could be for a pincode in a custom restriction card:

type: custom:restriction-card
restrictions:
  pin:
    code: !secret my_super_secret_pincode
    text: Enter pin to unlock
card:
  ...

since a pincode could be really important.

But in many cases !secret is used for ANY data which are shared in many yaml-files in config:
-- complex structures like "common settings for input_number entity", "common settings for some card",
-- or simple data like "value of particular option".
Yes, these data are not "secrets" in fact & supposed to be imported via !include like:

type: history-graph
hours_to_show: !include /config/shared/.../common_hours_to_show.yaml

But in this case each entry (even just a simple string) should be a separate yaml-file.
That is why some people import these shared pieces with !secret - and all these pieces can be stored in one secrets.yaml file (could be stored as a separate secrets.yaml in the same folder where a particular package is stored, not in a one global secrets.yaml).
I myself prefer !include method (although it is more cumbersome - but more "correct") & use !secret only for real "secrets".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants