Open fakuivan opened 6 months ago
What is the point of doing substitutions like that?
The same point as using substitutions in the first place, avoiding repetition, for example:
---
# main file
esphome:
name: test
packages:
included: !include
file: included.yaml
vars:
value: some value
host:
---
# included.yaml
substitutions:
frequently_used_value: ${value} and more
...
- $frequently_used_value
- $frequently_used_value
- $frequently_used_value
- $frequently_used_value
- $frequently_used_value
that's the first thing I can come up with, I'm sure there are more uses
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
The problem
vars
in!include
do not get substituted in entries for thesubstitutions
components on the imported file, making the following fail:This is a result of how
vars
in!include
is processed as substitutions insubstitute_vars
.https://github.com/esphome/esphome/blob/357ac3b85f6cff3c93ec8a3c29daca1e945a4fda/esphome/yaml_util.py#L286-L316
Specifically this line, where the contents of the
substitutions
section is swapped by what's invars
, instead of first substituted and then swapped back in. It'll probably be a good idea to specify how substitutions are to be merged in cases like this.Which version of ESPHome has the issue?
2024.3.0-dev
What type of installation are you using?
pip
Which version of Home Assistant has the issue?
No response
What platform are you using?
ESP8266
Board
No response
Component causing the issue
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response