Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ac52387
feat(models): say whether a circuit declares a breaker rating
cayossarian Oct 21, 2026
2f3584c
feat(models): say whether a panel publishes shared meters
cayossarian Nov 12, 2026
b700808
chore(release): span-panel-api 3.9.0b1 and schema-1 1.5.0b1
cayossarian Nov 10, 2026
1d85404
fix(mqtt): subscribe each broker session once
cayossarian Nov 12, 2026
cc80bbb
fix(mqtt): stop a closed connect() and refuse malformed subscriptions
cayossarian Nov 12, 2026
a266c4c
fix(mqtt): keep AsyncMqttBridge.subscribe(), held on every session
cayossarian Nov 12, 2026
d28a5e8
fix(models): read publishes_shared_meters as unknown where the adapte…
cayossarian Nov 12, 2026
25b3b6b
fix(mqtt): end connect()'s waits on close() and notice a disconnect m…
cayossarian Nov 12, 2026
bf7f5f1
fix(mqtt): ignore a let-go client's disconnect and keep the client a …
cayossarian Nov 12, 2026
456d2ad
fix(mqtt): leave a client to the thread inside paho until its blockin…
cayossarian Nov 12, 2026
8938cdd
docs(changelog): describe the 3.9.0b2 fixes under 3.9.0
cayossarian Nov 12, 2026
becd7ea
test(mqtt): wait for the parser in test_close rather than a fixed sleep
cayossarian Nov 12, 2026
0611df9
test(mqtt): wait for the parser in the rest of test_mqtt_connect_flow
cayossarian Nov 12, 2026
8f0ed28
test: wait for the parser wherever a test feeds a background connect()
cayossarian Nov 12, 2026
36dbb41
fix(mqtt): keep the loop out of a client until its blocking call returns
cayossarian Nov 13, 2026
62c91e7
fix(mqtt): let a let-go client's socket close change only that socket
cayossarian Nov 13, 2026
6f03731
fix(mqtt): tell a bridge's user it disconnected when it disconnects
cayossarian Nov 13, 2026
27f7a7e
fix(mqtt): take only an integer QoS in AsyncMqttBridge.subscribe()
cayossarian Nov 13, 2026
fff3b23
fix(mqtt): end connect()'s ready wait when connect() is cancelled
cayossarian Nov 13, 2026
d461d79
fix(mqtt): close what a rebuild's failed connect left of the new client
cayossarian Nov 13, 2026
3860d73
refactor(mqtt): drop connect()'s abandon check after the executor
cayossarian Nov 13, 2026
75a2c5f
test(mqtt): wait for the hand-back rather than counting loop turns
cayossarian Nov 13, 2026
3ab3d15
fix(mqtt): never unwatch a socket by a descriptor number it may no lo…
cayossarian Nov 13, 2026
c3f2af5
fix(mqtt): keep a stopped misc timer from reading as a running one
cayossarian Nov 13, 2026
ba9c7d4
test(mqtt): pin the hand-back's event order, its callback swap and th…
cayossarian Nov 13, 2026
878f682
test(mqtt): type the raising remove_reader stand-in as the loop's own
cayossarian Nov 13, 2026
250ec15
test(mqtt): wait on conditions where the session tests counted loop t…
cayossarian Nov 13, 2026
62a9b2f
style(mqtt): rewrap the hand-back's docstring
cayossarian Nov 13, 2026
e4364e1
test(mqtt): hold the real-socket reconnects to a clean hand-back, and…
cayossarian Nov 13, 2026
9dff638
fix(mqtt): answer a blocking call's caller however its hand-back goes
cayossarian Nov 13, 2026
d066d83
docs(changelog): record that subscribe() sends once per topic, and se…
cayossarian Nov 13, 2026
7d6fff1
chore(release): span-panel-api 3.9.0b2
cayossarian Nov 12, 2026
6ec6c2f
chore(release): span-panel-api 3.9.0 and schema-1 1.5.0
cayossarian Nov 16, 2026
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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Pre-releases are not listed separately. A beta is a step towards the next public version, so its changes are folded into that version's entry as they land and are described against the **last public release**, never against the beta before it. What one
beta corrected in an earlier beta does not appear at all: from the point of view of somebody upgrading between released versions, it never happened.

