Skip to content

Name the circuit or device in a control's error as Home Assistant shows it - #386

Merged
cayossarian merged 1 commit into
mainfrom
feat/adopted-error-names
Nov 23, 2026
Merged

cayossarian merged 1 commit into
mainfrom
feat/adopted-error-names

Conversation

@cayossarian

Copy link
Copy Markdown
Member

What

When a write from a breaker, circuit priority, charger or adopted-device control fails, its error now names the circuit or device as Home Assistant shows it: the user's rename where there is one, else the device's registered name. Before, these errors used a name captured at setup or the panel's own circuit name, so a rename in Home Assistant never reached them.

Changes

  • Shared name: SpanPanelEntity._displayed_device_name() reads the entity's device_entry when the message is built, through util.device_display_name (from Show renamed panels and sub-devices by their Home Assistant name #384). All five error families use it.
    • It has no fallback. An added control always has a named device: Core links the device before it adds the entity or aborts the add, and every device these controls sit on is registered under a non-empty name.
  • Adopted card names never empty: adopted_device_label answers the device's name, else the last non-empty segment of its declared type, else its wire id. A nameless device whose type ends in a dot used to get the panel entry's title on its first registration and an empty name on the next load.
  • Side effects, each consistent with the device list:
    • An unnamed solar circuit's error says "Solar", as its device does, instead of its breaker positions.
    • A circuit missing from the live snapshot is named by its device, not its wire id.
    • In the moment between a SPAN-app rename and the reload it triggers, the error names what the device list still shows.
  • Tests: controls that were written to without being added now go through a real entity platform, through new helpers in tests/helpers.py, instead of mocked entities.

Changelog (2.3.4, Fixed)

  • An error from a breaker, circuit priority, charger or adopted-device control now names the circuit or device by the name you gave it in Home Assistant, where it kept the name the panel or the integration gave it.

Tests

  • New tests/test_control_error_device_names.py covers every family on both failure paths: renamed before a restart, renamed after setup, not renamed, the SPAN-app rename window and a circuit missing from the snapshot, plus the unnamed solar circuit. The rename cases fail on the previous code.
  • tests/test_adoption.py adds the adopted cases, and the two malformed-type card names.
  • Full suite: 4673 passed. mypy, ruff and the pre-commit hooks are clean.

…e Assistant shows it

A failed write from a breaker, circuit priority, charger or adopted-device
control named the circuit or device by a name captured at setup or taken from
the panel, so a rename in Home Assistant never reached the error. The errors
now read the entity's device entry when the message is built, through a shared
_displayed_device_name; an added control always has a named device.

An adopted device's card name is never empty any more: a nameless device whose
declared type ends in a dot is named by its last type segment, else its id.
@cayossarian
cayossarian merged commit 6237dc0 into main Nov 23, 2026
8 checks passed
@cayossarian
cayossarian deleted the feat/adopted-error-names branch November 23, 2026 23:50
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

Successfully merging this pull request may close these issues.

1 participant