Skip to content

feat(python-client): get_network_topology + network_topology_updated (schema 13) - #917

Open
MindFreeze wants to merge 4 commits into
matter-js:mainfrom
MindFreeze:matter-python-network-topology
Open

feat(python-client): get_network_topology + network_topology_updated (schema 13)#917
MindFreeze wants to merge 4 commits into
matter-js:mainfrom
MindFreeze:matter-python-network-topology

Conversation

@MindFreeze

Copy link
Copy Markdown
Contributor

Python client counterpart of #832, for the Matter network visualization work in OpenHomeFoundation roadmap #210. Targets the next matter-python-client release (0.8.0), which Home Assistant core will consume.

What's here

  • Typed wire modelsNetworkTopology / NetworkTopologyNode / NetworkTopologyConnection / TopologyDirectionInfo dataclasses matching the schema-13 wire contract. kind / role / strength are open string sets (not enums) so a newer server introducing values can never break dataclass_from_dict parsing.
  • get_network_topology(refresh=False) — gated with require_schema=13 (raises ServerVersionTooOld against older servers); issuing it also opts the connection in to topology pushes, per the server contract.
  • Typed event parsingnetwork_topology_updated reaches subscribers as a parsed NetworkTopology (EventType.NETWORK_TOPOLOGY_UPDATED).

The client baseline SCHEMA_VERSION stays 11 — per-command gating is the feature gate, so the client keeps working against schema-11/12 servers.

Testing

ruff / mypy clean; unit tests cover command translation + refresh passthrough, the schema-12 rejection path, forward-compat parsing (unknown fields and enum-like values), and typed event dispatch. The full python integration suite stays green.

Also verified live against a server build from #832: connect (schema 13) → empty typed graph → import_test_node fixtures → network_topology_updated push parsed into NetworkTopology (18 nodes / 16 connections with per-direction LQI/RSSI) → refresh=True round-trip.

…ted (schema 13)

Client counterpart of the server-side network topology API: typed
NetworkTopology / node / connection / direction dataclasses (kind, role and
strength stay open string sets so newer servers can't break parsing),
get_network_topology(refresh=) gated on require_schema=13, and typed
parsing of the network_topology_updated event.
Copilot AI review requested due to automatic review settings July 23, 2026 05:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds schema-13 network topology support to the Python client, matching the server-side get_network_topology API and typed network_topology_updated event so downstream consumers (e.g., Home Assistant) can consume a parsed topology graph.

Changes:

  • Introduces typed wire dataclasses for the schema-13 network topology payload (NetworkTopology*, TopologyDirectionInfo) and adds the new command/event constants.
  • Adds MatterClient.get_network_topology(refresh=False) gated with require_schema=13, returning a typed NetworkTopology.
  • Parses network_topology_updated into a typed NetworkTopology in event dispatch, with unit tests covering gating, passthrough, forward-compat parsing, and typed event delivery.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
python_client/matter_server/common/models.py Adds schema-13 network topology dataclasses and registers new EventType / APICommand values.
python_client/matter_server/client/client.py Implements get_network_topology() (schema-gated) and typed parsing/dispatch of network_topology_updated.
python_client/tests/test_network_topology.py Adds unit tests for command construction, schema gating behavior, forward-compatible parsing, and typed event handling.

Comment thread python_client/matter_server/common/models.py Outdated
Copilot AI review requested due to automatic review settings July 23, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@MindFreeze
MindFreeze marked this pull request as ready for review July 23, 2026 13:00
Copilot AI review requested due to automatic review settings July 30, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@Apollon77 Apollon77 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed alongside #832. This side is clean — the open-string-set choice for kind/role/strength, the unknown-key forward-compat test, and the per-command require_schema=13 gate (baseline staying at 11) are all the right calls, and the schema-12 rejection test actually proves the gate rather than assuming it.

Two non-blocking notes:

  1. Merge order: require_schema=13 is hardcoded while main still reports SCHEMA_VERSION = 12, so this has to land after #832 (which bumps it and updates python_client/tests/test_integration.py). No file overlap between the two, so no conflict either way.
  2. refresh=True is expensive server-side, and #832 currently has no in-flight coalescing (each caller fans out reads to every online node). Callers polling it would multiply that. Docstring note below.

Copilot's strength-in-docstring remark is already addressed in the current head.

Comment thread python_client/matter_server/client/client.py
…ollable

The refresh path costs a per-node attribute read fan-out on the server, so it is
a user-initiated action; the push event is the source for keeping a graph current.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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.

3 participants