## [3.9.0]

Snapshots say whether a circuit declares a breaker rating and whether a panel publishes shared meters, and each broker connection subscribes once.

### Added

- **`SpanCircuitSnapshot.breaker_rating_declared`** says whether a circuit declares a breaker rating, so a consumer can tell a rating the panel does not publish from one that has not arrived yet; `None` where the adapter does not say.
- **`SpanPanelSnapshot.publishes_shared_meters`** says whether any circuit declares `meter/shared-with-device-ids`, so a consumer can tell a panel that describes its multi-load breakers from one, such as MAIN 32, that publishes each as a single circuit;
`None` where the adapter does not say, as with `span-panel-api-schema-0` or a `span-panel-api-schema-1` older than 1.5.0.
- **`AsyncMqttBridge.set_subscriptions()` sets the topics every connection the bridge opens is subscribed to**, replacing what it set before and never dropping a topic `subscribe()` added.

### Changed

- **`AsyncMqttBridge.subscribe()` sends nothing for a topic the bridge already holds at that QoS or higher**, where every call sent a SUBSCRIBE and the broker replayed the topic's retained messages each time.
- **The `schema-1` extra requires `span-panel-api-schema-1` 1.5.0 or newer**, the adapter that fills `breaker_rating_declared` and `publishes_shared_meters`.

### Fixed

- **Each broker connection subscribes once, so the panel's retained tree arrives once per connection**, where `connect()` subscribed twice and received the whole tree twice, and a panel that changes schema generation while connected no longer has every
message under its own device delivered twice until the next reconnect.
- **`connect()` raises `SpanPanelConnectionError` when `close()` is called while it is connecting**, where it could carry on and return as if connected, raise `AttributeError`, or wait for the panel and report a timeout.
- **`AsyncMqttBridge.connect()` raises `SpanPanelConnectionError` when `disconnect()` is called while it is connecting**, where it could raise `AttributeError` or carry on and connect.
- **`AsyncMqttBridge.subscribe()` keeps its topic subscribed on every later connection**, where the subscription ended with the connection it was made on and was lost if made before the first.

## [3.8.0]

Snapshot fields that held a fabricated constant can now be unknown, and with `span-panel-api-schema-0` 1.3.0 and `span-panel-api-schema-1` 1.4.0 or newer the parsers report them as unknown and stop synthesising unoccupied positions.
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ All panel state is represented as immutable, frozen dataclasses:

