Using websocket matter server to query/control matter-enabled lights/sensors via a HTTP GET interface.
Project description
Matter Web Controller
This document explains how the local Matter device management system works using a web interface.
System Architecture
The system separates background tasks and simplifies network rules to make it easier to use:
- Background Process: The app runs the standard
python-matter-serveras a separate background task. This keeps the heavy work away from the web server. - Event-Driven Caching & Offline-First: The web server subscribes to device events and maintains local JSON/text caches (
devices_cache.txt,occupancy_cache.json, andnames_cache.json). The caches are hydrated immediately upon server startup to ensure seamless continuity and non-blocking, immediate API responses. - HTTP Setup: The web server acts as a middleman. It changes complex WebSocket data into simple HTTP requests (GET/POST). Users only need to communicate via standard web addresses to interact with JSON data.
Requirements
Python 3.12 or newer.
Installation
Create a virtual environment and install the package using your package manager. This will automatically install required tools like aiohttp and home-assistant-chip-core.
How to Run
Start the system by typing the executable command matter-srv. You can use the --port parameter to set the web server port. The default is 8080. The background Matter server will automatically use the next port number.
API Endpoints
Note on Device IDs and Aliases: All devices use a standardized composite ID format: dev_{node_id}_{endpoint_id}. You can assign unique human-readable names (aliases) to devices using the /api/name endpoint. These names can be used interchangeably with the standard ID in all control and query APIs.
Get all cached devices
- URL:
/api/devices - Method:
GET - Description: Retrieves the complete list of all devices, their assigned names, and raw states directly from the local cache.
- Example:
http://localhost:8080/api/devices
Get lighting device status
- URL:
/api/lights - Method:
GET - Description: Retrieves cached lighting states. The data includes the standardized ID, an array of assigned names, power state, normalized brightness level (0.0 to 1.0), and color temperature (in Kelvin).
- Example:
http://localhost:8080/api/lights
Get sensor device status
- URL:
/api/sensors - Method:
GET - Description: Retrieves aggregated sensor states from the cache. Includes standardized ID, an array of assigned names, and a human-readable timestamp (
occupancy_last_active) for occupancy sensors. - Example:
http://localhost:8080/api/sensors
Get specific sensor status
- URL:
/api/sensor - Method:
GET - Description: Retrieves the state and formatted occupancy history for a specific sensor.
- Parameters:
id(string, required): The standardized ID or assigned name of the device.
- Example:
http://localhost:8080/api/sensor?id=LivingRoomSensor
Assign a name to a device
- URL:
/api/name - Method:
GETorPOST - Description: Assigns a unique alias to a device. The system enforces global uniqueness for each name across all devices.
- Parameters / JSON Body:
id(string, required): The standard ID or existing name of the device.name(string, required): The new unique name to assign.
- Example (POST):
curl -X POST -H "Content-Type: application/json" -d '{"id": "dev_1_8", "name": "Living Room Light"}' http://localhost:8080/api/name
Commission a new Matter device
- URL:
/api/register - Method:
GET - Description: Initiates the commissioning process for a new device on the local network.
- Parameters:
code(string, required): The Matter setup payload code.ip(string, optional): The IP address of the device for direct network commissioning.name(string, optional): A pending name to assign to the device upon successful commissioning.
- Example:
http://localhost:8080/api/register?code=11223344556&name=KitchenLight
Control a lighting device
- URL:
/api/set - Method:
GETorPOST - Description: Controls the brightness and color temperature of a specific lighting device.
- Parameters / JSON Body:
id(string, required): The standardized ID or assigned name (e.g.,dev_1_8orLiving Room Light).brightness(float, optional): The desired brightness level from 0.0 to 1.0. Setting to 0.0 powers off the device.temperature(integer, optional): The desired color temperature in Kelvin.
- Example (POST):
curl -X POST -H "Content-Type: application/json" -d '{"id": "Living Room Light", "brightness": 0.8, "temperature": 4000}' http://localhost:8080/api/set
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matter_web_controller-0.8.0.tar.gz.
File metadata
- Download URL: matter_web_controller-0.8.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98b697646191fadea39c92eed8eac404153b3be07f6434435a4276f7642ad092
|
|
| MD5 |
4590a6cd646a7112fd90d05aa7dbff19
|
|
| BLAKE2b-256 |
982a4f2947bcca8464d3945dcb9e1e45202550f3f5f4ff189fd79b480cfcad87
|
Provenance
The following attestation bundles were made for matter_web_controller-0.8.0.tar.gz:
Publisher:
python-publish.yml on dongnh/matter_webcontrol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matter_web_controller-0.8.0.tar.gz -
Subject digest:
98b697646191fadea39c92eed8eac404153b3be07f6434435a4276f7642ad092 - Sigstore transparency entry: 1002538622
- Sigstore integration time:
-
Permalink:
dongnh/matter_webcontrol@679c361a8a4d03a7daeeb5cc8273836c840a37ae -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/dongnh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@679c361a8a4d03a7daeeb5cc8273836c840a37ae -
Trigger Event:
release
-
Statement type:
File details
Details for the file matter_web_controller-0.8.0-py3-none-any.whl.
File metadata
- Download URL: matter_web_controller-0.8.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad0974534dfd5711786ffba134f9ee413dd1f2f33fbcc4db3c3a52893332c009
|
|
| MD5 |
bf1dcc2eb7a5b4616c3dfd6c2f2b94e4
|
|
| BLAKE2b-256 |
f5a1c12d6072110d882f9785ccfe06d246e00ed41b8c64c0522cc46a4b9bd814
|
Provenance
The following attestation bundles were made for matter_web_controller-0.8.0-py3-none-any.whl:
Publisher:
python-publish.yml on dongnh/matter_webcontrol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
matter_web_controller-0.8.0-py3-none-any.whl -
Subject digest:
ad0974534dfd5711786ffba134f9ee413dd1f2f33fbcc4db3c3a52893332c009 - Sigstore transparency entry: 1002538673
- Sigstore integration time:
-
Permalink:
dongnh/matter_webcontrol@679c361a8a4d03a7daeeb5cc8273836c840a37ae -
Branch / Tag:
refs/tags/v0.7.0 - Owner: https://github.com/dongnh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@679c361a8a4d03a7daeeb5cc8273836c840a37ae -
Trigger Event:
release
-
Statement type: