Repository navigation
Name the circuit or device in a control's error as Home Assistant shows it - #386
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SpanPanelEntity._displayed_device_name()reads the entity'sdevice_entrywhen the message is built, throughutil.device_display_name(from Show renamed panels and sub-devices by their Home Assistant name #384). All five error families use it.adopted_device_labelanswers 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.tests/helpers.py, instead of mocked entities.Changelog (2.3.4, Fixed)
Tests
tests/test_control_error_device_names.pycovers 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.pyadds the adopted cases, and the two malformed-type card names.