esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Substitutins not parsed in !extend #5594

Open Masterz69 opened 6 months ago

Masterz69 commented 6 months ago

The problem

Using packages to define relays in configuration like sw_relay_1 etc. by passing ${id} to package. Trying to create package to extend relays with some functions by using !extend.

But discovered - substitutions not parsed while using !extend configration.

switch:      
  - id: !extend sw_relay_${id}

causing Source for extension of ID 'sw_relay_${id}' was not found. id: !extend sw_relay_${id}

Which version of ESPHome has the issue?

2023.12.7

What type of installation are you using?

Home Assistant Add-on

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

main file:

packages:
  config_pulse_${id}: !include
    file: config_pulse.yaml
    vars:
      id: ${id}
  relay_base_${id}: !include
    file: relay_base.yaml
    vars:
      id: ${id}

switch:      
  - id: !extend sw_relay_${id}

...

relay_base.yaml:

switch:      
  - platform: template
    id: sw_relay_${id}
...

Anything in the logs that might be useful for us?

No response

Additional information

No response

Masterz69 commented 1 month ago

!extend can't find source too in following case:

package.yaml:

switch:      
  - platform: template
    id: sw_relay_${id}

main.yaml

packages:
  package: !include { file: package.yaml, vars: { id: 1 } }

switch:
  - id: !extend sw_relay_1