Open Pimentoso opened 3 weeks ago
I think extend can only be used in the main yaml.
@ssieb does not work even by moving the contents of motion_status_leds.yml
inside main.yml
(after the packages declaration). Gives the same error.
And you can't extend sub-components like that. You need to move it up one level. I think that should work.
But that's literally what the extend function should do. From the original PR description #3555
which means that a user can override a field in a package's component by referencing the same id in their config with !extend id.
However! I might have found a workaround, which is using the Copy integration
Basically I made moving_target_sensor
internal, and exposed a copy of it. Now it does not have the has_moving_target:
section, the yml compiles. I haven't tested it yet though.
So motion_sensor.yml
became
binary_sensor:
- platform: ld2410
has_target:
id: motion_sensor_internal
internal: true
has_moving_target:
id: moving_target_sensor_internal
internal: true
has_still_target:
id: still_target_sensor_internal
internal: true
- platform: copy
source_id: motion_sensor_internal
id: motion_sensor
name: "${device_name}-presence"
- platform: copy
source_id: moving_target_sensor_internal
id: moving_target_sensor
name: "${device_name}-moving-target"
- platform: copy
source_id: still_target_sensor_internal
id: still_target_sensor
name: "${device_name}-still-target"
You didn't want to do:
binary_sensor:
- platform: ld2410
id: !extend my_ld2410
has_moving_target:
on_press:
then:
- light.addressable_set:
id: rgb_leds
[...turn on a led]
on_release:
then:
- light.addressable_set:
id: rgb_leds
[...turn off a led]
You might need to include the id:
and name:
as well though.
That's not working because:
[id] is an invalid option for [binary_sensor.ld2410].
Thanks for your suggestions however. I will test my workround soon and report back.
The problem
In my house I am using many LD2410 presence sensors, so I wanted to use !extend to add some actions to the binary sensors. The yml is failing to compile.
main yml file
motion_sensor.yml
motion_status_leds.yml
I receive the following error
I suspect it's because the
!extend
syntax cannot handle nested IDs like in the LD2410 case? Or am I doing anything wrong? Is there any workaround?cc @quentinmit
Which version of ESPHome has the issue?
2024.3.2
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
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response