esphome / esphome/feature-requests

Allow substitutions in secret references

Open
#3,171 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
450
Forks
29
PR merge metrics
No merged PRs in 30d

Description

**Describe the problem you have/What new integration you would like**

Allow substitutions in secret references

**Please describe your use case for this integration and alternatives you've tried:**

The esphome UI suggests that `api.key` should be unique to each device, however this precludes using variables over hardcoding device names into the reference, as substitutions aren't expanded in secret references.

For example, if you have multiple devices each with their own API key (or any other secret), it's cleaner to have `api_key: !secret "${name}".api.key` inherited (or even repeated) across configs, than to hardcode/retype the device name in each file.

**Additional context**

Back in 2019 (https://github.com/esphome/issues/issues/486#issuecomment-506014504) it was said that secrets were resolved prior to substitutions by design and this is how it'll stay as "it makes more sense in some cases". Perhaps it would be possible to preserve this order by prepending a third step to the order of processing:

1) substitutions in `!secret` references are expanded
2) `!secret` references themselves are expanded
3) Other substitutions are expanded

I'm unsure of the level of interest in this as a whole, but I think it may make for slightly more reusable config and easier maintenance in larger esphome deployments.

Thanks! :)

Contributor guide

No contributing guide indexed for this repository

Research direction

No implementation files or tests are named. Start by locating ESPHome's handling of !secret references and substitutions, then trace the current processing order using a configuration with ${name}. Done means substitutions work inside secret references while the existing secret-resolution behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.