Attributes sharing an ID with a manufacturer-specific definition still break the HA cluster attribute UI (list/read/write)

Open
#921 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

The zha-side fix starts in zha/zigbee/device.py, in write_zigbee_attribute, where cluster.find_attribute is called without the manufacturer code; the error labelling is in zha/application/helpers.py, write_attributes_safe. Run tests/test_device.py with a shared-ID case (Innr SP 120 snapshot, ID 0x0000) to reproduce the KeyError. Done means writes with manufacturer 0x1166 and None reach the matching definition, and the HA Core and frontend parts are coordinated, since the WS API shape changes.

Written by the indexing model from the issue text.

Description

HA core

Summary

#920 fixed the device-diagnostics part of #798 by iterating cluster.AttributeDefs. The other consumers of attribute definitions still assume that an attribute ID is unique within a cluster. A quirk can legitimately define a manufacturer-specific attribute at the same ID as a ZCL attribute (the Innr SP 120 metering quirk defines current_mfg_summ_delivered at 0x0000 with manufacturer code 0x1166, next to the standard current_summ_delivered). On such a cluster, the "Manage Zigbee device" → Clusters → attributes UI in Home Assistant currently can't list, read, or write those attributes correctly. As noted on #798, this is still an open issue in the HA frontend. This issue tracks the remaining zha, HA Core and frontend work.

What's still broken

Verified on zha dev at 5eb118cc4065221f032221cdcbdfffd383dd139e (zigpy 2.3.0, zha-quirks 2.2.2), using the innr-sp-120-0x11040002.json snapshot:

  1. The listing drops one definition. Device.async_get_cluster_attributes returns zigpy's cluster.attributes, which is keyed by ID only (https://github.com/zigpy/zha/blob/5eb118cc4065221f032221cdcbdfffd383dd139e/zha/zigbee/device.py#L1364). For the SP 120 metering cluster, ID 0x0000 lists only current_summ_delivered, and current_mfg_summ_delivered never reaches the UI. HA Core's zha/devices/clusters/attributes then sends just {id, name} with no manufacturer code (homeassistant/components/zha/websocket_api.py L607), and the frontend keys the attribute picker on id alone.
  2. Reading the shared ID fails. Without a manufacturer code, the read call fails with KeyError: Multiple definitions exist for attribute ID 0x0000, please specify a manufacturer code. The read WS command only accepts an integer ID (websocket_api.py L701), and the frontend sends no manufacturer unless the "Manufacturer code override" field is filled. So even the standard current_summ_delivered can't be read from the UI on this device.
  3. zha's write ignores the manufacturer code. Device.write_zigbee_attribute resolves the attribute with cluster.find_attribute(attribute) before writing, without passing the manufacturer (https://github.com/zigpy/zha/blob/5eb118cc4065221f032221cdcbdfffd383dd139e/zha/zigbee/device.py#L1396). For a shared ID it raises the same KeyError whatever manufacturer is passed: none, 0x1166, or None.
  4. Related: the manufacturer override no longer works the way the UI and service describe it. zigpy now resolves a definition by (ID, manufacturer code). Passing a manufacturer code that no definition has, e.g. a code on a standard attribute, raises KeyError. The zha.set_zigbee_cluster_attribute service documents -1 as "force no code to be set", but HA forwards -1 unchanged (services.py L111) and zigpy raises KeyError: -1.
  5. Minor: when a write fails, write_attributes_safe labels the error via cluster.attributes[record.attrid] (https://github.com/zigpy/zha/blob/5eb118cc4065221f032221cdcbdfffd383dd139e/zha/application/helpers.py#L117), which can name the wrong definition for a shared ID.

Existing work: dmulcahey's frontend and core branches

Two unmerged branches from 2026-09-06 already cover most of the HA side (no PRs opened for them yet):

What they do for this problem:

  • Core lists attributes from cluster.AttributeDefs, including the manufacturer-specific duplicates. For each attribute it sends manufacturer_code and is_manufacturer_specific, along with type, access and a form schema.
  • Core's read command also accepts an attribute name, and resolves the definition with the manufacturer code.
  • The core write service maps -1 to None and does the manufacturer-aware lookup itself, which bypasses zha's write_zigbee_attribute (item 3).
  • The frontend keys attributes by (id, name, manufacturer code) and labels manufacturer-specific ones with their code. It reads and writes by name together with the definition's own manufacturer code.

Beyond this issue, the branches also add typed form schemas (structs, lists, enums) for attribute values and command arguments.

Things to settle before upstreaming:

  • The WS API shape changes. zha/devices/clusters/attributes goes from [{id, name}] to [{schema, zcl_attribute: {...}}], and the attribute read returns a typed value instead of a string. The core and frontend PRs have to ship in the same release.
  • The manual "Manufacturer code override" field is removed for both attributes and commands. Commands are then issued without an explicit manufacturer code. That fits zigpy's definition-driven model (item 4), but it drops the escape hatch for commands that have no manufacturer-specific definition.
  • Both branches are far behind (core by ~2000 commits, frontend by ~400) and need a rebase.

Proposed fixes

  • zha: pass the manufacturer in write_zigbee_attribute (cluster.find_attribute(attribute, manufacturer_code=manufacturer)). I tested this locally on the SP 120 snapshot. With manufacturer=0x1166 the write goes to current_mfg_summ_delivered, and with None it goes to the standard attribute. Calling it without a manufacturer still raises, which is correct for an ambiguous ID. tests/test_device.py passes with the change. This lets HA keep calling zha instead of re-implementing the write.
  • zha: give HA an accessor that returns every definition (e.g. a list from AttributeDefs), or let HA iterate cluster.AttributeDefs directly as the core branch does. Keep the dict-returning async_get_cluster_attributes unchanged, so it doesn't silently change its contract.
  • zha: label write_attributes_safe failures from the attributes that were actually written, not from cluster.attributes.
  • HA Core: list from AttributeDefs with manufacturer metadata, accept names in the read command, and map -1 to None (the core branch above).
  • Frontend: key by (id, name, manufacturer code), and read/write with the definition's code (the frontend branch above).

Context: #798, #920

How this was checked
  • Ran a probe test against the SP 120 snapshot at zha dev 5eb118cc. async_get_cluster_attributes(1, 0x0702) lists only current_summ_delivered for ID 0x0000. write_zigbee_attribute(1, 0x0702, 0, 5, manufacturer=...) raises KeyError: Multiple definitions exist… for no manufacturer, 0x1166 and None. cluster.read_attributes([0]) raises the same.
  • With the one-line find_attribute(..., manufacturer_code=manufacturer) change, writes with 0x1166 and None reach cluster.write_attributes with the matching manufacturer. tests/test_device.py passes (68 tests).
  • zigpy 2.3.0: OnOff.find_attribute(start_up_on_off.id, manufacturer_code=-1) and manufacturer_code=0x1234 both raise KeyError, and manufacturer_code=None resolves the standard attribute.
  • HA Core and frontend: read on current dev. The branch behaviour comes from their diffs against the merge base.

Also related (comment below):

Dominant language
Python
Stars
96
Forks
84
Avg merge
2d 4h
Merged PRs (30d)
30

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zigpy/zha

All issues in zigpy/zha

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.