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
26 changes: 22 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ All notable changes to this project will be documented in this file.
- **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.

- **Current monitoring notifications now name a circuit by the name you gave it in Home Assistant, including through `{name}` in a custom title or message**,
where they used its name in the SPAN app; the `span_panel_current_alert` event carries that name in a new `alert_display_name` field and leaves `alert_name`
as it was.

- **The Get monitoring status action now fails with an error when the panel it is asked about has not finished loading, such as while Home Assistant starts, or
when the config entry it names is not a SPAN Panel's**, where it answered that monitoring was off, so a script step that calls it then stops unless it is set
to continue on error, and Home Assistant logs the error.

- **Changing a panel's current monitoring while the panel is not loaded, or naming a config entry that is not a SPAN Panel's, now fails with an error, turning
monitoring off included**, where turning it off reported success and left monitoring to start again once the panel loaded, and turning it on, changing its
settings or a threshold named by circuit id or leg, or sending a test notification said monitoring was not enabled.

- **The `{entity_id}` placeholder in a current monitoring notification's title or message now carries the entity ID of the circuit's Current sensor, or its
Power sensor where it has none, or of the mains leg's Current sensor**, where it carried the circuit's internal id or the leg's name.

- **Current monitoring turned off now stays off after Home Assistant restarts on a panel whose options still hold the monitoring switch an earlier release
stored there**, where it came back on at every restart.

## [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 Expand Up @@ -72,8 +90,8 @@ setting and favorite across to them, and each entity keeps its entity ID and his
- **A panel reloads once, not twice, after reauthentication, reconfiguration or re-pinning its certificate authority.** Reconfiguring no longer logs Home
Assistant's warning that the integration "has an update listener and should use it for scheduling a reload".

- **A reload no longer starts in the middle of the panel's own update**, and a change that nothing in the integration reads, such as the system option for
new entities, or a rediscovery that changes nothing, no longer reloads the panel.
- **A reload no longer starts in the middle of the panel's own update**, and a change that nothing in the integration reads, such as the system option for new
entities, or a rediscovery that changes nothing, no longer reloads the panel.

- **A change made while a panel is setting up is applied.** An options save that landed during setup was stored but not used until the next restart, and a
reconfigure completed while the panel was retrying waited for Home Assistant's next retry, up to ten minutes later. Both now reload the panel straight away.
Expand All @@ -99,8 +117,8 @@ Home Assistant 2026.11.

### Fixed

- **Discovering or adding a panel no longer logs a warning that its credentials are being sent over plaintext HTTP**, which the schema read that set it off never
carries.
- **Discovering or adding a panel no longer logs a warning that its credentials are being sent over plaintext HTTP**, which the schema read that set it off
never carries.

## [2.3.1] - 11/2026