- **`SpanPanelSnapshot`**: complete panel state. Identity (serial, firmware, vendor, model, hardware version), panel size, main breaker rating, main relay, door state, connection uptime on a flat panel, network links with the Wi-Fi SSID and vendor cloud,
grid and feedthrough power and energy, grid/DSM state, run configuration, dominant power source, grid islandability, per-leg voltages, power flows, lugs current and whether the lugs are the service entrance, busbar current, line frequency, the rating of
the protection ahead of the upstream lugs, the first and last breaker positions, whether any circuit declares what it feeds, shed policy and forecast. It holds `circuits`, `battery`, `pv`, `pv_inverters`, `evse`, `mid`, `pcs`, `adopted_devices` and
`extension_properties`.
- **`SpanCircuitSnapshot`**: one circuit. Id, name, relay state and requester, power, energy and their update times, tabs, 240 V, breaker rating, current, priority, user controllability, sheddable / never-backup / always-on flags, device type, relative
position, PCS management and priority, the `$target` pending state for relay and priority, nominal voltage, the breaker's protection functions, the role it declares for what it feeds, the other circuits its meter or relay is shared with, and whether it
is a meter outside the panel, which has no breaker space, relay or shed priority and reads import-positive.
the protection ahead of the upstream lugs, the first and last breaker positions, whether any circuit declares what it feeds or a shared meter, shed policy and forecast. It holds `circuits`, `battery`, `pv`, `pv_inverters`, `evse`, `mid`, `pcs`,
`adopted_devices` and `extension_properties`.
- **`SpanCircuitSnapshot`**: one circuit. Id, name, relay state and requester, power, energy and their update times, tabs, 240 V, breaker rating and whether it declares one, current, priority, user controllability, sheddable / never-backup / always-on
flags, device type, relative position, PCS management and priority, the `$target` pending state for relay and priority, nominal voltage, the breaker's protection functions, the role it declares for what it feeds, the other circuits its meter or relay is
shared with, and whether it is a meter outside the panel, which has no breaker space, relay or shed priority and reads import-positive.
- **`SpanBatterySnapshot`**: the BESS. Whether the panel declares one, SoE percentage and kWh, its own meter reading, communication state, link health, the circuit that feeds it, vendor / `model` / `part_number` / serial / version, nameplate capacity.
- **`SpanPVSnapshot`**: one PV inverter. Link health, vendor / `model` / serial / version, nameplate capacity (the array's DC size), feeding circuit, relative position, its wire `device_id` and its `node_id`, which is its key in `pv_inverters`.
`SpanPanelSnapshot.pv` is the lone inverter, or describes several together.
Expand Down
9 changes: 9 additions & 0 deletions packages/schema-1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ number. A release here means this parser changed, never that the panel did.

Pre-releases are not listed separately. A beta is a step towards the next public version, so its changes are folded into that version's entry as they land and are described against the last public release, never against the beta before it.

## [1.5.0]

Requires `span-panel-api` **3.9.0 or newer**, whose snapshots carry the fields this parser now fills.

### Added

- **Circuits report whether they declare a breaker rating** (`breaker_rating_declared`).
- **The snapshot reports whether any circuit declares a shared-meter list** (`publishes_shared_meters`).

## [1.4.0]

Requires `span-panel-api` **3.8.0 or newer**, whose snapshot fields accept the unknown values this parser now reports and carry the fields it now fills.
Expand Down
8 changes: 6 additions & 2 deletions packages/schema-1/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "span-panel-api-schema-1"
version = "1.4.0"
version = "1.5.0"
description = "Parent/child schema (data-model-version 1.x) parser for span-panel-api"
authors = [
{name = "SpanPanel"}
Expand Down Expand Up @@ -34,7 +34,11 @@ dependencies = [
# it, imports `device_id_order` from its models, implements the masked-tree
# protocol and types new in it, and relies on its client reading a cleared
# value as unpublished.
"span-panel-api>=3.8.0,<4.0",
# Raised to 3.9.0, the first bootstrap whose snapshots carry
# `SpanCircuitSnapshot.breaker_rating_declared` and
# `SpanPanelSnapshot.publishes_shared_meters`, which this parser fills.
# Against an earlier one, building a snapshot fails on those arguments.
"span-panel-api>=3.9.0,<4.0",
# Only this distribution depends on the eBus SDK. The bootstrap and
# schema-0 stay clean, so a flat-panel install never pulls it in — which is
# what bounds the release coupling this dependency introduces to panels on
Expand Down
3 changes: 3 additions & 0 deletions packages/schema-1/src/span_panel_api_schema_1/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ def build_circuit(
is_240v=None if poles is None else poles >= 2,
current_a=_number(device, NODE_METER, PROP_CURRENT),
breaker_rating_a=_number(device, NODE_BREAKER, PROP_RATING),
# The declaration, not the value: a rating that has not arrived yet
# reads as `None` above whether or not the panel will ever publish one.
breaker_rating_declared=PROP_RATING in node_properties(device, NODE_BREAKER),
# A relay locked closed. A device with no relay is not "on" at all.
always_on=declares_node(device, NODE_SWITCH) and not relay_controllable,
relay_requester=_text(device, NODE_SWITCH, PROP_RELAY_REQUESTER, UNKNOWN),
Expand Down
5 changes: 5 additions & 0 deletions packages/schema-1/src/span_panel_api_schema_1/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
from span_panel_api_schema_1.const import (
NODE_CONNECTION,
NODE_INFO,
NODE_METER,
PROP_FEEDS_DEVICE_ID,
PROP_FEEDS_ROLE,
PROP_MODEL,
PROP_SERIAL_NUMBER,
PROP_SHARED_WITH_DEVICE_IDS,
TYPE_BESS,
TYPE_CIRCUIT,
TYPE_EVSE,
Expand Down Expand Up @@ -289,6 +291,9 @@ def build_snapshot(panel: DiscoveredDevice, children: list[DiscoveredDevice]) ->
publishes_solar_roles=any(
PROP_FEEDS_ROLE in node_properties(circuit, NODE_CONNECTION) for circuit in roles.circuits
),
publishes_shared_meters=any(
PROP_SHARED_WITH_DEVICE_IDS in node_properties(circuit, NODE_METER) for circuit in roles.circuits
),
shed_policy=fields.shed_policy,
shed_policy_algorithm=fields.shed_policy_algorithm,
shed_soc_threshold_shed_percent=fields.shed_soc_threshold_shed_percent,
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "span-panel-api"
version = "3.8.0"
version = "3.9.0"
description = "A client library for SPAN Panel API"
authors = [
{name = "SpanPanel"}
Expand Down Expand Up @@ -71,7 +71,10 @@ schema-0 = ["span-panel-api-schema-0>=1.3.0"]
# Raised to 1.4.0 for 3.8.0: for the same reason as schema-0's, and because that
# adapter fills the snapshot fields this bootstrap adds and exports the masked
# device tree.
schema-1 = ["span-panel-api-schema-1>=1.4.0"]
# Raised to 1.5.0 for 3.9.0: a 1.4.x adapter is still accepted, but it leaves
# `breaker_rating_declared` and `publishes_shared_meters` unknown, and 1.5.0 is
# the adapter that fills them.
schema-1 = ["span-panel-api-schema-1>=1.5.0"]

[project.urls]
Homepage = "https://github.com/SpanPanel/span-panel-api"
Expand Down
20 changes: 20 additions & 0 deletions src/span_panel_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class SpanCircuitSnapshot:
is_240v: bool | None = False
current_a: float | None = None
breaker_rating_a: float | None = None
# Whether the circuit's description declares a breaker rating, as distinct
# from whether its value has arrived. `True`: declared, so `breaker_rating_a`
# is `None` only until the retained value lands. `False`: the panel
# publishes no rating for this circuit. `None`: the adapter does not say
# (flat, REST, a hand-built snapshot) and the consumer must treat it as
# not known, never as `False`.
breaker_rating_declared: bool | None = None
always_on: bool = False # v2 new: circuit/always-on
relay_requester: str = "UNKNOWN" # v2 new: circuit/relay-requester
# Epoch seconds at which the reading last changed, as received over MQTT.
Expand Down Expand Up @@ -1340,6 +1347,19 @@ class SpanPanelSnapshot:
which declares no roles.
"""

publishes_shared_meters: bool | None = None
"""Whether any circuit declares `meter/shared-with-device-ids`, or `None` where the adapter does not say.

The declaration decides, not the value: a panel model that describes its
multi-load breakers declares the list on every circuit, a standard breaker
included, and publishes a value only where a meter is shared. Such a panel
publishes each circuit of a multi-load breaker as its own device with its
own rating. `False` where no circuit declares the list, as on MAIN 32.
`None` where the adapter does not answer -- the flat schema's, one older
than this field, a hand-built snapshot -- and the consumer must treat it as
not known, never as `False`.
"""

# `shed/policy`, v1.0 only: how the panel decides what to shed, and the two
# SoC thresholds that make its behaviour predictable. The wire carries one
# `json` document; these are the parsed answer plus the document itself.
Expand Down
Loading
Loading