I have been using substitutions in my device YAML files like this:
substitutions:
device_name: kim_desklight
esphome:
name: ${device_name}
platform: ESP8266
board: esp01_1m
...
...
...
switch:
- platform: gpio
name: ${device_name}
pin:
number: 12
mode: output
id: ${device_name}_relay
- platform: gpio
name: ${device_name} led"
pin:
number: 13
mode: output
This makes it really easy to duplicate the YAML file for new devices on the same hardware with only a single change in substitutions:
However, when I use the substitution on the id: line, I get an error:
id: ${device_name}_relay
“Dashes are not supported in IDs, please use underscore”.
But underscores are discouraged in the name:.
So, here’s my question.
Is the id: only used at compile time? Would I be better using a simple string, like “relay12”? Is the ID local? Does it matter if I use the same ID: on multiple device YAML files?