Expand Down
12 changes: 7 additions & 5 deletions custom_components/span_panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
DEFAULT_MQTTS_PORT,
DEFAULT_SNAPSHOT_INTERVAL,
DOMAIN,
ENABLE_CURRENT_MONITORING,
PANEL_CA_PENDING,
)
from .control_gate import ControlGate, ControlLock, ControlPolicy
Expand All @@ -90,7 +89,11 @@
)
from .coordinator import SpanPanelCoordinator
from .curation import async_forget_curation, async_load_curation
from .current_monitor import CurrentMonitor, async_forget_monitoring
from .current_monitor import (
CurrentMonitor,
async_adopt_legacy_enable_option,
async_forget_monitoring,
)
from .device_id_rekey import async_migrate_device_ids, entry_holds_old_ids
from .entry_issues import async_clear_unlinked_issues, entry_removed
from .entry_reloads import (
Expand Down Expand Up @@ -914,9 +917,8 @@ async def _async_setup_entry(hass: HomeAssistant, entry: SpanPanelConfigEntry) -

await coordinator.async_setup_streaming()

if entry.options.get(
ENABLE_CURRENT_MONITORING, False
) or await CurrentMonitor.async_is_enabled(hass, entry):
await async_adopt_legacy_enable_option(hass, entry)
if await CurrentMonitor.async_is_enabled(hass, entry):
# Held, not judged: the first judgement, and any alert it raises,
# is the next update's.
monitor = CurrentMonitor(
Expand Down
56 changes: 42 additions & 14 deletions custom_components/span_panel/alert_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
def format_notification(
*,
alert_type: str,
alert_name: str,
alert_id: str,
display_name: str,
entity_id: str,
current_a: float,
monitoring_rating_a: float,
threshold_pct: int,
Expand All @@ -52,13 +52,22 @@ def format_notification(
) -> tuple[str, str]:
"""Format notification title and message using templates.

`monitoring_rating_a` is the rating the point was judged against, which the
`{breaker_rating_a}` placeholder carries.
`display_name` is the point's name as Home Assistant shows it, which the
`{name}` placeholder carries, and `entity_id` the entity it is shown under,
which `{entity_id}` carries. `monitoring_rating_a` is the rating the point
was judged against, which the `{breaker_rating_a}` placeholder carries.

Available placeholders:
{name} - The circuit's name in the SPAN app, or the mains leg
{name} - The circuit's name as Home Assistant shows it: the
name the user gave its device, else the name the
device is registered under, those of circuits that
share a meter joined with " + "; or the mains leg
(e.g. "Mains Upstream L1")
{entity_id} - Entity ID (e.g. sensor.kitchen_current)
{entity_id} - The entity ID of the circuit's Current sensor, or
its Power sensor where it has none, that of the
circuit `alert_id` names for circuits that share a
meter; for the mains, the leg's Current sensor
(e.g. sensor.kitchen_current)
{alert_type} - "spike" or "continuous_overload"
{current_a} - Current draw in amps (e.g. 18.3)
{breaker_rating_a}- The rating in amps the circuit is judged against (e.g. 20):
Expand All @@ -73,8 +82,8 @@ def format_notification(
"""
window_m = (window_duration_s or 0) // 60
template_vars = {
"name": alert_name,
"entity_id": alert_id,
"name": display_name,
"entity_id": entity_id,
"alert_type": alert_type,
"current_a": f"{current_a:.1f}",
"breaker_rating_a": f"{monitoring_rating_a:.0f}",
Expand All @@ -86,12 +95,12 @@ def format_notification(
try:
title = title_template.format_map(template_vars)
except (KeyError, ValueError):
title = f"SPAN: {alert_name} {alert_type}"
title = f"SPAN: {display_name} {alert_type}"
try:
message = message_template.format_map(template_vars)
except (KeyError, ValueError):
message = (
f"{alert_name} at {current_a:.1f}A "
f"{display_name} at {current_a:.1f}A "
f"({utilization_pct}% of {monitoring_rating_a:.0f}A rating) at {local_time or ''}"
)
return title, message
Expand Down Expand Up @@ -163,7 +172,9 @@ def dispatch_alert(
*,
alert_type: str,
alert_name: str,
display_name: str,
alert_id: str,
entity_id: str,
alert_source: str,
current_a: float,
breaker_rating_a: float | None,
Expand All @@ -179,6 +190,15 @@ def dispatch_alert(
) -> None:
"""Dispatch alert through all enabled notification channels.

`alert_name` is the panel's name for the point and `display_name` the name
Home Assistant shows for it, the user's where they renamed the circuit's
device. The event carries both, as `alert_name` and `alert_display_name`:
automations read `alert_name`, so a rename in Home Assistant never changes
it. The title and message are read by a person, so their `{name}` is the
name that person finds the circuit under. `alert_id` is the point's id,
which the event carries, and `entity_id` the entity the point is shown
under, which only the text's `{entity_id}` carries.

The event payload carries the ratings as `get_monitoring_status` does:
`breaker_rating_a` is the panel's rating (a shared meter's capacity over its
members' ratings, None if any is unknown), `monitoring_rating_a` the rating the
Expand All @@ -199,6 +219,7 @@ def dispatch_alert(
"alert_source": alert_source,
"alert_id": alert_id,
"alert_name": alert_name,
"alert_display_name": display_name,
"alert_type": alert_type,
"current_a": round(current_a, 1),
"breaker_rating_a": breaker_rating_a,
Expand Down Expand Up @@ -227,8 +248,8 @@ def dispatch_alert(

title, message = format_notification(
alert_type=alert_type,
alert_name=alert_name,
alert_id=alert_id,
display_name=display_name,
entity_id=entity_id,
current_a=current_a,
monitoring_rating_a=monitoring_rating_a,
threshold_pct=threshold_pct,
Expand Down Expand Up @@ -274,7 +295,13 @@ def dispatch_test_alert(
"""Dispatch a test notification using sample values through all enabled channels."""
alert_type = "spike"
alert_name = "Kitchen Oven"
# The sample circuit is one nobody renamed, so Home Assistant shows it by
# the panel's name.
display_name = alert_name
alert_id = "sensor.kitchen_oven_current"
# The sample's id has always been its sensor's entity ID, so the text's
# `{entity_id}` carries the same one.
entity_id = alert_id
alert_source = "circuit"
current_a = 18.3
breaker_rating_a = 20.0
Expand All @@ -296,6 +323,7 @@ def dispatch_test_alert(
"alert_source": alert_source,
"alert_id": alert_id,
"alert_name": alert_name,
"alert_display_name": display_name,
"alert_type": alert_type,
"current_a": current_a,
"breaker_rating_a": breaker_rating_a,
Expand All @@ -316,8 +344,8 @@ def dispatch_test_alert(

title, message = format_notification(
alert_type=alert_type,
alert_name=alert_name,
alert_id=alert_id,
display_name=display_name,
entity_id=entity_id,
current_a=current_a,
monitoring_rating_a=monitoring_rating_a,
threshold_pct=threshold_pct,
Expand Down
1 change: 0 additions & 1 deletion custom_components/span_panel/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
"""The config flow's starting choice for a new install, which it stores."""

# Current monitoring configuration
ENABLE_CURRENT_MONITORING = "enable_current_monitoring"
DEFAULT_CONTINUOUS_THRESHOLD_PCT = 80
DEFAULT_SPIKE_THRESHOLD_PCT = 100
DEFAULT_WINDOW_DURATION_M = 15
Expand Down
Loading