Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover: adding several devices causes an error if yaml-anchor is used #128

Open
ildar170975 opened this issue Aug 23, 2024 · 1 comment
Open

Comments

@ildar170975
Copy link

ildar170975 commented Aug 23, 2024

Consider this code:

version: 1
devices:
  Test Cover:
    - platform: cover
      initial_value: 'closed'
      open_close_duration: 5
      open_close_tick: 1

  Test Cover abc:
    - platform: cover
      initial_value: 'closed'
      open_close_duration: 5
      open_close_tick: 1

Trying to add these covers:
изображение

Seems that 2 covers are created properly:
изображение

And no errors/warnings in Log.

Then consider this code:

version: 1
devices:
  Test Cover: &ref_settings
    - platform: cover
      initial_value: 'closed'
      open_close_duration: 5
      open_close_tick: 1

  Test Cover abc: *ref_settings

which is supposed to produce same result.
But it gives an error:
изображение

No covers are created.

There is an error in Log:
2024-08-23 19:36:40.903 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry imported - virtual for virtual
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/virtual/init.py", line 149, in async_setup_entry
await vcfg.async_load()
File "/config/custom_components/virtual/cfg.py", line 306, in async_load
platform = entity.pop(CONF_PLATFORM)
^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'platform'

@ildar170975
Copy link
Author

ildar170975 commented Aug 23, 2024

Mysteriously this variant works:

version: 1
devices:
  Test Cover:
    - <<: &ref_settings
        platform: cover
        initial_value: 'closed'
        open_close_duration: 5
        open_close_tick: 1

  Test Cover abc:
    - *ref_settings

and this - does NOT:

version: 1
devices:
  Test Cover:
    - <<: &ref_settings
        platform: cover
        initial_value: 'closed'
        open_close_duration: 5
        open_close_tick: 1

  Test Cover abc:
    - *ref_settings
  Test Cover xyz:
    - *ref_settings

The glitch could be related somehow to an omitted "name" option - this code works (creates 3 covers):

version: 1
devices:
  Test Cover:
    - <<: &ref_settings
        platform: cover
        initial_value: 'closed'
        open_close_duration: 5
        open_close_tick: 1
      name: testing_cover

  Test Cover abc:
    - <<: *ref_settings
      name: testing_cover_abc
  Test Cover xyz:
    - <<: *ref_settings
      name: testing_cover_xyz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant