Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file.

## [2.3.4] - 11/2026

### Fixed

- **The SPAN Panel card and the sidebar dashboard now show a panel and each of its battery, charger and solar devices by the name you gave it in Home
Assistant**, where a renamed device kept the name the integration gave it.

- **A SPAN Panel card opened while Home Assistant is starting or restarting, or while the integration retries a panel it cannot reach, says it is waiting for
the panel to load and draws the panel once it has loaded**, where it showed "Unable to connect to SPAN Panel" until Retry was pressed or the dashboard was
opened again.

## [2.3.3] - 11/2026

**Install 2.3.3 before your panel updates to firmware r202645**, which gives the panel's circuits new device IDs: 2.3.3 carries every circuit entity, device,
Expand Down
8 changes: 4 additions & 4 deletions custom_components/span_panel/additions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from .const import DOMAIN
from .extension import is_extension_unique_id
from .notices import async_raise, read_translations
from .util import ADOPTED_IDENTIFIER_TOKEN
from .util import ADOPTED_IDENTIFIER_TOKEN, device_display_name

if TYPE_CHECKING:
from homeassistant.config_entries import ConfigEntry
Expand Down Expand Up @@ -368,7 +368,7 @@ def _adopted_device_name(
token = f"_{ADOPTED_IDENTIFIER_TOKEN}_"
if not any(token in identifier for _domain, identifier in device.identifiers):
return None
return device.name_by_user or device.name or registry_entry.entity_id
return device_display_name(device) or registry_entry.entity_id


def _extension_device_name(
Expand All @@ -392,7 +392,7 @@ def _extension_device_name(
device = devices.async_get(registry_entry.device_id)
if device is None:
return None
return device.name_by_user or device.name or registry_entry.entity_id
return device_display_name(device) or registry_entry.entity_id


def _label(devices: dr.DeviceRegistry, registry_entry: er.RegistryEntry) -> str:
Expand Down Expand Up @@ -443,7 +443,7 @@ def _own_device_name(devices: dr.DeviceRegistry, registry_entry: er.RegistryEntr
return None
if isinstance(device, dr.DeviceEntry) and device.via_device_id is None:
return None
return device.name_by_user or device.name
return device_display_name(device)


async def async_forget_announcements(hass: HomeAssistant, entry: ConfigEntry) -> None:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/span_panel/circuit_object_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class here that defines an add or remove hook defines
from .id_builder import build_circuit_device_identifier
from .naming import circuit_object_id_suffix, suffix_wordings, without_core_number
from .runtime import SpanPanelConfigEntry, SpanPanelRuntimeData, loaded_runtime_data
from .util import circuit_id_of_device, effective_circuit_device_name
from .util import circuit_id_of_device, device_display_name, effective_circuit_device_name

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -277,7 +277,7 @@ def compose_circuit_object_id(
composed_device_name = device_name
area_id = device_area_id
if device_area_id is None and panel is not None:
panel_name = panel.name_by_user or panel.name
panel_name = device_display_name(panel)
area_id = panel.area_id

area_name: str | None = None
Expand Down
3 changes: 2 additions & 1 deletion custom_components/span_panel/conversion_repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
from .entry_issues import EntryIssue, EntryIssueFamily, async_create_entry_issue
from .id_builder import build_switch_unique_id
from .runtime import SpanPanelConfigEntry, loaded_runtime_data
from .util import device_display_name

_TRANSLATION_KEY: Final = "circuit_devices_converted"

Expand Down Expand Up @@ -243,7 +244,7 @@ def _panel_name(hass: HomeAssistant, entry: SpanPanelConfigEntry) -> str:
runtime_data = loaded_runtime_data(entry)
if runtime_data is not None:
device = dr.async_get(hass).async_get(runtime_data.panel_device_id)
if device is not None and (name := device.name_by_user or device.name):
if device is not None and (name := device_display_name(device)):
return name
return entry.title

Expand Down
26 changes: 13 additions & 13 deletions custom_components/span_panel/frontend/dist/span-panel-card.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions custom_components/span_panel/frontend/dist/span-panel.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion custom_components/span_panel/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"span-panel-api-schema-1==1.5.0",
"span-panel-api==3.9.1"
],
"version": "2.3.3",
"version": "2.3.4b1",
"zeroconf": [
{
"type": "_span._tcp.local."
Expand Down
18 changes: 18 additions & 0 deletions custom_components/span_panel/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Final

from homeassistant.helpers.device_registry import (
AnyDeviceEntry,
ChildDeviceEntry,
ChildDeviceInfo,
DeviceInfo,
Expand Down Expand Up @@ -551,6 +552,23 @@ def circuit_id_of_device(serial: str, device: ChildDeviceEntry) -> str | None:
return None


def device_display_name(device: AnyDeviceEntry) -> str | None:
"""Return the name Home Assistant shows for a device: the user's, else the integration's.

A rename in Home Assistant is stored in `name_by_user`, and `name` stays the
name the integration registered the device under. Core shows the user's
wherever there is one, so anything that names a device to a person asks
here rather than reading `name` -- which is how the card's title kept a
panel's default name after the user renamed it.

Empty or None only for a device with neither, which each caller answers in
its own way. A circuit's entities are named by `effective_circuit_device_name`
instead, which falls back to the name the device is about to be given
rather than the one the registry holds.
"""
return device.name_by_user or device.name


def effective_circuit_device_name(
device_registry: DeviceRegistry,
serial: str,
Expand Down
9 changes: 6 additions & 3 deletions custom_components/span_panel/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
)
from .runtime import SpanPanelRuntimeData, loaded_runtime_data
from .solar_topology import SolarTopology, solar_topology
from .util import circuit_device, classify_sub_device_identifier, pv_device_ref
from .util import circuit_device, classify_sub_device_identifier, device_display_name, pv_device_ref
from .websocket_adopted import handle_adopted_curate, handle_adopted_list
from .websocket_panel import resolve_panel_device

Expand Down Expand Up @@ -287,7 +287,8 @@ async def handle_panel_topology(
sub_device_type = _classify_sub_device(dev)

record: dict[str, Any] = {
"name": dev.name,
# The name Home Assistant shows for the device, a rename included.
"name": device_display_name(dev),
"type": sub_device_type,
"manufacturer": dev.manufacturer,
"model": dev.model,
Expand Down Expand Up @@ -326,7 +327,9 @@ async def handle_panel_topology(
# the panel's identity from here rather than looking up the id it has.
"panel_device_id": device_entry.id,
"config_entry_id": config_entry_id,
"device_name": device_entry.name,
# The name Home Assistant shows for the panel's device: the user's
# where they renamed it, else the one the entry was set up with.
"device_name": device_display_name(device_entry),
"panel_entities": panel_entities,
# Whether `set_circuit_package_ratings` takes ratings on this panel at
# all. False where the panel describes its multi-load breakers: current
Expand Down
3 changes: 2 additions & 1 deletion custom_components/span_panel/websocket_adopted.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
from .entry_reloads import async_request_reload
from .extension import adoptable, extension_curation_key, resolve_platform
from .runtime import SpanPanelRuntimeData, loaded_runtime_data
from .util import device_display_name
from .websocket_panel import resolve_panel_device

if TYPE_CHECKING:
Expand Down Expand Up @@ -457,7 +458,7 @@ def _device_label(card: dr.DeviceEntry | None, fallback: str) -> str:
"""
if card is None:
return fallback
return card.name_by_user or card.name or fallback
return device_display_name(card) or fallback


def _resolve_panel_entry(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "span"
version = "2.3.3"
version = "2.3.4b1"
description = "Span Panel Custom Integration for Home Assistant"
authors = [{name = "SpanPanel"}]
license = {text = "MIT"}
Expand Down
67 changes: 64 additions & 3 deletions tests/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
pv_binding_for,
)
from .helpers import (
PANEL_NAME,
count_panel_describes_breakers,
register_circuit_device,
register_panel_device,
Expand Down Expand Up @@ -139,16 +140,24 @@ async def _panel_holding(
return panel_device_id


async def _ask_topology(hass: HomeAssistant, device_id: str) -> dict[str, dict[str, object]]:
"""Answer the topology for the panel whose device registry ID is `device_id`, and return its circuits."""
async def _topology_result(hass: HomeAssistant, device_id: str) -> dict[str, object]:
"""Answer the topology for the panel whose device registry ID is `device_id`, and return it."""
connection = _make_mock_connection()

await _handle_panel_topology_inner(
hass, connection, {"id": 1, "type": "span_panel/panel_topology", "device_id": device_id}
)

connection.send_error.assert_not_called()
circuits: dict[str, dict[str, object]] = connection.send_result.call_args.args[1]["circuits"]
result: object = connection.send_result.call_args.args[1]
assert isinstance(result, dict)
return result


async def _ask_topology(hass: HomeAssistant, device_id: str) -> dict[str, dict[str, object]]:
"""Answer the topology for the panel whose device registry ID is `device_id`, and return its circuits."""
circuits = (await _topology_result(hass, device_id))["circuits"]
assert isinstance(circuits, dict)
return circuits


Expand Down Expand Up @@ -684,6 +693,58 @@ async def test_sub_devices_included(self, hass: HomeAssistant):
bess_entities = result["sub_devices"][bess_device.id]["entities"]
assert "sensor.span_panel_battery_level" in bess_entities

@pytest.mark.parametrize(
("name_by_user", "expected"),
[(None, PANEL_NAME), ("Garage Panel", "Garage Panel")],
ids=["not_renamed", "renamed"],
)
async def test_topology_names_the_panel_as_home_assistant_does(
self, hass: HomeAssistant, name_by_user: str | None, expected: str
) -> None:
"""`device_name` is the name the user gave the panel's device, else the integration's.

A rename in Home Assistant is stored in `name_by_user` and leaves `name`
as the integration registered it. The card titles itself from
`device_name`, so reading `name` alone kept the default title after a
rename, and two panels the user had told apart showed the same one.
"""
snapshot = SpanPanelSnapshotFactory.create(serial_number="sp3-242424-001")
panel_device_id = await _panel_holding(hass, snapshot, {})
dr.async_get(hass).async_update_device(panel_device_id, name_by_user=name_by_user)

result = await _topology_result(hass, panel_device_id)

assert result["device_name"] == expected

@pytest.mark.parametrize(
("name_by_user", "expected"),
[(None, "SPAN Panel Battery"), ("Backup Battery", "Backup Battery")],
ids=["not_renamed", "renamed"],
)
async def test_topology_names_each_sub_device_as_home_assistant_does(
self, hass: HomeAssistant, name_by_user: str | None, expected: str
) -> None:
"""A sub-device's record carries the name the user gave its device, else the integration's.

The card names each sub-device's tile from its record, so a rename in
Home Assistant reaches the tile the way it reaches the device list.
"""
serial = "sp3-242424-001"
snapshot = SpanPanelSnapshotFactory.create(
serial_number=serial,
battery=SpanBatterySnapshotFactory.create(soe_percentage=85.0),
)
panel_device_id = await _panel_holding(hass, snapshot, {})
battery = _register_sub_device(
hass, "span_entry", f"{serial}_bess", "SPAN Panel Battery", panel_device_id
)
dr.async_get(hass).async_update_device(battery.id, name_by_user=name_by_user)

sub_devices = (await _topology_result(hass, panel_device_id))["sub_devices"]

assert isinstance(sub_devices, dict)
assert sub_devices[battery.id]["name"] == expected

@pytest.mark.asyncio
async def test_evse_feed_circuit_entities_found(self, hass: HomeAssistant):
"""EVSE feed circuit sensor entities are found even though they live on the EVSE device."""
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading