Skip to content

ZHA fails to load when ClusterType.Client is used in v2 Quirk #353

@tr4nt0r

Description

@tr4nt0r

Bug description

The log outputs this error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/logbook/processor.py", line 259, in _humanify
    data = describe_event(event_cache_get(row))
  File "/usr/src/homeassistant/homeassistant/components/zha/logbook.py", line 44, in async_describe_zha_event
    zha_device = async_get_zha_device_proxy(
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        hass, event.data[ATTR_DEVICE_ID]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ).device
    ^
  File "/usr/src/homeassistant/homeassistant/components/zha/helpers.py", line 1060, in async_get_zha_device_proxy
    zha_gateway_proxy = get_zha_gateway_proxy(hass)
  File "/usr/src/homeassistant/homeassistant/components/zha/helpers.py", line 1039, in get_zha_gateway_proxy
    raise ValueError("No gateway object exists")
ValueError: No gateway object exists

Steps to reproduce

This V2 Quirk caused the error:

In the quirk an out cluster is replaced, but when creating a number input for this cluster ZHA integration fails to load. When commenting out ClusterType.Client, ZHA will load again but will not create the entities as it cannot find the cluster

(
    QuirkBuilder("MiaMiaoCe", "MHO-C401N-z")
    .applies_to("Xiaomi", "LYWSD03MMC-z")
    .replaces(CustomUserInterfaceCluster, cluster_type=ClusterType.Client)
    .number(
        CustomUserInterfaceCluster.AttributeDefs.temperature_offset.name,
        CustomUserInterfaceCluster.cluster_id,
        ClusterType.Client,
        min_value=-327.67,
        max_value=327.67,
        step=0.01,
        unit=UnitOfTemperature.CELSIUS,
        translation_key="temperature_offset",
        fallback_name="Temperature offset",
        multiplier=100
    )
    .number(
        CustomUserInterfaceCluster.AttributeDefs.humidity_offset.name,
        CustomUserInterfaceCluster.cluster_id,
        ClusterType.Client,
        min_value=-327.67,
        max_value=327.67,
        step=0.01,
        # unit=PERCENTAGE,
        translation_key="temperature_offset",
        fallback_name="Temperature offset",
        multiplier=100
    )
    .add_to_registry()
)

Expected behavior

ZHA loads successfully and creates the number entities

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions