I’m working on a YAML config file for ESPHome and need to use some anchors to avoid a lot of repetition. I’ve been having a really tough time finding information on YAML anchors and examples of more than just the simplest uses. In this case, I have, with someone’s suggestion:
.number: &AnchorDelay
optimistic: true
min_value: 0
max_value: 600
step: 1
initial_value: 0
web_server: &AnchorDelayWebServer
sorting_group_id: sorting_group_switchmain
sorting_weight: 30
number:
- platform: template
<<: *AnchorDelay
id: "SwitchMainDelay"
name: "Main Switch Delay"
- platform: template
<<: *AnchorDelay
id: "Switch01Delay"
name: "Switch 01 Delay"
web_server:
<< : *AnchorDelayWebServer
sorting_group_id: sorting_group_switch1
In order to create the original component I wanted within the number:
section, this format has been the only thing I could find. It seems to work, but I can’t find clear documentation on what the .number
with the dot/period at the start of the line does. I’ve searched and have not found any clear answer of just what that’s about or what it does.
4