Skip to content

Error while setting up subset of chargers #274

@sveinse

Description

@sveinse

If selecting a subset of chargers the setup will fail with errors. This is due to missing device coordinators for any chargers that is not selected, while the setup loop is iterating over all chargers present.

2025-08-08 10:23:09.372 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up zaptec platform for binary_sensor: 'xxx'
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.13/site-packages/homeassistant/helpers/entity_platform.py", line 382, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/workspaces/zaptec/custom_components/zaptec/binary_sensor.py", line 108, in async_setup_entry
    entities = entry.runtime_data.create_entities_from_zaptec(
        INSTALLATION_ENTITIES,
        CHARGER_ENTITIES,
    )
  File "/workspaces/zaptec/custom_components/zaptec/__init__.py", line 470, in create_entities_from_zaptec
    self.create_entities_from_descriptions(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        installation_descriptions,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
        obj,
        ^^^^
        info,
        ^^^^^
    )
    ^
  File "/workspaces/zaptec/custom_components/zaptec/__init__.py", line 415, in create_entities_from_descriptions
    coordinator=self.device_coordinators[zaptec_obj.id],
                ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'xxx'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions