diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index fea0cb84..97551892 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,4 +1,4 @@
-blank_issues_enabled: true
+blank_issues_enabled: false
contact_links:
- name: I have an issue or bug regarding using Matter with Home Assistant
url: https://github.com/home-assistant/core/issues?q=is:issue+is:open+label:%22integration:+matter%22
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md
new file mode 100644
index 00000000..cbe8b6cc
--- /dev/null
+++ b/.github/copilot-instructions.md
@@ -0,0 +1,252 @@
+# Python Matter Server
+
+Python Matter Server is an officially certified Software Component that provides Matter controller support. It serves as the foundation for Matter support in Home Assistant and other projects. The server implements a Matter Controller over WebSockets using the official Matter SDK.
+
+**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**
+
+## Working Effectively
+
+### Bootstrap and Setup
+- **CRITICAL**: Matter Server requires Linux or macOS with specific IPv6 networking configuration. Windows/WSL is NOT supported.
+- Set up the complete development environment:
+ ```bash
+ scripts/setup.sh
+ ```
+ - Creates Python virtual environment in `.venv/`
+ - Installs Python dependencies including Matter SDK components
+ - Installs pre-commit hooks for code quality
+ - **TIMING**: Typically takes 3-5 minutes. NEVER CANCEL - wait up to 10 minutes for completion.
+ - **NETWORK ISSUE**: If pip install fails with timeout errors (common with Matter SDK dependencies), this is due to network limitations, not code issues.
+
+### Python Server Development
+- **Always run the bootstrapping steps first before any Python development**
+- Start the Matter server:
+ ```bash
+ # Basic server (info log level)
+ python -m matter_server.server
+
+ # Debug mode
+ python -m matter_server.server --log-level debug
+
+ # SDK debug mode
+ python -m matter_server.server --log-level-sdk progress
+ ```
+- Create `/data` directory with proper permissions if it doesn't exist
+- Server runs on port 5580 by default (WebSocket endpoint)
+- Alternative entry point: `python main.py`
+
+### Dashboard Development
+- **Dashboard setup** (requires Python dependencies to be available):
+ ```bash
+ cd dashboard
+ script/setup
+ ```
+ - Runs `npm install` (~15 seconds)
+ - Generates descriptions file from Python source
+ - **TIMING**: ~30 seconds total. NEVER CANCEL - set timeout to 2+ minutes.
+
+- **Development server**:
+ ```bash
+ cd dashboard
+ script/develop
+ ```
+ - Starts TypeScript compiler in watch mode
+ - Starts development server on http://localhost:5010
+ - Live reload for development changes
+ - **TIMING**: Starts in ~5 seconds
+
+- **Production build**:
+ ```bash
+ cd dashboard
+ script/build
+ ```
+ - Builds optimized TypeScript/JavaScript bundle
+ - Copies build to `matter_server/dashboard/` directory
+ - **TIMING**: ~10 seconds. NEVER CANCEL - set timeout to 2+ minutes.
+
+### Testing and Code Quality
+- **Run complete test suite**:
+ ```bash
+ scripts/run-in-env.sh pytest --durations 10 --cov-report term-missing --cov=matter_server --cov-report=xml tests/
+ ```
+ - **TIMING**: Typically 2-3 minutes. NEVER CANCEL - set timeout to 10+ minutes.
+
+- **Pre-commit validation** (REQUIRED before commits):
+ ```bash
+ SKIP=no-commit-to-branch pre-commit run --all-files
+ ```
+ - Runs ruff (linting + formatting), pylint, mypy, codespell, and other checks
+ - **TIMING**: 1-2 minutes for all files. NEVER CANCEL - set timeout to 5+ minutes.
+
+- **Individual linting tools**:
+ ```bash
+ scripts/run-in-env.sh ruff check --fix
+ scripts/run-in-env.sh ruff format
+ scripts/run-in-env.sh pylint matter_server/ tests/
+ scripts/run-in-env.sh mypy
+ ```
+
+## Validation Scenarios
+
+**ALWAYS manually validate changes using complete end-to-end scenarios:**
+
+### Python Server Validation
+1. Start the server: `python -m matter_server.server --log-level debug`
+2. Verify WebSocket endpoint responds (server starts without errors)
+3. Check dashboard is accessible if built: verify `matter_server/dashboard/` contains files
+4. Test example client: `python scripts/example.py` (requires dependencies)
+
+### Dashboard Validation
+1. Build dashboard: `cd dashboard && script/build`
+2. Verify build artifacts: check `matter_server/dashboard/js/` contains compiled JavaScript
+3. Start development server: `cd dashboard && script/develop`
+4. Access http://localhost:5010 and verify dashboard loads
+5. Test WebSocket connection input (should prompt for server URL)
+
+### Pre-commit Validation
+**CRITICAL**: Always run before pushing changes or CI will fail:
+```bash
+SKIP=no-commit-to-branch pre-commit run --all-files
+```
+
+## Repository Structure
+
+### Key Directories
+```
+matter_server/ # Main Python package
+├── client/ # Matter client library
+├── server/ # Matter server implementation
+├── common/ # Shared utilities
+└── dashboard/ # Built web dashboard (auto-generated)
+
+dashboard/ # Dashboard source code (TypeScript/Lit)
+├── src/ # TypeScript source files
+├── script/ # Build and development scripts
+└── public/ # Static assets
+
+scripts/ # Development utilities
+├── setup.sh # Main environment setup
+├── example.py # Server/client example
+└── generate_descriptions.py # Generates dashboard type definitions
+
+tests/ # Test suite (pytest-based)
+docs/ # Documentation
+├── os_requirements.md # Operating system setup requirements
+├── docker.md # Docker deployment guide
+└── websockets_api.md # WebSocket API documentation
+```
+
+### Important Files
+- `pyproject.toml` - Python packaging and tool configuration
+- `main.py` - Alternative server entry point
+- `.pre-commit-config.yaml` - Code quality hooks configuration
+- `DEVELOPMENT.md` - Detailed development setup guide
+
+## Common Issues and Solutions
+
+### Network Timeouts During Setup
+**SYMPTOM**: `pip install` fails with `ReadTimeoutError` from PyPI
+**CAUSE**: Matter SDK dependencies are large and can timeout on slow connections
+**SOLUTION**:
+- Retry setup: `scripts/setup.sh`
+- Use `pip install --timeout 300` for extended timeout
+- **Document as known issue** if persistent
+
+### IPv6/Networking Issues
+**SYMPTOM**: Matter devices not discoverable or connection failures
+**REFERENCE**: See `docs/os_requirements.md` for complete networking requirements
+**KEY REQUIREMENTS**:
+- IPv6 support enabled on host interface
+- No multicast filtering on network equipment
+- Proper ICMPv6 Router Advertisement processing
+- For Thread devices: specific kernel options and sysctl settings
+
+### Pre-commit Hook Failures
+**SYMPTOM**: Git commits rejected due to formatting/linting issues
+**SOLUTION**:
+```bash
+SKIP=no-commit-to-branch pre-commit run --all-files
+scripts/run-in-env.sh ruff format # Fix formatting
+scripts/run-in-env.sh ruff check --fix # Fix linting issues
+```
+
+### Dashboard Build Issues
+**SYMPTOM**: `script/setup` fails with "No module named 'chip'"
+**CAUSE**: Python Matter SDK dependencies not installed
+**SOLUTION**: Run `scripts/setup.sh` first to install Python dependencies
+
+## Development Tips
+
+- **Always** activate virtual environment: `source .venv/bin/activate`
+- Use `scripts/run-in-env.sh` for consistent tool execution across environments
+- Dashboard development can proceed independently once built once
+- Server requires `/data` directory for persistent storage
+- Matter protocol requires specific OS and network configuration (see `docs/os_requirements.md`)
+- Example usage patterns available in `scripts/example.py`
+- WebSocket API documentation in `docs/websockets_api.md`
+
+## CI/CD Integration
+
+The project uses GitHub Actions (`.github/workflows/test.yml`):
+- Linting: pre-commit hooks on Python 3.12
+- Testing: pytest on Python 3.12 and 3.13
+- **Always ensure pre-commit passes locally** before pushing to avoid CI failures
+
+## Project Context
+
+This project implements both server and client components:
+- **Server**: Runs Matter Controller with WebSocket API
+- **Client**: Python library for consuming the WebSocket API (used by Home Assistant)
+- **Dashboard**: Web-based debugging and testing interface
+- **Architecture**: Allows multiple consumers to connect to same Matter fabric
+- **Deployment**: Available as Home Assistant add-on, Docker container, or standalone
+
+The separation enables scenarios where the Matter fabric continues running while consumers (like Home Assistant) restart or disconnect.
+
+## Linting and Code Quality Requirements
+
+**CRITICAL**: All code changes MUST pass linting checks before submitting PRs. The CI will fail if linting issues are present.
+
+### Required Linting Steps Before PR Submission
+
+Always run these commands before committing and pushing changes:
+
+```bash
+# Run all pre-commit checks (REQUIRED)
+SKIP=no-commit-to-branch pre-commit run --all-files
+
+# Individual linting tools for troubleshooting
+scripts/run-in-env.sh ruff check --fix # Fix linting issues
+scripts/run-in-env.sh ruff format # Fix formatting
+scripts/run-in-env.sh pylint matter_server/ tests/ # Check code quality
+scripts/run-in-env.sh mypy # Check type annotations
+```
+
+### Linting Tools Used
+
+The project uses multiple linting tools enforced via pre-commit hooks:
+
+- **ruff**: Fast Python linter and formatter (replaces flake8, isort, etc.)
+- **pylint**: Static code analysis for code quality
+- **mypy**: Static type checking
+- **codespell**: Spell checking for code and documentation
+- **File format checks**: JSON, TOML validation, trailing whitespace, end-of-file fixers
+
+### Common Linting Failures
+
+**Trailing Whitespace**: Remove all trailing spaces from lines
+**Missing Newline**: Ensure files end with a single newline character
+**Import Order**: Use `ruff format` to fix import sorting
+**Type Annotations**: Add type hints where mypy reports missing annotations
+**Spelling**: Use `codespell` to check for typos in code and comments
+
+### Automated Fixing
+
+Most linting issues can be automatically fixed:
+
+```bash
+scripts/run-in-env.sh ruff check --fix # Auto-fix many linting issues
+scripts/run-in-env.sh ruff format # Auto-format code
+```
+
+**Always verify changes after auto-fixing and run the full pre-commit suite before submitting.**
diff --git a/.github/workflows/pr-labels.yaml b/.github/workflows/pr-labels.yaml
index 1f7dd8f7..9bf883e5 100644
--- a/.github/workflows/pr-labels.yaml
+++ b/.github/workflows/pr-labels.yaml
@@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🏷 Verify PR has a valid label
- uses: ludeeus/action-require-labels@1.1.0
+ uses: ludeeus/action-require-labels@2.0.0
with:
labels: >-
- breaking-change, bugfix, refactor, new-feature, maintenance, ci, dependencies
+ breaking-change, bugfix, refactor, new-feature, maintenance, ci, dependencies, docs
diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml
index 18e52677..9521e8c4 100644
--- a/.github/workflows/release-drafter.yml
+++ b/.github/workflows/release-drafter.yml
@@ -7,9 +7,12 @@ on:
jobs:
update_release_draft:
+ permissions:
+ contents: write # for release-drafter/release-drafter to create a github release
+ pull-requests: read # for release-drafter/release-drafter to read PR content and labels
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- - uses: release-drafter/release-drafter@v6.0.0
+ - uses: release-drafter/release-drafter@v7.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1ae57bb2..4613a630 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -4,7 +4,7 @@ on:
release:
types: [published]
env:
- PYTHON_VERSION: "3.11"
+ PYTHON_VERSION: "3.12"
NODE_VERSION: "18.x"
jobs:
@@ -14,7 +14,7 @@ jobs:
outputs:
version: ${{ steps.vars.outputs.tag }}
steps:
- - uses: actions/checkout@v4.1.7
+ - uses: actions/checkout@v7.0.0
- name: Get tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
@@ -32,11 +32,11 @@ jobs:
fi
fi
- name: Set up Python ${{ env.PYTHON_VERSION }}
- uses: actions/setup-python@v5.2.0
+ uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Node ${{ env.NODE_VERSION }}
- uses: actions/setup-node@v4
+ uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install build
@@ -64,7 +64,7 @@ jobs:
run: >-
python3 -m build
- name: Publish release to PyPI
- uses: pypa/gh-action-pypi-publish@v1.10.1
+ uses: pypa/gh-action-pypi-publish@v1.14.0
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
@@ -77,15 +77,15 @@ jobs:
packages: write
needs: build-and-publish-pypi
steps:
- - uses: actions/checkout@v4.1.7
+ - uses: actions/checkout@v7.0.0
- name: Log in to the GitHub container registry
- uses: docker/login-action@v3.3.0
+ uses: docker/login-action@v4.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3.6.1
+ uses: docker/setup-buildx-action@v4.1.0
- name: Version number for tags
id: tags
shell: bash
@@ -95,7 +95,7 @@ jobs:
echo "minor=${patch%.*}" >> $GITHUB_OUTPUT
echo "major=${patch%.*.*}" >> $GITHUB_OUTPUT
- name: Build and Push release
- uses: docker/build-push-action@v6.7.0
+ uses: docker/build-push-action@v7.2.0
if: github.event.release.prerelease == false
with:
context: .
@@ -109,7 +109,7 @@ jobs:
push: true
build-args: "PYTHON_MATTER_SERVER=${{ needs.build-and-publish-pypi.outputs.version }}"
- name: Build and Push pre-release
- uses: docker/build-push-action@v6.7.0
+ uses: docker/build-push-action@v7.2.0
if: github.event.release.prerelease == true
with:
context: .
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index dac6a7d0..0d6dba37 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,15 +16,14 @@ jobs:
steps:
- name: Check out code from GitHub
- uses: actions/checkout@v4.1.7
+ uses: actions/checkout@v7.0.0
- name: Set up Python
- uses: actions/setup-python@v5.2.0
+ uses: actions/setup-python@v6.2.0
with:
- python-version: "3.11"
+ python-version: "3.12"
- name: Install dependencies
run: |
sudo apt-get update
- sudo apt-get install -y libgirepository1.0-dev
python -m pip install --upgrade pip
pip install -e .[server]
pip install -e .[test]
@@ -38,14 +37,14 @@ jobs:
fail-fast: false
matrix:
python-version:
- - "3.11"
- "3.12"
+ - "3.13"
steps:
- name: Check out code from GitHub
- uses: actions/checkout@v4.1.7
+ uses: actions/checkout@v7.0.0
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5.2.0
+ uses: actions/setup-python@v6.2.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dbb047a4..be2d4979 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -9,14 +9,14 @@ repos:
types: [python]
entry: scripts/run-in-env.sh ruff check --fix
require_serial: true
- stages: [commit, push, manual]
+ stages: [pre-commit, pre-push, manual]
- id: ruff-format
name: 🐶 Ruff Formatter
language: system
types: [python]
entry: scripts/run-in-env.sh ruff format
require_serial: true
- stages: [commit, push, manual]
+ stages: [pre-commit, pre-push, manual]
- id: check-ast
name: 🐍 Check Python AST
language: system
@@ -36,7 +36,7 @@ repos:
language: system
types: [text, executable]
entry: scripts/run-in-env.sh check-executables-have-shebangs
- stages: [commit, push, manual]
+ stages: [pre-commit, pre-push, manual]
- id: check-json
name: { Check JSON files
language: system
@@ -72,7 +72,7 @@ repos:
language: system
types: [text]
entry: scripts/run-in-env.sh end-of-file-fixer
- stages: [commit, push, manual]
+ stages: [pre-commit, pre-push, manual]
- id: no-commit-to-branch
name: 🛑 Don't commit to main branch
language: system
@@ -85,13 +85,15 @@ repos:
name: 🌟 Starring code with pylint
language: system
types: [python]
- entry: scripts/run-in-env.sh pylint
+ entry: scripts/run-in-env.sh pylint matter_server/ tests/
+ require_serial: true
+ pass_filenames: false
- id: trailing-whitespace
name: ✄ Trim Trailing Whitespace
language: system
types: [text]
entry: scripts/run-in-env.sh trailing-whitespace-fixer
- stages: [commit, push, manual]
+ stages: [pre-commit, pre-push, manual]
- id: mypy
name: mypy
entry: scripts/run-in-env.sh mypy
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
new file mode 100644
index 00000000..dd49ff81
--- /dev/null
+++ b/DEVELOPMENT.md
@@ -0,0 +1,39 @@
+# Setting up your development environment
+
+**For enabling Matter support within Home Assistant, please refer to the Home Assistant documentation. These instructions are for development only!**
+
+Development is only possible on a (recent) Linux or MacOS machine. Other operating systems are **not supported**. See [here](docs/os_requirements.md) for a full list of requirements to the OS and network, especially if you plan on communicating with Thread based devices.
+
+- Download/clone the repo to your local machine.
+- Set-up the development environment: `scripts/setup.sh`
+- Create the `/data` directory if it does not exist with permissions for the user running the python-matter-server.
+
+## Start Matter server
+
+You can check out the [example script](/scripts/example.py) in the scripts folder for generic directions to run the client and server.
+
+- To run the server in `info` log-level, you can run: `python -m matter_server.server`
+- To start the server in `debug` log-level, you can run: `python -m matter_server.server --log-level debug`
+- To start the server with SDK in `progress` log-level, you can run: `python -m matter_server.server --log-level-sdk progress`. This will display more information from the Matter SDK (C++) side of the Matter Server.
+
+Use `--help` to get a list of possible log levels and other command line arguments.
+
+The server runs a Matter Controller and includes all logic for storing node information, interviews and subscriptions. To interact with this controller we've created a small Websockets API with an RPC-like interface. The library contains a client as reference implementation which in turn is used by Home Assistant. Splitting the server from the client allows the scenario where multiple consumers can communicate to the same Matter fabric and the Matter fabric can keep running while the consumer (e.g. Home Assistant is down).
+
+If you happen to get `OSError: [Errno 105] No buffer space available.`, increase the IPv4 group limits with:
+```
+echo "net.ipv4.igmp_max_memberships=1024" | sudo tee -a /etc/sysctl.d/local.conf
+sudo service procps force-reload
+```
+
+## Python client library only
+
+There is also a Python client library hosted in this repository (used by Home Assistant), which consumes the Websockets API published from the server.
+
+The client library has a dependency on the chip/matter clusters package which contains all (Cluster) models and this package is os/platform independent. The server library depends on the Matter Core SDK (still named CHIP) which is architecture and OS specific. We build (and publish) wheels for Linux (amd64 and aarch64) to pypi but for other platforms (like Macos) you will need to build those wheels yourself using the exact same version of the SDK as we use for the clusters package. Take a look at our build script for directions: https://github.com/home-assistant-libs/chip-wheels/blob/main/.github/workflows/build.yaml
+
+To only install the client part: `pip install python-matter-server`
+
+## Websocket commands
+
+[Websocket documentation](/docs/websockets_api.md)
diff --git a/Dockerfile b/Dockerfile
index 83fe2450..133fb300 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM python:3.11-slim-bullseye
+FROM python:3.12-slim-bookworm
# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -26,7 +26,7 @@ RUN \
ARG PYTHON_MATTER_SERVER
-ENV chip_example_url "https://github.com/home-assistant-libs/matter-linux-ota-provider/releases/download/2024.7.2"
+ENV chip_example_url "https://github.com/home-assistant-libs/matter-linux-ota-provider/releases/download/2025.9.0"
ARG TARGETPLATFORM
RUN \
diff --git a/README.md b/README.md
index 7239061d..a875cff8 100644
--- a/README.md
+++ b/README.md
@@ -1,317 +1,48 @@
-# Python Matter Server
+# Open Home Foundation Matter Server
+
+
+
+The Open Home Foundation Matter Server is an [officially certified](https://csa-iot.org/csa_product/open-home-foundation-matter-server/) Software Component to create a Matter controller. It serves as the foundation to provide Matter support to [Home Assistant](https://home-assistant.io) but its universal approach makes it suitable to be used in other projects too.
This project implements a Matter Controller Server over WebSockets using the
[official Matter (formerly CHIP) SDK](https://github.com/project-chip/connectedhomeip)
as a base and provides both a server and client implementation.
-The goal of this project is primarily to have Matter support in Home Assistant
-but its universal approach makes it suitable to be used in other projects too.
+> [!IMPORTANT]
+> The Matter Server was rewritten and moved to [matterjs-server](https://github.com/matter-js/matterjs-server)! 🎉
+> The version 8.1.2 is the final version of the python-matter-server, libraries, and docker-container.
+> Please migrate to the new server as soon as possible, as the python-matter-server will no longer receive updates or support.
+
+The Open Home Foundation Matter Server software component is funded by [Nabu Casa](https://www.nabucasa.com/) (a member of the CSA) and donated to [The Open Home Foundation](https://www.openhomefoundation.org/).
## Support
-Got questions?
+For developers, making use of this component or contributing to it, use the issue tracker within this repository and/or reach out on discord.
-You have several options to get them answered:
+For users of Home Assistant, seek support in the official Home Assistant support channels.
- The Home Assistant [Community Forum](https://community.home-assistant.io/).
- The Home Assistant [Discord Chat Server](https://discord.gg/c5DvZ4e).
- Join [the Reddit subreddit in /r/homeassistant](https://reddit.com/r/homeassistant).
-If you experience issues using Matter with Home Assistant, please open an issue
-report in the [Home Assistant Core repository](https://github.com/home-assistant/core/issues/new/choose).
-
-You may also open issues in this repository if you are absolutely sure that your
-issue is related to the Matter Server component.
-
-## Installation
-
-We strongly recommend using Home Assistant OS along with the official Matter
-Server add-on to use Matter with Home Assistant. The Matter integration
-automatically installs the Python Matter Server add-on. Please refer to the
-[Home Assistant documentation](https://www.home-assistant.io/integrations/matter/).
-Home Assistant OS has been tested and tuned to be used with Matter and Thread,
-which makes this combination the best tested and largely worry free
-environment.
-
-If you still prefer a self-managed container installation, we do offer an
-official container image. Please keep in mind that you might experience
-communication issues with Matter devices, especially Thread based devices.
-This is mostly because the container installation uses host networking, and
-relies on the networking managed by your operating system.
-
-### Requirements to communicate with Wi-Fi/Ethernet based Matter devices
-
-Make sure you run the container on the host network. The host network
-interface needs to be in the same network as the Android/iPhone device
-you are using for commissioning. Matter uses link-local multicast protocols
-which do not work across different LANs or VLANs.
-
-The host network interface needs IPv6 support enabled.
-
-### Requirements to communicate with Thread devices through Thread border routers
-
-For communication through Thread border routers which are not running on the same
-host as the Matter Controller server to work, IPv6 routing needs to be properly
-working. IPv6 routing is largely setup automatically through the IPv6 Neighbor
-Discovery Protocol, specifically the Route Information Options (RIO). However,
-if IPv6 Neighbor Discovery RIO's are processed, and processed correctly depends on the network
-management software your system is using. There may be bugs and caveats in
-processing this Route Information Options.
-
-In general, make sure the kernel option `CONFIG_IPV6_ROUTER_PREF` is enabled and
-that IPv6 forwarding is disabled (sysctl variable `net.ipv6.conf.all.forwarding`).
-If IPv6 forwarding is enabled, the Linux kernel doesn't employ reachability
-probing (RFC 4191), which can lead to longer outages (up to 30min) until
-network changes are detected.
-
-If you are using NetworkManager, make sure to use at least NetworkManager 1.42.
-Previous versions lose track of routes and stale routes can lead to unreachable
-Thread devices. All current released NetworkManager versions can't handle
-multiple routes to the same network properly. This means if you have multiple
-Thread border routers, the fallback won't work immediately (see [NetworkManager
-issue #1232](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1232)).
-
-We currently don't have experience with systemd-networkd. It seems to have its
-own IPv6 Neighbor Discovery Protocol handling.
-
-If you don't use NetworkManager or systemd-networkd, you can use the kernel's
-IPv6 Neighbor Discovery Protocol handling.
-
-Make sure the kernel options `CONFIG_IPV6_ROUTE_INFO` is enabled and the
-following sysctl variables are set:
-
-```
-sysctl -w net.ipv6.conf.wlan0.accept_ra=1
-sysctl -w net.ipv6.conf.wlan0.accept_ra_rt_info_max_plen=64
-```
-
-If your system has IPv6 forwarding enabled (not recommended, see above), you'll
-have to use `2` for the accept_ra variable. See also the [Thread Border Router - Bidirectional IPv6 Connectivity and DNS-Based Service Discovery codelab](https://openthread.io/codelabs/openthread-border-router#6).
-
-### Running the Matter Server using container image
-
-With the following command you can run the Matter Server in a container using
-Docker. The Matter network data (fabric information) are stored in a newly
-created directory `data` in the current directory. Adjust the command to
-choose another location instead.
-
-```
-mkdir data
-docker run -d \
- --name matter-server \
- --restart=unless-stopped \
- --security-opt apparmor=unconfined \
- -v $(pwd)/data:/data \
- --network=host \
- ghcr.io/home-assistant-libs/python-matter-server:stable
-```
-
-> [!NOTE]
-> The container has a default command line set (see Dockerfile). If you intend to pass additional arguments, you have to pass the default command line as well.
-
-To use local commissioning with Bluetooth, make sure to pass the D-Bus socket as well:
-```
-docker run -d \
- --name matter-server \
- --restart=unless-stopped \
- --security-opt apparmor=unconfined \
- -v $(pwd)/data:/data \
- -v /run/dbus:/run/dbus:ro \
- --network=host \
- ghcr.io/home-assistant-libs/python-matter-server:stable --storage-path /data --paa-root-cert-dir /data/credentials --bluetooth-adapter 0
-```
-
-### Running using Docker compose
-
-```sh
-docker compose up -d
-docker compose logs -f
-```
-
-NOTE: Both Matter and this implementation are in an early state and features are probably missing or could be improved. See our [development notes](#development) how you can help out, with development and/or testing.
-
-### Websocket commands
-
-This list is not intended to be complete, for a complete oversight see the client implementation.
-
-**Set WiFi credentials**
-Inform the controller about the WiFi credentials it needs to send when commissioning a new device.
-
-```json
-{
- "message_id": "1",
- "command": "set_wifi_credentials",
- "args": {
- "ssid": "wifi-name-here",
- "credentials": "wifi-password-here"
- }
-}
-```
+- If you experience issues using Matter with Home Assistant, please open an issue
+ report in the [Home Assistant Core repository](https://github.com/home-assistant/core/issues/new/choose).
-**Set Thread dataset**
-Inform the controller about the Thread credentials it needs to use when commissioning a new device.
-
-```json
-{
- "message_id": "1",
- "command": "set_thread_dataset",
- "args": {
- "dataset": "put-credentials-here"
- }
-}
-```
-
-**Commission with code**
-Commission a new device. For WiFi or Thread based devices, the credentials need to be set upfront, otherwise, commissioning will fail. Supports both QR-code syntax (MT:...) and manual pairing code as string.
-The controller will use bluetooth for the commissioning of wireless devices. If the machine running the Python Matter Server controller lacks Bluetooth support, commissioning will only work for devices already connected to the network (by cable or another controller).
-
-```json
-{
- "message_id": "2",
- "command": "commission_with_code",
- "args": {
- "code": "MT:Y.ABCDEFG123456789"
- }
-}
-```
-
-**Open Commissioning window**
-Open a commissioning window to commission a device present on this controller to another.
-Returns code to use as discriminator.
-
-```json
-{
- "message_id": "2",
- "command": "open_commissioning_window",
- "args": {
- "node_id": 1
- }
-}
-```
-
-**Get Nodes**
-Get all nodes already commissioned on the controller.
-
-```json
-{
- "message_id": "2",
- "command": "get_nodes"
-}
-```
-
-**Get Node**
-Get info of a single Node.
-
-```json
-{
- "message_id": "2",
- "command": "get_node",
- "args": {
- "node_id": 1
- }
-}
-```
-
-**Start listening**
-When the start_listening command is issued, the server will dump all existing nodes. From that moment on all events (including node attribute changes) will be forwarded.
-
-```json
-{
- "message_id": "3",
- "command": "start_listening"
-}
-```
-
-**Send a command**
-Because we use the datamodels of the Matter SDK, this is a little bit more involved. Here is an example of turning on a switch:
-
-```python
-import json
-
-# Import the CHIP clusters
-from chip.clusters import Objects as clusters
-
-# Import the ability to turn objects into dictionaries, and vice-versa
-from matter_server.common.helpers.util import dataclass_from_dict,dataclass_to_dict
-
-command = clusters.OnOff.Commands.On()
-payload = dataclass_to_dict(command)
-
-
-message = {
- "message_id": "example",
- "command": "device_command",
- "args": {
- "endpoint_id": 1,
- "node_id": 1,
- "payload": payload,
- "cluster_id": command.cluster_id,
- "command_name": "On"
- }
-}
-
-print(json.dumps(message, indent=2))
-```
-
-```json
-{
- "message_id": "example",
- "command": "device_command",
- "args": {
- "endpoint_id": 1,
- "node_id": 1,
- "payload": {},
- "cluster_id": 6,
- "command_name": "On"
- }
-}
-```
-
-You can also provide parameters for the cluster commands. Here's how to change the brightness for example:
-
-```
-command = clusters.LevelControl.Commands.MoveToLevelWithOnOff(
- level=int(value), # provide a percentage
- transitionTime=0, # in seconds
-)
-```
-
-### Note when using Thread based Matter devices
-
-When communicating with Thread devices through a non-local Thread border router,
-your host must process ICMPv6 Router Advertisements. See the [openthread.io
-Bidirectional IPv6 Connectivity code labs](https://openthread.io/codelabs/openthread-border-router#6)
-on how-to setup your host correctly. Note that NetworkManager has its own ICMPv6
-Router Advertisement processing. A recent version of NetworkManager is
-necessary, and there are still known issues (see NetworkManager issue
-[#1232](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1232)).
-
-The Home Assistant Operating System 10 and newer correctly processes ICMPv6
-Router Advertisements.
+Please do not create Home Assistant enduser support issues in the issue tracker of this repository.
## Development
-Want to help out with development, testing, and/or documentation? Great! As both this project and Matter keeps evolving and more and more devices are available with actual Matter support, there will be a lot to improve. Reach out to us on discord if you want to help out.
-
-### Setting up your development environment
-
-**For enabling Matter support within Home Assistant, please refer to the Home Assistant documentation. These instructions are for development only!**
-
-Development is only possible on a (recent) Linux or MacOS machine. Other operating systems are not supported.
+Want to help out with development, testing, and/or documentation? Great! As both this project and Matter keeps evolving there will be a lot to improve. Reach out to us on discord if you want to help out.
-- Download/clone the repo to your local machine.
-- Set-up the development environment: `scripts/setup.sh`
+[Development documentation](DEVELOPMENT.md)
-You can check out the example script in the scripts folder for generic directions to run the client and server.
+## Installation / Running the Matter Server
-To just run the server, you can run: `python -m matter_server.server`
+- Endusers of Home Assistant, refer to the [Home Assistant documentation](https://www.home-assistant.io/integrations/matter/) how to run Matter in Home Assistant using the official Matter Server add-on, which is based on this project.
-The server runs a Matter Controller and includes all logic for storing node information, interviews and subscriptions. To interact with this controller we've created a small Websockets API with an RPC-like interface. The library contains a client as reference implementation which in turn is used by Home Assistant. Splitting the server from the client allows the scenario where multiple consumers can communicate to the same Matter fabric and the Matter fabric can keep running while the consumer (e.g. Home Assistant is down).
+- For running the server and/or client in your development environment, see the [Development documentation](DEVELOPMENT.md).
-### Python client library only
+- For running the Matter Server as a standalone docker container, see our instructions [here](docs/docker.md).
-There is also a Python client library hosted in this repository (used by Home Assistant), which consumes the Websockets API published from the server.
-
-The client library has a dependency on the chip/matter clusters package which contains all (Cluster) models and this package is os/platform independent. The server library depends on the Matter Core SDK (still named CHIP) which is architecture and OS specific. We build (and publish) wheels for Linux (amd64 and aarch64) to pypi but for other platforms (like Macos) you will need to build those wheels yourself using the exact same version of the SDK as we use for the clusters package. Take a look at our build script for directions: https://github.com/home-assistant-libs/chip-wheels/blob/main/.github/workflows/build.yaml
-
-To only install the client part: `pip install python-matter-server`
+> [!NOTE]
+> Both Matter and this implementation are in an early state and features are probably missing or could be improved. See our [development notes](#development) how you can help out, with development and/or testing.
diff --git a/compose.yml b/compose.yml
deleted file mode 100644
index 2696c453..00000000
--- a/compose.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-services:
- # python-matter-server
- matter-server:
- image: ghcr.io/home-assistant-libs/python-matter-server:stable
- container_name: matter-server
- restart: unless-stopped
- # Required for mDNS to work correctly
- network_mode: host
- security_opt:
- # Needed for Bluetooth via dbus
- - apparmor:unconfined
- volumes:
- # Create an .env file that sets the USERDIR environment variable.
- - ${USERDIR:-$HOME}/docker/matter-server/data:/data/
- # Required for Bluetooth via D-Bus
- #- /run/dbus:/run/dbus:ro
- # If you adjust command line, make sure to pass the default CMD arguments too:
- #command: --storage-path /data --paa-root-cert-dir /data/credentials --bluetooth-adapter 0
diff --git a/dashboard/README.md b/dashboard/README.md
index 1b431b03..8d9349f2 100644
--- a/dashboard/README.md
+++ b/dashboard/README.md
@@ -20,9 +20,9 @@ script/develop
The dashboard will be available at [http://localhost:5010](http://localhost:5010). When you open it from localhost, it will ask you for your websocket server URL.
-The websocket URL of the Home Assistant add-on will be something like `ws://homeassistant.local:5080`. If you are running the Python Matter Server locally, it will be `ws://localhost:5080`.
+The websocket URL of the Home Assistant add-on will be something like `ws://homeassistant.local:5580`. If you are running the Python Matter Server locally, it will be `ws://localhost:5580`.
-If you want to use the dashboard with the Python Matter Server Home Assistant add-on, you need to configure it to make the WebSocket server available on the network. Go to the [add-on info page](https://my.home-assistant.io/redirect/supervisor_addon/?addon=core_matter_server), click on Configuration. Under "Network", show disabled ports and enter the port you want to use for the WebSocket server (e.g. 5080). Then, click "save" and restart the add-on when prompted.
+If you want to use the dashboard with the Python Matter Server Home Assistant add-on, you need to configure it to make the WebSocket server available on the network. Go to the [add-on info page](https://my.home-assistant.io/redirect/supervisor_addon/?addon=core_matter_server), click on Configuration. Under "Network", show disabled ports and enter the port you want to use for the WebSocket server (e.g. 5580). Then, click "save" and restart the add-on when prompted.
## Production build
diff --git a/dashboard/note.md b/dashboard/note.md
new file mode 100644
index 00000000..12a6d1b2
--- /dev/null
+++ b/dashboard/note.md
@@ -0,0 +1,12 @@
+```
+
+
${"privilege:" + entry.privilege}
+
${"authMode:" + entry.authMode}
+
${"fabricIndex:" + entry.fabricIndex}
+
+ subjects:${JSON.stringify(entry.subjects)}
+ targets:${JSON.stringify(entry.targets)}
+
+```
diff --git a/dashboard/src/client/client.ts b/dashboard/src/client/client.ts
index 25625f68..19d0f5f6 100644
--- a/dashboard/src/client/client.ts
+++ b/dashboard/src/client/client.ts
@@ -143,6 +143,21 @@ export class MatterClient {
await this.sendCommand("update_node", 10, { node_id: nodeId, software_version: softwareVersion });
}
+ async setACLEntry(nodeId: number, entry: any) {
+ return await this.sendCommand("set_acl_entry", 0, {
+ node_id: nodeId,
+ entry: entry,
+ });
+ }
+
+ async setNodeBinding(nodeId: number, endpoint: number, bindings: any) {
+ return await this.sendCommand("set_node_binding", 0, {
+ node_id: nodeId,
+ endpoint: endpoint,
+ bindings: bindings,
+ });
+ }
+
async sendCommand(
command: T,
require_schema: number | undefined = undefined,
diff --git a/dashboard/src/client/models/descriptions.ts b/dashboard/src/client/models/descriptions.ts
index b3e68d68..04dcd291 100644
--- a/dashboard/src/client/models/descriptions.ts
+++ b/dashboard/src/client/models/descriptions.ts
@@ -26,10 +26,10 @@ export const device_types: Record = {
"id": 4293984257,
"label": "Orphan Clusters",
"clusters": [
+ 28,
66,
67,
- 68,
- 28
+ 68
]
},
"22": {
@@ -70,26 +70,26 @@ export const device_types: Record = {
"id": 1296,
"label": "Electrical Sensor",
"clusters": [
+ 29,
144,
145,
- 156,
- 29
+ 156
]
},
"18": {
"id": 18,
"label": "OTA Requestor",
"clusters": [
- 42,
- 29
+ 29,
+ 42
]
},
"20": {
"id": 20,
"label": "OTA Provider",
"clusters": [
- 41,
- 29
+ 29,
+ 41
]
},
"14": {
@@ -102,37 +102,59 @@ export const device_types: Record = {
},
"19": {
"id": 19,
- "label": "Bridged Device",
+ "label": "Bridged Node",
"clusters": [
- 57,
29,
46,
- 47
+ 47,
+ 57
]
},
"256": {
"id": 256,
"label": "On/Off Light",
"clusters": [
- 98,
3,
4,
6,
8,
- 29
+ 29,
+ 98
]
},
"257": {
"id": 257,
"label": "Dimmable Light",
"clusters": [
- 98,
3,
4,
6,
8,
29,
- 30
+ 30,
+ 98
+ ]
+ },
+ "271": {
+ "id": 271,
+ "label": "Mounted On/Off Control",
+ "clusters": [
+ 98,
+ 3,
+ 4,
+ 6,
+ 8
+ ]
+ },
+ "272": {
+ "id": 272,
+ "label": "Mounted Dimmable Load Control",
+ "clusters": [
+ 98,
+ 3,
+ 4,
+ 6,
+ 8
]
},
"268": {
@@ -190,14 +212,14 @@ export const device_types: Record = {
"label": "Pump",
"clusters": [
512,
- 1026,
- 3,
+ 98,
1027,
- 4,
- 6,
1028,
- 98,
+ 3,
+ 1026,
+ 4,
8,
+ 6,
29,
30
]
@@ -300,8 +322,8 @@ export const device_types: Record = {
"id": 773,
"label": "Pressure Sensor",
"clusters": [
- 3,
1027,
+ 3,
29
]
},
@@ -355,9 +377,9 @@ export const device_types: Record = {
"label": "Window Covering",
"clusters": [
258,
- 98,
3,
4,
+ 98,
29
]
},
@@ -374,10 +396,10 @@ export const device_types: Record = {
"id": 768,
"label": "Heating/Cooling Unit",
"clusters": [
- 514,
+ 98,
3,
+ 514,
4,
- 98,
6,
8,
29,
@@ -388,14 +410,14 @@ export const device_types: Record = {
"id": 769,
"label": "Thermostat",
"clusters": [
- 513,
- 98,
3,
- 516,
4,
- 56,
29,
- 30
+ 30,
+ 56,
+ 98,
+ 513,
+ 516
]
},
"43": {
@@ -415,14 +437,14 @@ export const device_types: Record = {
1283,
1284,
1285,
- 1286,
6,
1287,
- 1289,
1288,
- 1291,
- 1292,
+ 1286,
1290,
+ 1289,
+ 1292,
+ 1291,
1294,
29
]
@@ -435,10 +457,10 @@ export const device_types: Record = {
1284,
1285,
6,
- 1286,
1287,
- 1289,
1288,
+ 1286,
+ 1289,
1291,
29
]
@@ -450,17 +472,17 @@ export const device_types: Record = {
1283,
1284,
1285,
- 1286,
6,
1287,
- 1289,
+ 8,
1288,
- 1291,
+ 1290,
+ 1286,
1292,
1293,
1294,
- 8,
- 1290,
+ 1289,
+ 1291,
29,
30
]
@@ -472,16 +494,16 @@ export const device_types: Record = {
1283,
1284,
1285,
- 1286,
6,
1287,
- 1289,
+ 8,
1288,
- 1291,
+ 1290,
+ 1286,
1292,
- 8,
+ 1289,
1294,
- 1290,
+ 1291,
29,
30
]
@@ -526,14 +548,14 @@ export const device_types: Record = {
"label": "Room Air Conditioner",
"clusters": [
513,
+ 98,
514,
- 3,
516,
+ 1029,
+ 3,
+ 1026,
4,
6,
- 1026,
- 98,
- 1029,
29
]
},
@@ -572,12 +594,12 @@ export const device_types: Record = {
1029,
1066,
1067,
- 1068,
1036,
- 1037,
- 1071,
1069,
1070,
+ 1037,
+ 1071,
+ 1068,
1043,
1045,
91,
@@ -670,6 +692,7 @@ export const device_types: Record = {
"clusters": [
97,
3,
+ 336,
84,
85,
29
@@ -692,9 +715,9 @@ export const device_types: Record = {
"label": "Water Freeze Detector",
"clusters": [
128,
- 29,
3,
- 69
+ 69,
+ 29
]
},
"66": {
@@ -711,9 +734,9 @@ export const device_types: Record = {
"label": "Water Leak Detector",
"clusters": [
128,
- 29,
3,
- 69
+ 69,
+ 29
]
},
"68": {
@@ -721,15 +744,27 @@ export const device_types: Record = {
"label": "Rain Sensor",
"clusters": [
128,
- 29,
3,
- 69
+ 69,
+ 29
]
},
- "4293984272": {
- "id": 4293984272,
+ "144": {
+ "id": 144,
"label": "Network Infrastructure Manager",
"clusters": [
+ 1105,
+ 1106,
+ 1107,
+ 29
+ ]
+ },
+ "145": {
+ "id": 145,
+ "label": "Thread Border Router",
+ "clusters": [
+ 1106,
+ 53,
29
]
},
@@ -741,20 +776,22 @@ export const device_types: Record = {
257,
98,
3,
- 4,
1026,
+ 4,
6,
- 259,
8,
29,
30
]
},
- "4293984258": {
- "id": 4293984258,
- "label": "Secondary Network Commissioning Device Type",
+ "25": {
+ "id": 25,
+ "label": "Secondary Network Interface",
"clusters": [
49,
+ 53,
+ 54,
+ 55,
29
]
},
@@ -773,7 +810,8 @@ export const device_types: Record = {
"clusters": [
1026,
29,
- 86
+ 86,
+ 6
]
},
"1292": {
@@ -786,6 +824,50 @@ export const device_types: Record = {
153,
29
]
+ },
+ "1293": {
+ "id": 1293,
+ "label": "Device Energy Management",
+ "clusters": [
+ 152,
+ 29,
+ 159
+ ]
+ },
+ "1295": {
+ "id": 1295,
+ "label": "Water Heater",
+ "clusters": [
+ 513,
+ 3,
+ 148,
+ 29,
+ 158
+ ]
+ },
+ "777": {
+ "id": 777,
+ "label": "Heat Pump",
+ "clusters": [
+ 3,
+ 29
+ ]
+ },
+ "23": {
+ "id": 23,
+ "label": "Solar Power",
+ "clusters": [
+ 3,
+ 29
+ ]
+ },
+ "24": {
+ "id": 24,
+ "label": "Battery Storage",
+ "clusters": [
+ 3,
+ 29
+ ]
}
}
@@ -964,60 +1046,6 @@ export const clusters: Record = {
}
}
},
- "7": {
- "id": 7,
- "label": "OnOffSwitchConfiguration",
- "attributes": {
- "0": {
- "id": 0,
- "cluster_id": 7,
- "label": "SwitchType",
- "type": "uint"
- },
- "16": {
- "id": 16,
- "cluster_id": 7,
- "label": "SwitchActions",
- "type": "uint"
- },
- "65528": {
- "id": 65528,
- "cluster_id": 7,
- "label": "GeneratedCommandList",
- "type": "List[uint]"
- },
- "65529": {
- "id": 65529,
- "cluster_id": 7,
- "label": "AcceptedCommandList",
- "type": "List[uint]"
- },
- "65530": {
- "id": 65530,
- "cluster_id": 7,
- "label": "EventList",
- "type": "List[uint]"
- },
- "65531": {
- "id": 65531,
- "cluster_id": 7,
- "label": "AttributeList",
- "type": "List[uint]"
- },
- "65532": {
- "id": 65532,
- "cluster_id": 7,
- "label": "FeatureMap",
- "type": "uint"
- },
- "65533": {
- "id": 65533,
- "cluster_id": 7,
- "label": "ClusterRevision",
- "type": "uint"
- }
- }
- },
"8": {
"id": 8,
"label": "LevelControl",
@@ -1144,158 +1172,62 @@ export const clusters: Record = {
}
}
},
- "15": {
- "id": 15,
- "label": "BinaryInputBasic",
+ "28": {
+ "id": 28,
+ "label": "PulseWidthModulation",
"attributes": {
- "4": {
- "id": 4,
- "cluster_id": 15,
- "label": "ActiveText",
- "type": "Optional[str]"
- },
- "28": {
- "id": 28,
- "cluster_id": 15,
- "label": "Description",
- "type": "Optional[str]"
- },
- "46": {
- "id": 46,
- "cluster_id": 15,
- "label": "InactiveText",
- "type": "Optional[str]"
- },
- "81": {
- "id": 81,
- "cluster_id": 15,
- "label": "OutOfService",
- "type": "bool"
- },
- "84": {
- "id": 84,
- "cluster_id": 15,
- "label": "Polarity",
- "type": "Optional[uint]"
- },
- "85": {
- "id": 85,
- "cluster_id": 15,
- "label": "PresentValue",
- "type": "bool"
- },
- "103": {
- "id": 103,
- "cluster_id": 15,
- "label": "Reliability",
- "type": "Optional[uint]"
- },
- "111": {
- "id": 111,
- "cluster_id": 15,
- "label": "StatusFlags",
- "type": "uint"
- },
- "256": {
- "id": 256,
- "cluster_id": 15,
- "label": "ApplicationType",
- "type": "Optional[uint]"
- },
"65528": {
"id": 65528,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "GeneratedCommandList",
"type": "List[uint]"
},
"65529": {
"id": 65529,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "AcceptedCommandList",
"type": "List[uint]"
},
"65530": {
"id": 65530,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "EventList",
"type": "List[uint]"
},
"65531": {
"id": 65531,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "AttributeList",
"type": "List[uint]"
},
"65532": {
"id": 65532,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "FeatureMap",
"type": "uint"
},
"65533": {
"id": 65533,
- "cluster_id": 15,
+ "cluster_id": 28,
"label": "ClusterRevision",
"type": "uint"
}
}
},
- "28": {
- "id": 28,
- "label": "PulseWidthModulation",
+ "29": {
+ "id": 29,
+ "label": "Descriptor",
"attributes": {
- "65528": {
- "id": 65528,
- "cluster_id": 28,
- "label": "GeneratedCommandList",
- "type": "List[uint]"
- },
- "65529": {
- "id": 65529,
- "cluster_id": 28,
- "label": "AcceptedCommandList",
- "type": "List[uint]"
- },
- "65530": {
- "id": 65530,
- "cluster_id": 28,
- "label": "EventList",
- "type": "List[uint]"
- },
- "65531": {
- "id": 65531,
- "cluster_id": 28,
- "label": "AttributeList",
- "type": "List[uint]"
- },
- "65532": {
- "id": 65532,
- "cluster_id": 28,
- "label": "FeatureMap",
- "type": "uint"
- },
- "65533": {
- "id": 65533,
- "cluster_id": 28,
- "label": "ClusterRevision",
- "type": "uint"
- }
- }
- },
- "29": {
- "id": 29,
- "label": "Descriptor",
- "attributes": {
- "0": {
- "id": 0,
- "cluster_id": 29,
- "label": "DeviceTypeList",
- "type": "List[Descriptor.Structs.DeviceTypeStruct]"
- },
- "1": {
- "id": 1,
- "cluster_id": 29,
- "label": "ServerList",
+ "0": {
+ "id": 0,
+ "cluster_id": 29,
+ "label": "DeviceTypeList",
+ "type": "List[Descriptor.Structs.DeviceTypeStruct]"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 29,
+ "label": "ServerList",
"type": "List[uint]"
},
"2": {
@@ -1436,6 +1368,18 @@ export const clusters: Record = {
"label": "AccessControlEntriesPerFabric",
"type": "uint"
},
+ "5": {
+ "id": 5,
+ "cluster_id": 31,
+ "label": "CommissioningARL",
+ "type": "Optional[List[AccessControl.Structs.CommissioningAccessRestrictionEntryStruct]]"
+ },
+ "6": {
+ "id": 6,
+ "cluster_id": 31,
+ "label": "Arl",
+ "type": "Optional[List[AccessControl.Structs.AccessRestrictionEntryStruct]]"
+ },
"65528": {
"id": 65528,
"cluster_id": 31,
@@ -1650,7 +1594,7 @@ export const clusters: Record = {
"id": 18,
"cluster_id": 40,
"label": "UniqueID",
- "type": "Optional[str]"
+ "type": "str"
},
"19": {
"id": 19,
@@ -2300,6 +2244,30 @@ export const clusters: Record = {
"label": "SupportsConcurrentConnection",
"type": "bool"
},
+ "5": {
+ "id": 5,
+ "cluster_id": 48,
+ "label": "TCAcceptedVersion",
+ "type": "Optional[uint]"
+ },
+ "6": {
+ "id": 6,
+ "cluster_id": 48,
+ "label": "TCMinRequiredVersion",
+ "type": "Optional[uint]"
+ },
+ "7": {
+ "id": 7,
+ "cluster_id": 48,
+ "label": "TCAcknowledgements",
+ "type": "Optional[uint]"
+ },
+ "8": {
+ "id": 8,
+ "cluster_id": 48,
+ "label": "TCAcknowledgementsRequired",
+ "type": "Optional[bool]"
+ },
"65528": {
"id": 65528,
"cluster_id": 48,
@@ -3428,6 +3396,12 @@ export const clusters: Record = {
"label": "ProductName",
"type": "Optional[str]"
},
+ "4": {
+ "id": 4,
+ "cluster_id": 57,
+ "label": "ProductID",
+ "type": "Optional[uint]"
+ },
"5": {
"id": 5,
"cluster_id": 57,
@@ -3498,7 +3472,7 @@ export const clusters: Record = {
"id": 18,
"cluster_id": 57,
"label": "UniqueID",
- "type": "Optional[str]"
+ "type": "str"
},
"20": {
"id": 20,
@@ -4136,6 +4110,12 @@ export const clusters: Record = {
"label": "OperatingMode",
"type": "Optional[IcdManagement.Enums.OperatingModeEnum]"
},
+ "9": {
+ "id": 9,
+ "cluster_id": 70,
+ "label": "MaximumCheckInBackOff",
+ "type": "Optional[uint]"
+ },
"65528": {
"id": 65528,
"cluster_id": 70,
@@ -6208,6 +6188,84 @@ export const clusters: Record = {
}
}
},
+ "148": {
+ "id": 148,
+ "label": "WaterHeaterManagement",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 148,
+ "label": "HeaterTypes",
+ "type": "uint"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 148,
+ "label": "HeatDemand",
+ "type": "uint"
+ },
+ "2": {
+ "id": 2,
+ "cluster_id": 148,
+ "label": "TankVolume",
+ "type": "Optional[uint]"
+ },
+ "3": {
+ "id": 3,
+ "cluster_id": 148,
+ "label": "EstimatedHeatRequired",
+ "type": "Optional[int]"
+ },
+ "4": {
+ "id": 4,
+ "cluster_id": 148,
+ "label": "TankPercentage",
+ "type": "Optional[uint]"
+ },
+ "5": {
+ "id": 5,
+ "cluster_id": 148,
+ "label": "BoostState",
+ "type": "aenum BoostStateEnum"
+ },
+ "65528": {
+ "id": 65528,
+ "cluster_id": 148,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
+ },
+ "65529": {
+ "id": 65529,
+ "cluster_id": 148,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
+ },
+ "65530": {
+ "id": 65530,
+ "cluster_id": 148,
+ "label": "EventList",
+ "type": "List[uint]"
+ },
+ "65531": {
+ "id": 65531,
+ "cluster_id": 148,
+ "label": "AttributeList",
+ "type": "List[uint]"
+ },
+ "65532": {
+ "id": 65532,
+ "cluster_id": 148,
+ "label": "FeatureMap",
+ "type": "uint"
+ },
+ "65533": {
+ "id": 65533,
+ "cluster_id": 148,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
"150": {
"id": 150,
"label": "DemandResponseLoadControl",
@@ -6390,7 +6448,7 @@ export const clusters: Record = {
"id": 5,
"cluster_id": 152,
"label": "PowerAdjustmentCapability",
- "type": "Union[NoneType, Nullable, List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]"
+ "type": "Union[NoneType, Nullable, DeviceEnergyManagement.Structs.PowerAdjustCapabilityStruct]"
},
"6": {
"id": 6,
@@ -6814,6 +6872,72 @@ export const clusters: Record = {
}
}
},
+ "158": {
+ "id": 158,
+ "label": "WaterHeaterMode",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 158,
+ "label": "SupportedModes",
+ "type": "List[WaterHeaterMode.Structs.ModeOptionStruct]"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 158,
+ "label": "CurrentMode",
+ "type": "uint"
+ },
+ "2": {
+ "id": 2,
+ "cluster_id": 158,
+ "label": "StartUpMode",
+ "type": "Union[NoneType, Nullable, uint]"
+ },
+ "3": {
+ "id": 3,
+ "cluster_id": 158,
+ "label": "OnMode",
+ "type": "Union[NoneType, Nullable, uint]"
+ },
+ "65528": {
+ "id": 65528,
+ "cluster_id": 158,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
+ },
+ "65529": {
+ "id": 65529,
+ "cluster_id": 158,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
+ },
+ "65530": {
+ "id": 65530,
+ "cluster_id": 158,
+ "label": "EventList",
+ "type": "List[uint]"
+ },
+ "65531": {
+ "id": 65531,
+ "cluster_id": 158,
+ "label": "AttributeList",
+ "type": "List[uint]"
+ },
+ "65532": {
+ "id": 65532,
+ "cluster_id": 158,
+ "label": "FeatureMap",
+ "type": "uint"
+ },
+ "65533": {
+ "id": 65533,
+ "cluster_id": 158,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
"159": {
"id": 159,
"label": "DeviceEnergyManagementMode",
@@ -7014,7 +7138,7 @@ export const clusters: Record = {
"id": 35,
"cluster_id": 257,
"label": "AutoRelockTime",
- "type": "uint"
+ "type": "Optional[uint]"
},
"36": {
"id": 36,
@@ -7366,103 +7490,79 @@ export const clusters: Record = {
}
}
},
- "259": {
- "id": 259,
- "label": "BarrierControl",
+ "336": {
+ "id": 336,
+ "label": "ServiceArea",
"attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 336,
+ "label": "SupportedAreas",
+ "type": "List[ServiceArea.Structs.AreaStruct]"
+ },
"1": {
"id": 1,
- "cluster_id": 259,
- "label": "BarrierMovingState",
- "type": "uint"
+ "cluster_id": 336,
+ "label": "SupportedMaps",
+ "type": "Optional[List[ServiceArea.Structs.MapStruct]]"
},
"2": {
"id": 2,
- "cluster_id": 259,
- "label": "BarrierSafetyStatus",
- "type": "uint"
+ "cluster_id": 336,
+ "label": "SelectedAreas",
+ "type": "List[uint]"
},
"3": {
"id": 3,
- "cluster_id": 259,
- "label": "BarrierCapabilities",
- "type": "uint"
+ "cluster_id": 336,
+ "label": "CurrentArea",
+ "type": "Union[NoneType, Nullable, uint]"
},
"4": {
"id": 4,
- "cluster_id": 259,
- "label": "BarrierOpenEvents",
- "type": "Optional[uint]"
+ "cluster_id": 336,
+ "label": "EstimatedEndTime",
+ "type": "Union[NoneType, Nullable, uint]"
},
"5": {
"id": 5,
- "cluster_id": 259,
- "label": "BarrierCloseEvents",
- "type": "Optional[uint]"
- },
- "6": {
- "id": 6,
- "cluster_id": 259,
- "label": "BarrierCommandOpenEvents",
- "type": "Optional[uint]"
- },
- "7": {
- "id": 7,
- "cluster_id": 259,
- "label": "BarrierCommandCloseEvents",
- "type": "Optional[uint]"
- },
- "8": {
- "id": 8,
- "cluster_id": 259,
- "label": "BarrierOpenPeriod",
- "type": "Optional[uint]"
- },
- "9": {
- "id": 9,
- "cluster_id": 259,
- "label": "BarrierClosePeriod",
- "type": "Optional[uint]"
- },
- "10": {
- "id": 10,
- "cluster_id": 259,
- "label": "BarrierPosition",
- "type": "uint"
+ "cluster_id": 336,
+ "label": "Progress",
+ "type": "Optional[List[ServiceArea.Structs.ProgressStruct]]"
},
"65528": {
"id": 65528,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "GeneratedCommandList",
"type": "List[uint]"
},
"65529": {
"id": 65529,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "AcceptedCommandList",
"type": "List[uint]"
},
"65530": {
"id": 65530,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "EventList",
"type": "List[uint]"
},
"65531": {
"id": 65531,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "AttributeList",
"type": "List[uint]"
},
"65532": {
"id": 65532,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "FeatureMap",
"type": "uint"
},
"65533": {
"id": 65533,
- "cluster_id": 259,
+ "cluster_id": 336,
"label": "ClusterRevision",
"type": "uint"
}
@@ -8009,27 +8109,9 @@ export const clusters: Record = {
"82": {
"id": 82,
"cluster_id": 513,
- "label": "PresetsSchedulesEditable",
- "type": "Optional[bool]"
- },
- "83": {
- "id": 83,
- "cluster_id": 513,
- "label": "TemperatureSetpointHoldPolicy",
- "type": "Optional[uint]"
- },
- "84": {
- "id": 84,
- "cluster_id": 513,
"label": "SetpointHoldExpiryTimestamp",
"type": "Union[NoneType, Nullable, uint]"
},
- "85": {
- "id": 85,
- "cluster_id": 513,
- "label": "QueuedPreset",
- "type": "Union[NoneType, Nullable, Thermostat.Structs.QueuedPresetStruct]"
- },
"65528": {
"id": 65528,
"cluster_id": 513,
@@ -8280,7 +8362,7 @@ export const clusters: Record = {
"id": 5,
"cluster_id": 768,
"label": "DriftCompensation",
- "type": "Optional[uint]"
+ "type": "Optional[ColorControl.Enums.DriftCompensationEnum]"
},
"6": {
"id": 6,
@@ -8298,7 +8380,7 @@ export const clusters: Record = {
"id": 8,
"cluster_id": 768,
"label": "ColorMode",
- "type": "uint"
+ "type": "aenum ColorModeEnum"
},
"15": {
"id": 15,
@@ -8496,7 +8578,7 @@ export const clusters: Record = {
"id": 16385,
"cluster_id": 768,
"label": "EnhancedColorMode",
- "type": "uint"
+ "type": "aenum EnhancedColorModeEnum"
},
"16386": {
"id": 16386,
@@ -9110,6 +9192,18 @@ export const clusters: Record = {
"label": "OccupancySensorTypeBitmap",
"type": "uint"
},
+ "3": {
+ "id": 3,
+ "cluster_id": 1030,
+ "label": "HoldTime",
+ "type": "Optional[uint]"
+ },
+ "4": {
+ "id": 4,
+ "cluster_id": 1030,
+ "label": "HoldTimeLimits",
+ "type": "Optional[OccupancySensing.Structs.HoldTimeLimitsStruct]"
+ },
"16": {
"id": 16,
"cluster_id": 1030,
@@ -10282,13 +10376,205 @@ export const clusters: Record = {
}
}
},
- "1283": {
- "id": 1283,
- "label": "WakeOnLan",
+ "1105": {
+ "id": 1105,
+ "label": "WiFiNetworkManagement",
"attributes": {
"0": {
"id": 0,
- "cluster_id": 1283,
+ "cluster_id": 1105,
+ "label": "Ssid",
+ "type": "Union[Nullable, bytes]"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 1105,
+ "label": "PassphraseSurrogate",
+ "type": "Union[Nullable, uint]"
+ },
+ "65528": {
+ "id": 65528,
+ "cluster_id": 1105,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
+ },
+ "65529": {
+ "id": 65529,
+ "cluster_id": 1105,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
+ },
+ "65530": {
+ "id": 65530,
+ "cluster_id": 1105,
+ "label": "EventList",
+ "type": "List[uint]"
+ },
+ "65531": {
+ "id": 65531,
+ "cluster_id": 1105,
+ "label": "AttributeList",
+ "type": "List[uint]"
+ },
+ "65532": {
+ "id": 65532,
+ "cluster_id": 1105,
+ "label": "FeatureMap",
+ "type": "uint"
+ },
+ "65533": {
+ "id": 65533,
+ "cluster_id": 1105,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
+ "1106": {
+ "id": 1106,
+ "label": "ThreadBorderRouterManagement",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 1106,
+ "label": "BorderRouterName",
+ "type": "str"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 1106,
+ "label": "BorderAgentID",
+ "type": "bytes"
+ },
+ "2": {
+ "id": 2,
+ "cluster_id": 1106,
+ "label": "ThreadVersion",
+ "type": "uint"
+ },
+ "3": {
+ "id": 3,
+ "cluster_id": 1106,
+ "label": "InterfaceEnabled",
+ "type": "bool"
+ },
+ "4": {
+ "id": 4,
+ "cluster_id": 1106,
+ "label": "ActiveDatasetTimestamp",
+ "type": "Union[Nullable, uint]"
+ },
+ "5": {
+ "id": 5,
+ "cluster_id": 1106,
+ "label": "PendingDatasetTimestamp",
+ "type": "Union[Nullable, uint]"
+ },
+ "65528": {
+ "id": 65528,
+ "cluster_id": 1106,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
+ },
+ "65529": {
+ "id": 65529,
+ "cluster_id": 1106,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
+ },
+ "65530": {
+ "id": 65530,
+ "cluster_id": 1106,
+ "label": "EventList",
+ "type": "List[uint]"
+ },
+ "65531": {
+ "id": 65531,
+ "cluster_id": 1106,
+ "label": "AttributeList",
+ "type": "List[uint]"
+ },
+ "65532": {
+ "id": 65532,
+ "cluster_id": 1106,
+ "label": "FeatureMap",
+ "type": "uint"
+ },
+ "65533": {
+ "id": 65533,
+ "cluster_id": 1106,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
+ "1107": {
+ "id": 1107,
+ "label": "ThreadNetworkDirectory",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 1107,
+ "label": "PreferredExtendedPanID",
+ "type": "Union[Nullable, bytes]"
+ },
+ "1": {
+ "id": 1,
+ "cluster_id": 1107,
+ "label": "ThreadNetworks",
+ "type": "List[ThreadNetworkDirectory.Structs.ThreadNetworkStruct]"
+ },
+ "2": {
+ "id": 2,
+ "cluster_id": 1107,
+ "label": "ThreadNetworkTableSize",
+ "type": "uint"
+ },
+ "65528": {
+ "id": 65528,
+ "cluster_id": 1107,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
+ },
+ "65529": {
+ "id": 65529,
+ "cluster_id": 1107,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
+ },
+ "65530": {
+ "id": 65530,
+ "cluster_id": 1107,
+ "label": "EventList",
+ "type": "List[uint]"
+ },
+ "65531": {
+ "id": 65531,
+ "cluster_id": 1107,
+ "label": "AttributeList",
+ "type": "List[uint]"
+ },
+ "65532": {
+ "id": 65532,
+ "cluster_id": 1107,
+ "label": "FeatureMap",
+ "type": "uint"
+ },
+ "65533": {
+ "id": 65533,
+ "cluster_id": 1107,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
+ "1283": {
+ "id": 1283,
+ "label": "WakeOnLan",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 1283,
"label": "MACAddress",
"type": "Optional[str]"
},
@@ -11122,831 +11408,123 @@ export const clusters: Record = {
}
}
},
- "2820": {
- "id": 2820,
- "label": "ElectricalMeasurement",
+ "1872": {
+ "id": 1872,
+ "label": "EcosystemInformation",
"attributes": {
"0": {
"id": 0,
- "cluster_id": 2820,
- "label": "MeasurementType",
- "type": "Optional[uint]"
+ "cluster_id": 1872,
+ "label": "DeviceDirectory",
+ "type": "List[EcosystemInformation.Structs.EcosystemDeviceStruct]"
},
- "256": {
- "id": 256,
- "cluster_id": 2820,
- "label": "DcVoltage",
- "type": "Optional[int]"
+ "1": {
+ "id": 1,
+ "cluster_id": 1872,
+ "label": "LocationDirectory",
+ "type": "List[EcosystemInformation.Structs.EcosystemLocationStruct]"
},
- "257": {
- "id": 257,
- "cluster_id": 2820,
- "label": "DcVoltageMin",
- "type": "Optional[int]"
+ "65528": {
+ "id": 65528,
+ "cluster_id": 1872,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
},
- "258": {
- "id": 258,
- "cluster_id": 2820,
- "label": "DcVoltageMax",
- "type": "Optional[int]"
+ "65529": {
+ "id": 65529,
+ "cluster_id": 1872,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
},
- "259": {
- "id": 259,
- "cluster_id": 2820,
- "label": "DcCurrent",
- "type": "Optional[int]"
+ "65530": {
+ "id": 65530,
+ "cluster_id": 1872,
+ "label": "EventList",
+ "type": "List[uint]"
},
- "260": {
- "id": 260,
- "cluster_id": 2820,
- "label": "DcCurrentMin",
- "type": "Optional[int]"
+ "65531": {
+ "id": 65531,
+ "cluster_id": 1872,
+ "label": "AttributeList",
+ "type": "List[uint]"
},
- "261": {
- "id": 261,
- "cluster_id": 2820,
- "label": "DcCurrentMax",
- "type": "Optional[int]"
+ "65532": {
+ "id": 65532,
+ "cluster_id": 1872,
+ "label": "FeatureMap",
+ "type": "uint"
},
- "262": {
- "id": 262,
- "cluster_id": 2820,
- "label": "DcPower",
- "type": "Optional[int]"
+ "65533": {
+ "id": 65533,
+ "cluster_id": 1872,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
+ "1873": {
+ "id": 1873,
+ "label": "CommissionerControl",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 1873,
+ "label": "SupportedDeviceCategories",
+ "type": "uint"
},
- "263": {
- "id": 263,
- "cluster_id": 2820,
- "label": "DcPowerMin",
- "type": "Optional[int]"
+ "65528": {
+ "id": 65528,
+ "cluster_id": 1873,
+ "label": "GeneratedCommandList",
+ "type": "List[uint]"
},
- "264": {
- "id": 264,
- "cluster_id": 2820,
- "label": "DcPowerMax",
- "type": "Optional[int]"
+ "65529": {
+ "id": 65529,
+ "cluster_id": 1873,
+ "label": "AcceptedCommandList",
+ "type": "List[uint]"
},
- "512": {
- "id": 512,
- "cluster_id": 2820,
- "label": "DcVoltageMultiplier",
- "type": "Optional[uint]"
+ "65530": {
+ "id": 65530,
+ "cluster_id": 1873,
+ "label": "EventList",
+ "type": "List[uint]"
},
- "513": {
- "id": 513,
- "cluster_id": 2820,
- "label": "DcVoltageDivisor",
- "type": "Optional[uint]"
+ "65531": {
+ "id": 65531,
+ "cluster_id": 1873,
+ "label": "AttributeList",
+ "type": "List[uint]"
},
- "514": {
- "id": 514,
- "cluster_id": 2820,
- "label": "DcCurrentMultiplier",
- "type": "Optional[uint]"
+ "65532": {
+ "id": 65532,
+ "cluster_id": 1873,
+ "label": "FeatureMap",
+ "type": "uint"
},
- "515": {
- "id": 515,
- "cluster_id": 2820,
- "label": "DcCurrentDivisor",
- "type": "Optional[uint]"
+ "65533": {
+ "id": 65533,
+ "cluster_id": 1873,
+ "label": "ClusterRevision",
+ "type": "uint"
+ }
+ }
+ },
+ "4294048773": {
+ "id": 4294048773,
+ "label": "UnitTesting",
+ "attributes": {
+ "0": {
+ "id": 0,
+ "cluster_id": 4294048773,
+ "label": "Boolean",
+ "type": "bool"
},
- "516": {
- "id": 516,
- "cluster_id": 2820,
- "label": "DcPowerMultiplier",
- "type": "Optional[uint]"
- },
- "517": {
- "id": 517,
- "cluster_id": 2820,
- "label": "DcPowerDivisor",
- "type": "Optional[uint]"
- },
- "768": {
- "id": 768,
- "cluster_id": 2820,
- "label": "AcFrequency",
- "type": "Optional[uint]"
- },
- "769": {
- "id": 769,
- "cluster_id": 2820,
- "label": "AcFrequencyMin",
- "type": "Optional[uint]"
- },
- "770": {
- "id": 770,
- "cluster_id": 2820,
- "label": "AcFrequencyMax",
- "type": "Optional[uint]"
- },
- "771": {
- "id": 771,
- "cluster_id": 2820,
- "label": "NeutralCurrent",
- "type": "Optional[uint]"
- },
- "772": {
- "id": 772,
- "cluster_id": 2820,
- "label": "TotalActivePower",
- "type": "Optional[int]"
- },
- "773": {
- "id": 773,
- "cluster_id": 2820,
- "label": "TotalReactivePower",
- "type": "Optional[int]"
- },
- "774": {
- "id": 774,
- "cluster_id": 2820,
- "label": "TotalApparentPower",
- "type": "Optional[uint]"
- },
- "775": {
- "id": 775,
- "cluster_id": 2820,
- "label": "Measured1stHarmonicCurrent",
- "type": "Optional[int]"
- },
- "776": {
- "id": 776,
- "cluster_id": 2820,
- "label": "Measured3rdHarmonicCurrent",
- "type": "Optional[int]"
- },
- "777": {
- "id": 777,
- "cluster_id": 2820,
- "label": "Measured5thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "778": {
- "id": 778,
- "cluster_id": 2820,
- "label": "Measured7thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "779": {
- "id": 779,
- "cluster_id": 2820,
- "label": "Measured9thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "780": {
- "id": 780,
- "cluster_id": 2820,
- "label": "Measured11thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "781": {
- "id": 781,
- "cluster_id": 2820,
- "label": "MeasuredPhase1stHarmonicCurrent",
- "type": "Optional[int]"
- },
- "782": {
- "id": 782,
- "cluster_id": 2820,
- "label": "MeasuredPhase3rdHarmonicCurrent",
- "type": "Optional[int]"
- },
- "783": {
- "id": 783,
- "cluster_id": 2820,
- "label": "MeasuredPhase5thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "784": {
- "id": 784,
- "cluster_id": 2820,
- "label": "MeasuredPhase7thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "785": {
- "id": 785,
- "cluster_id": 2820,
- "label": "MeasuredPhase9thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "786": {
- "id": 786,
- "cluster_id": 2820,
- "label": "MeasuredPhase11thHarmonicCurrent",
- "type": "Optional[int]"
- },
- "1024": {
- "id": 1024,
- "cluster_id": 2820,
- "label": "AcFrequencyMultiplier",
- "type": "Optional[uint]"
- },
- "1025": {
- "id": 1025,
- "cluster_id": 2820,
- "label": "AcFrequencyDivisor",
- "type": "Optional[uint]"
- },
- "1026": {
- "id": 1026,
- "cluster_id": 2820,
- "label": "PowerMultiplier",
- "type": "Optional[uint]"
- },
- "1027": {
- "id": 1027,
- "cluster_id": 2820,
- "label": "PowerDivisor",
- "type": "Optional[uint]"
- },
- "1028": {
- "id": 1028,
- "cluster_id": 2820,
- "label": "HarmonicCurrentMultiplier",
- "type": "Optional[int]"
- },
- "1029": {
- "id": 1029,
- "cluster_id": 2820,
- "label": "PhaseHarmonicCurrentMultiplier",
- "type": "Optional[int]"
- },
- "1280": {
- "id": 1280,
- "cluster_id": 2820,
- "label": "InstantaneousVoltage",
- "type": "Optional[int]"
- },
- "1281": {
- "id": 1281,
- "cluster_id": 2820,
- "label": "InstantaneousLineCurrent",
- "type": "Optional[uint]"
- },
- "1282": {
- "id": 1282,
- "cluster_id": 2820,
- "label": "InstantaneousActiveCurrent",
- "type": "Optional[int]"
- },
- "1283": {
- "id": 1283,
- "cluster_id": 2820,
- "label": "InstantaneousReactiveCurrent",
- "type": "Optional[int]"
- },
- "1284": {
- "id": 1284,
- "cluster_id": 2820,
- "label": "InstantaneousPower",
- "type": "Optional[int]"
- },
- "1285": {
- "id": 1285,
- "cluster_id": 2820,
- "label": "RmsVoltage",
- "type": "Optional[uint]"
- },
- "1286": {
- "id": 1286,
- "cluster_id": 2820,
- "label": "RmsVoltageMin",
- "type": "Optional[uint]"
- },
- "1287": {
- "id": 1287,
- "cluster_id": 2820,
- "label": "RmsVoltageMax",
- "type": "Optional[uint]"
- },
- "1288": {
- "id": 1288,
- "cluster_id": 2820,
- "label": "RmsCurrent",
- "type": "Optional[uint]"
- },
- "1289": {
- "id": 1289,
- "cluster_id": 2820,
- "label": "RmsCurrentMin",
- "type": "Optional[uint]"
- },
- "1290": {
- "id": 1290,
- "cluster_id": 2820,
- "label": "RmsCurrentMax",
- "type": "Optional[uint]"
- },
- "1291": {
- "id": 1291,
- "cluster_id": 2820,
- "label": "ActivePower",
- "type": "Optional[int]"
- },
- "1292": {
- "id": 1292,
- "cluster_id": 2820,
- "label": "ActivePowerMin",
- "type": "Optional[int]"
- },
- "1293": {
- "id": 1293,
- "cluster_id": 2820,
- "label": "ActivePowerMax",
- "type": "Optional[int]"
- },
- "1294": {
- "id": 1294,
- "cluster_id": 2820,
- "label": "ReactivePower",
- "type": "Optional[int]"
- },
- "1295": {
- "id": 1295,
- "cluster_id": 2820,
- "label": "ApparentPower",
- "type": "Optional[uint]"
- },
- "1296": {
- "id": 1296,
- "cluster_id": 2820,
- "label": "PowerFactor",
- "type": "Optional[int]"
- },
- "1297": {
- "id": 1297,
- "cluster_id": 2820,
- "label": "AverageRmsVoltageMeasurementPeriod",
- "type": "Optional[uint]"
- },
- "1299": {
- "id": 1299,
- "cluster_id": 2820,
- "label": "AverageRmsUnderVoltageCounter",
- "type": "Optional[uint]"
- },
- "1300": {
- "id": 1300,
- "cluster_id": 2820,
- "label": "RmsExtremeOverVoltagePeriod",
- "type": "Optional[uint]"
- },
- "1301": {
- "id": 1301,
- "cluster_id": 2820,
- "label": "RmsExtremeUnderVoltagePeriod",
- "type": "Optional[uint]"
- },
- "1302": {
- "id": 1302,
- "cluster_id": 2820,
- "label": "RmsVoltageSagPeriod",
- "type": "Optional[uint]"
- },
- "1303": {
- "id": 1303,
- "cluster_id": 2820,
- "label": "RmsVoltageSwellPeriod",
- "type": "Optional[uint]"
- },
- "1536": {
- "id": 1536,
- "cluster_id": 2820,
- "label": "AcVoltageMultiplier",
- "type": "Optional[uint]"
- },
- "1537": {
- "id": 1537,
- "cluster_id": 2820,
- "label": "AcVoltageDivisor",
- "type": "Optional[uint]"
- },
- "1538": {
- "id": 1538,
- "cluster_id": 2820,
- "label": "AcCurrentMultiplier",
- "type": "Optional[uint]"
- },
- "1539": {
- "id": 1539,
- "cluster_id": 2820,
- "label": "AcCurrentDivisor",
- "type": "Optional[uint]"
- },
- "1540": {
- "id": 1540,
- "cluster_id": 2820,
- "label": "AcPowerMultiplier",
- "type": "Optional[uint]"
- },
- "1541": {
- "id": 1541,
- "cluster_id": 2820,
- "label": "AcPowerDivisor",
- "type": "Optional[uint]"
- },
- "1792": {
- "id": 1792,
- "cluster_id": 2820,
- "label": "OverloadAlarmsMask",
- "type": "Optional[uint]"
- },
- "1793": {
- "id": 1793,
- "cluster_id": 2820,
- "label": "VoltageOverload",
- "type": "Optional[int]"
- },
- "1794": {
- "id": 1794,
- "cluster_id": 2820,
- "label": "CurrentOverload",
- "type": "Optional[int]"
- },
- "2048": {
- "id": 2048,
- "cluster_id": 2820,
- "label": "AcOverloadAlarmsMask",
- "type": "Optional[uint]"
- },
- "2049": {
- "id": 2049,
- "cluster_id": 2820,
- "label": "AcVoltageOverload",
- "type": "Optional[int]"
- },
- "2050": {
- "id": 2050,
- "cluster_id": 2820,
- "label": "AcCurrentOverload",
- "type": "Optional[int]"
- },
- "2051": {
- "id": 2051,
- "cluster_id": 2820,
- "label": "AcActivePowerOverload",
- "type": "Optional[int]"
- },
- "2052": {
- "id": 2052,
- "cluster_id": 2820,
- "label": "AcReactivePowerOverload",
- "type": "Optional[int]"
- },
- "2053": {
- "id": 2053,
- "cluster_id": 2820,
- "label": "AverageRmsOverVoltage",
- "type": "Optional[int]"
- },
- "2054": {
- "id": 2054,
- "cluster_id": 2820,
- "label": "AverageRmsUnderVoltage",
- "type": "Optional[int]"
- },
- "2055": {
- "id": 2055,
- "cluster_id": 2820,
- "label": "RmsExtremeOverVoltage",
- "type": "Optional[int]"
- },
- "2056": {
- "id": 2056,
- "cluster_id": 2820,
- "label": "RmsExtremeUnderVoltage",
- "type": "Optional[int]"
- },
- "2057": {
- "id": 2057,
- "cluster_id": 2820,
- "label": "RmsVoltageSag",
- "type": "Optional[int]"
- },
- "2058": {
- "id": 2058,
- "cluster_id": 2820,
- "label": "RmsVoltageSwell",
- "type": "Optional[int]"
- },
- "2305": {
- "id": 2305,
- "cluster_id": 2820,
- "label": "LineCurrentPhaseB",
- "type": "Optional[uint]"
- },
- "2306": {
- "id": 2306,
- "cluster_id": 2820,
- "label": "ActiveCurrentPhaseB",
- "type": "Optional[int]"
- },
- "2307": {
- "id": 2307,
- "cluster_id": 2820,
- "label": "ReactiveCurrentPhaseB",
- "type": "Optional[int]"
- },
- "2309": {
- "id": 2309,
- "cluster_id": 2820,
- "label": "RmsVoltagePhaseB",
- "type": "Optional[uint]"
- },
- "2310": {
- "id": 2310,
- "cluster_id": 2820,
- "label": "RmsVoltageMinPhaseB",
- "type": "Optional[uint]"
- },
- "2311": {
- "id": 2311,
- "cluster_id": 2820,
- "label": "RmsVoltageMaxPhaseB",
- "type": "Optional[uint]"
- },
- "2312": {
- "id": 2312,
- "cluster_id": 2820,
- "label": "RmsCurrentPhaseB",
- "type": "Optional[uint]"
- },
- "2313": {
- "id": 2313,
- "cluster_id": 2820,
- "label": "RmsCurrentMinPhaseB",
- "type": "Optional[uint]"
- },
- "2314": {
- "id": 2314,
- "cluster_id": 2820,
- "label": "RmsCurrentMaxPhaseB",
- "type": "Optional[uint]"
- },
- "2315": {
- "id": 2315,
- "cluster_id": 2820,
- "label": "ActivePowerPhaseB",
- "type": "Optional[int]"
- },
- "2316": {
- "id": 2316,
- "cluster_id": 2820,
- "label": "ActivePowerMinPhaseB",
- "type": "Optional[int]"
- },
- "2317": {
- "id": 2317,
- "cluster_id": 2820,
- "label": "ActivePowerMaxPhaseB",
- "type": "Optional[int]"
- },
- "2318": {
- "id": 2318,
- "cluster_id": 2820,
- "label": "ReactivePowerPhaseB",
- "type": "Optional[int]"
- },
- "2319": {
- "id": 2319,
- "cluster_id": 2820,
- "label": "ApparentPowerPhaseB",
- "type": "Optional[uint]"
- },
- "2320": {
- "id": 2320,
- "cluster_id": 2820,
- "label": "PowerFactorPhaseB",
- "type": "Optional[int]"
- },
- "2321": {
- "id": 2321,
- "cluster_id": 2820,
- "label": "AverageRmsVoltageMeasurementPeriodPhaseB",
- "type": "Optional[uint]"
- },
- "2322": {
- "id": 2322,
- "cluster_id": 2820,
- "label": "AverageRmsOverVoltageCounterPhaseB",
- "type": "Optional[uint]"
- },
- "2323": {
- "id": 2323,
- "cluster_id": 2820,
- "label": "AverageRmsUnderVoltageCounterPhaseB",
- "type": "Optional[uint]"
- },
- "2324": {
- "id": 2324,
- "cluster_id": 2820,
- "label": "RmsExtremeOverVoltagePeriodPhaseB",
- "type": "Optional[uint]"
- },
- "2325": {
- "id": 2325,
- "cluster_id": 2820,
- "label": "RmsExtremeUnderVoltagePeriodPhaseB",
- "type": "Optional[uint]"
- },
- "2326": {
- "id": 2326,
- "cluster_id": 2820,
- "label": "RmsVoltageSagPeriodPhaseB",
- "type": "Optional[uint]"
- },
- "2327": {
- "id": 2327,
- "cluster_id": 2820,
- "label": "RmsVoltageSwellPeriodPhaseB",
- "type": "Optional[uint]"
- },
- "2561": {
- "id": 2561,
- "cluster_id": 2820,
- "label": "LineCurrentPhaseC",
- "type": "Optional[uint]"
- },
- "2562": {
- "id": 2562,
- "cluster_id": 2820,
- "label": "ActiveCurrentPhaseC",
- "type": "Optional[int]"
- },
- "2563": {
- "id": 2563,
- "cluster_id": 2820,
- "label": "ReactiveCurrentPhaseC",
- "type": "Optional[int]"
- },
- "2565": {
- "id": 2565,
- "cluster_id": 2820,
- "label": "RmsVoltagePhaseC",
- "type": "Optional[uint]"
- },
- "2566": {
- "id": 2566,
- "cluster_id": 2820,
- "label": "RmsVoltageMinPhaseC",
- "type": "Optional[uint]"
- },
- "2567": {
- "id": 2567,
- "cluster_id": 2820,
- "label": "RmsVoltageMaxPhaseC",
- "type": "Optional[uint]"
- },
- "2568": {
- "id": 2568,
- "cluster_id": 2820,
- "label": "RmsCurrentPhaseC",
- "type": "Optional[uint]"
- },
- "2569": {
- "id": 2569,
- "cluster_id": 2820,
- "label": "RmsCurrentMinPhaseC",
- "type": "Optional[uint]"
- },
- "2570": {
- "id": 2570,
- "cluster_id": 2820,
- "label": "RmsCurrentMaxPhaseC",
- "type": "Optional[uint]"
- },
- "2571": {
- "id": 2571,
- "cluster_id": 2820,
- "label": "ActivePowerPhaseC",
- "type": "Optional[int]"
- },
- "2572": {
- "id": 2572,
- "cluster_id": 2820,
- "label": "ActivePowerMinPhaseC",
- "type": "Optional[int]"
- },
- "2573": {
- "id": 2573,
- "cluster_id": 2820,
- "label": "ActivePowerMaxPhaseC",
- "type": "Optional[int]"
- },
- "2574": {
- "id": 2574,
- "cluster_id": 2820,
- "label": "ReactivePowerPhaseC",
- "type": "Optional[int]"
- },
- "2575": {
- "id": 2575,
- "cluster_id": 2820,
- "label": "ApparentPowerPhaseC",
- "type": "Optional[uint]"
- },
- "2576": {
- "id": 2576,
- "cluster_id": 2820,
- "label": "PowerFactorPhaseC",
- "type": "Optional[int]"
- },
- "2577": {
- "id": 2577,
- "cluster_id": 2820,
- "label": "AverageRmsVoltageMeasurementPeriodPhaseC",
- "type": "Optional[uint]"
- },
- "2578": {
- "id": 2578,
- "cluster_id": 2820,
- "label": "AverageRmsOverVoltageCounterPhaseC",
- "type": "Optional[uint]"
- },
- "2579": {
- "id": 2579,
- "cluster_id": 2820,
- "label": "AverageRmsUnderVoltageCounterPhaseC",
- "type": "Optional[uint]"
- },
- "2580": {
- "id": 2580,
- "cluster_id": 2820,
- "label": "RmsExtremeOverVoltagePeriodPhaseC",
- "type": "Optional[uint]"
- },
- "2581": {
- "id": 2581,
- "cluster_id": 2820,
- "label": "RmsExtremeUnderVoltagePeriodPhaseC",
- "type": "Optional[uint]"
- },
- "2582": {
- "id": 2582,
- "cluster_id": 2820,
- "label": "RmsVoltageSagPeriodPhaseC",
- "type": "Optional[uint]"
- },
- "2583": {
- "id": 2583,
- "cluster_id": 2820,
- "label": "RmsVoltageSwellPeriodPhaseC",
- "type": "Optional[uint]"
- },
- "65528": {
- "id": 65528,
- "cluster_id": 2820,
- "label": "GeneratedCommandList",
- "type": "List[uint]"
- },
- "65529": {
- "id": 65529,
- "cluster_id": 2820,
- "label": "AcceptedCommandList",
- "type": "List[uint]"
- },
- "65530": {
- "id": 65530,
- "cluster_id": 2820,
- "label": "EventList",
- "type": "List[uint]"
- },
- "65531": {
- "id": 65531,
- "cluster_id": 2820,
- "label": "AttributeList",
- "type": "List[uint]"
- },
- "65532": {
- "id": 65532,
- "cluster_id": 2820,
- "label": "FeatureMap",
- "type": "uint"
- },
- "65533": {
- "id": 65533,
- "cluster_id": 2820,
- "label": "ClusterRevision",
- "type": "uint"
- }
- }
- },
- "4294048773": {
- "id": 4294048773,
- "label": "UnitTesting",
- "attributes": {
- "0": {
- "id": 0,
- "cluster_id": 4294048773,
- "label": "Boolean",
- "type": "bool"
- },
- "1": {
- "id": 1,
- "cluster_id": 4294048773,
- "label": "Bitmap8",
- "type": "uint"
+ "1": {
+ "id": 1,
+ "cluster_id": 4294048773,
+ "label": "Bitmap8",
+ "type": "uint"
},
"2": {
"id": 2,
@@ -12218,12 +11796,36 @@ export const clusters: Record = {
"label": "ClusterErrorBoolean",
"type": "bool"
},
+ "51": {
+ "id": 51,
+ "cluster_id": 4294048773,
+ "label": "GlobalEnum",
+ "type": "aenum TestGlobalEnum"
+ },
+ "52": {
+ "id": 52,
+ "cluster_id": 4294048773,
+ "label": "GlobalStruct",
+ "type": "Globals.Structs.TestGlobalStruct"
+ },
"255": {
"id": 255,
"cluster_id": 4294048773,
"label": "Unsupported",
"type": "Optional[bool]"
},
+ "12288": {
+ "id": 12288,
+ "cluster_id": 4294048773,
+ "label": "ReadFailureCode",
+ "type": "Optional[uint]"
+ },
+ "12289": {
+ "id": 12289,
+ "cluster_id": 4294048773,
+ "label": "FailureInt32U",
+ "type": "Optional[uint]"
+ },
"16384": {
"id": 16384,
"cluster_id": 4294048773,
@@ -12428,6 +12030,18 @@ export const clusters: Record = {
"label": "WriteOnlyInt8u",
"type": "Optional[uint]"
},
+ "16435": {
+ "id": 16435,
+ "cluster_id": 4294048773,
+ "label": "NullableGlobalEnum",
+ "type": "Union[Nullable, Globals.Enums.TestGlobalEnum]"
+ },
+ "16436": {
+ "id": 16436,
+ "cluster_id": 4294048773,
+ "label": "NullableGlobalStruct",
+ "type": "Union[Nullable, Globals.Structs.TestGlobalStruct]"
+ },
"65528": {
"id": 65528,
"cluster_id": 4294048773,
@@ -12601,6 +12215,60 @@ export const clusters: Record = {
"cluster_id": 319486977,
"label": "Current",
"type": "float32"
+ },
+ "319422483": {
+ "id": 319422483,
+ "cluster_id": 319486977,
+ "label": "Altitude",
+ "type": "float32"
+ },
+ "319422484": {
+ "id": 319422484,
+ "cluster_id": 319486977,
+ "label": "Pressure",
+ "type": "float32"
+ },
+ "319422485": {
+ "id": 319422485,
+ "cluster_id": 319486977,
+ "label": "WeatherTrend",
+ "type": "int"
+ },
+ "319422488": {
+ "id": 319422488,
+ "cluster_id": 319486977,
+ "label": "ValvePosition",
+ "type": "int"
+ },
+ "319422477": {
+ "id": 319422477,
+ "cluster_id": 319486977,
+ "label": "MotionSensitivity",
+ "type": "int"
+ }
+ }
+ },
+ "305134641": {
+ "id": 305134641,
+ "label": "InovelliCluster",
+ "attributes": {
+ "305070177": {
+ "id": 305070177,
+ "cluster_id": 305134641,
+ "label": "LEDIndicatorIntensityOn",
+ "type": "uint"
+ },
+ "305070178": {
+ "id": 305070178,
+ "cluster_id": 305134641,
+ "label": "LEDIndicatorIntensityOff",
+ "type": "uint"
+ },
+ "305070342": {
+ "id": 305070342,
+ "cluster_id": 305134641,
+ "label": "ClearNotificationWithConfigDoubleTap",
+ "type": "bool"
}
}
},
@@ -12651,5 +12319,65 @@ export const clusters: Record = {
"type": "uint"
}
}
+ },
+ "2820": {
+ "id": 2820,
+ "label": "DraftElectricalMeasurementCluster",
+ "attributes": {
+ "1285": {
+ "id": 1285,
+ "cluster_id": 2820,
+ "label": "RmsVoltage",
+ "type": "uint"
+ },
+ "1288": {
+ "id": 1288,
+ "cluster_id": 2820,
+ "label": "RmsCurrent",
+ "type": "uint"
+ },
+ "1291": {
+ "id": 1291,
+ "cluster_id": 2820,
+ "label": "ActivePower",
+ "type": "uint"
+ },
+ "1536": {
+ "id": 1536,
+ "cluster_id": 2820,
+ "label": "AcVoltageMultiplier",
+ "type": "uint"
+ },
+ "1537": {
+ "id": 1537,
+ "cluster_id": 2820,
+ "label": "AcVoltageDivisor",
+ "type": "uint"
+ },
+ "1538": {
+ "id": 1538,
+ "cluster_id": 2820,
+ "label": "AcCurrentMultiplier",
+ "type": "uint"
+ },
+ "1539": {
+ "id": 1539,
+ "cluster_id": 2820,
+ "label": "AcCurrentDivisor",
+ "type": "uint"
+ },
+ "1540": {
+ "id": 1540,
+ "cluster_id": 2820,
+ "label": "AcPowerMultiplier",
+ "type": "uint"
+ },
+ "1541": {
+ "id": 1541,
+ "cluster_id": 2820,
+ "label": "AcPowerDivisor",
+ "type": "uint"
+ }
+ }
}
}
diff --git a/dashboard/src/client/models/model.ts b/dashboard/src/client/models/model.ts
index 2c04fe66..bb0ef517 100644
--- a/dashboard/src/client/models/model.ts
+++ b/dashboard/src/client/models/model.ts
@@ -105,6 +105,14 @@ export interface APICommands {
requestArgs: {};
response: {};
};
+ set_acl_entry: {
+ requestArgs: {};
+ response: {};
+ };
+ set_node_binding: {
+ requestArgs: {};
+ response: {};
+ };
}
export interface CommandMessage {
diff --git a/dashboard/src/client/models/node.ts b/dashboard/src/client/models/node.ts
index 89e6af13..f09865a9 100644
--- a/dashboard/src/client/models/node.ts
+++ b/dashboard/src/client/models/node.ts
@@ -21,7 +21,7 @@ export class MatterNode {
get nodeLabel(): string {
const label = this.attributes["0/40/5"];
- if (!label) return '';
+ if (typeof label !== "string") return '';
if (label.includes("\u0000\u0000")) return '';
return label.trim();
}
diff --git a/dashboard/src/components/dialogs/acl/model.ts b/dashboard/src/components/dialogs/acl/model.ts
new file mode 100644
index 00000000..cf93df6d
--- /dev/null
+++ b/dashboard/src/components/dialogs/acl/model.ts
@@ -0,0 +1,100 @@
+
+export type AccessControlTargetStruct = {
+ cluster: number | undefined;
+ endpoint: number | undefined;
+ deviceType: number | undefined;
+};
+
+export type AccessControlEntryRawInput = {
+ "1": number;
+ "2": number;
+ "3": number[];
+ "4": AccessControlTargetStruct[] | undefined;
+ "254": number;
+};
+
+export type AccessControlEntryStruct = {
+ privilege: number;
+ authMode: number;
+ subjects: number[];
+ targets: AccessControlTargetStruct[] | undefined;
+ fabricIndex: number;
+};
+
+export class AccessControlTargetTransformer {
+ private static readonly KEY_MAPPING: {
+ [inputKey: string]: keyof AccessControlTargetStruct;
+ } = {
+ "0": "cluster",
+ "1": "endpoint",
+ "2": "deviceType",
+ };
+
+ public static transform(input: any): AccessControlTargetStruct {
+ if (!input || typeof input !== "object") {
+ throw new Error("Invalid input: expected an object");
+ }
+
+ const result: Partial = {};
+ const keyMapping = AccessControlTargetTransformer.KEY_MAPPING;
+
+ for (const key in input) {
+ if (key in keyMapping) {
+ const mappedKey = keyMapping[key];
+ if (mappedKey) {
+ const value = input[key];
+ if (value === undefined) continue;
+ result[mappedKey] = value;
+ }
+ }
+ }
+ return result as AccessControlTargetStruct;
+ }
+}
+
+export class AccessControlEntryDataTransformer {
+ private static readonly KEY_MAPPING: {
+ [inputKey: string]: keyof AccessControlEntryStruct;
+ } = {
+ "1": "privilege",
+ "2": "authMode",
+ "3": "subjects",
+ "4": "targets",
+ "254": "fabricIndex",
+ };
+
+ public static transform(input: any): AccessControlEntryStruct {
+ if (!input || typeof input !== "object") {
+ throw new Error("Invalid input: expected an object");
+ }
+
+ const result: Partial = {};
+ const keyMapping = AccessControlEntryDataTransformer.KEY_MAPPING;
+
+ for (const key in input) {
+ if (key in keyMapping) {
+ const mappedKey = keyMapping[key];
+ if (mappedKey) {
+ const value = input[key];
+ if (value === undefined) continue;
+ if (mappedKey === "subjects") {
+ result[mappedKey] = Array.isArray(value) ? value : undefined;
+ } else if (mappedKey === "targets") {
+ if (Array.isArray(value)) {
+ const _targets = Object.values(value).map((val) =>
+ AccessControlTargetTransformer.transform(val),
+ );
+ result[mappedKey] = _targets;
+ } else {
+ result[mappedKey] = undefined;
+ }
+ } else {
+ result[mappedKey] = value;
+ }
+ }
+ }
+ }
+
+ return result as AccessControlEntryStruct;
+ }
+}
diff --git a/dashboard/src/components/dialogs/binding/model.ts b/dashboard/src/components/dialogs/binding/model.ts
new file mode 100644
index 00000000..cc1ade35
--- /dev/null
+++ b/dashboard/src/components/dialogs/binding/model.ts
@@ -0,0 +1,52 @@
+export type InputType = {
+ [key: string]: number | number[] | undefined;
+};
+
+export interface BindingEntryStruct {
+ node: number;
+ group: number | undefined;
+ endpoint: number;
+ cluster: number | undefined;
+ fabricIndex: number | undefined;
+}
+
+export class BindingEntryDataTransformer {
+ private static readonly KEY_MAPPING: {
+ [inputKey: string]: keyof BindingEntryStruct;
+ } = {
+ "1": "node",
+ "3": "endpoint",
+ "4": "cluster",
+ "254": "fabricIndex",
+ };
+
+ public static transform(input: any): BindingEntryStruct {
+ if (!input || typeof input !== "object") {
+ throw new Error("Invalid input: expected an object");
+ }
+
+ const result: Partial = {};
+ const keyMapping = BindingEntryDataTransformer.KEY_MAPPING;
+
+ for (const key in input) {
+ if (key in keyMapping) {
+ const mappedKey = keyMapping[key];
+ if (mappedKey) {
+ const value = input[key];
+ if (value === undefined) {
+ continue;
+ }
+ if (mappedKey === "fabricIndex") {
+ result[mappedKey] = value === undefined ? undefined : Number(value);
+ } else if (mappedKey === "node" || mappedKey === "endpoint") {
+ result[mappedKey] = Number(value);
+ } else {
+ result[mappedKey] = value as BindingEntryStruct[typeof mappedKey];
+ }
+ }
+ }
+ }
+
+ return result as BindingEntryStruct;
+ }
+}
diff --git a/dashboard/src/components/dialogs/binding/node-binding-dialog.ts b/dashboard/src/components/dialogs/binding/node-binding-dialog.ts
new file mode 100644
index 00000000..ba187201
--- /dev/null
+++ b/dashboard/src/components/dialogs/binding/node-binding-dialog.ts
@@ -0,0 +1,434 @@
+import "@material/web/button/text-button";
+import "@material/web/dialog/dialog";
+import "@material/web/list/list";
+import "@material/web/list/list-item";
+import "../../../components/ha-svg-icon";
+import "@material/web/textfield/outlined-text-field";
+import type { MdOutlinedTextField } from "@material/web/textfield/outlined-text-field";
+
+import { html, LitElement, css, nothing } from "lit";
+import { customElement, property, query } from "lit/decorators.js";
+import { MatterNode } from "../../../client/models/node";
+import { preventDefault } from "../../../util/prevent_default";
+import { MatterClient } from "../../../client/client";
+import {
+ InputType,
+ BindingEntryStruct,
+ BindingEntryDataTransformer,
+} from "./model";
+
+import {
+ AccessControlEntryDataTransformer,
+ AccessControlEntryStruct,
+ AccessControlTargetStruct,
+} from "../acl/model";
+
+import { consume } from "@lit/context";
+import { clientContext } from "../../../client/client-context";
+
+@customElement("node-binding-dialog")
+export class NodeBindingDialog extends LitElement {
+ @consume({ context: clientContext, subscribe: true })
+ @property({ attribute: false })
+ public client!: MatterClient;
+
+ @property()
+ public node?: MatterNode;
+
+ @property({ attribute: false })
+ endpoint!: number;
+
+ @query("md-outlined-text-field[name='NodeId']")
+ private _targetNodeId!: MdOutlinedTextField;
+
+ @query("md-outlined-text-field[name='Endpoint']")
+ private _targetEndpoint!: MdOutlinedTextField;
+
+ @query("md-outlined-text-field[name='Cluster']")
+ private _targetCluster!: MdOutlinedTextField;
+
+ private fetchBindingEntry(): BindingEntryStruct[] {
+ const bindings_raw: [] = this.node!.attributes[this.endpoint + "/30/0"];
+ return Object.values(bindings_raw).map((value) =>
+ BindingEntryDataTransformer.transform(value),
+ );
+ }
+
+ private fetchACLEntry(targetNodeId: number): AccessControlEntryStruct[] {
+ const acl_cluster_raw: [InputType] =
+ this.client.nodes[targetNodeId].attributes["0/31/0"];
+ return Object.values(acl_cluster_raw).map((value: InputType) =>
+ AccessControlEntryDataTransformer.transform(value),
+ );
+ }
+
+ private async deleteBindingHandler(index: number): Promise {
+ const rawBindings = this.fetchBindingEntry();
+ try {
+ const targetNodeId = rawBindings[index].node;
+ const endpoint = rawBindings[index].endpoint;
+ await this.removeNodeAtACLEntry(
+ this.node!.node_id,
+ endpoint,
+ targetNodeId,
+ );
+ const updatedBindings = this.removeBindingAtIndex(rawBindings, index);
+ await this.syncBindingUpdates(updatedBindings, index);
+ } catch (error) {
+ this.handleBindingDeletionError(error);
+ }
+ }
+
+ private async removeNodeAtACLEntry(
+ sourceNodeId: number,
+ sourceEndpoint: number,
+ targetNodeId: number,
+ ): Promise {
+ const aclEntries = this.fetchACLEntry(targetNodeId);
+
+ const updatedACLEntries = aclEntries
+ .map((entry) =>
+ this.removeEntryAtACL(sourceNodeId, sourceEndpoint, entry),
+ )
+ .filter((entry): entry is Exclude => entry !== null);
+
+ await this.client.setACLEntry(targetNodeId, updatedACLEntries);
+ }
+
+ private removeEntryAtACL(
+ nodeId: number,
+ sourceEndpoint: number,
+ entry: AccessControlEntryStruct,
+ ): AccessControlEntryStruct | undefined {
+ const hasSubject = entry.subjects!.includes(nodeId);
+ if (!hasSubject) return entry;
+
+ const hasTarget = entry.targets!.filter(
+ (item) => item.endpoint === sourceEndpoint,
+ );
+ return hasTarget.length > 0 ? undefined : entry;
+ }
+
+ private removeBindingAtIndex(
+ bindings: BindingEntryStruct[],
+ index: number,
+ ): BindingEntryStruct[] {
+ return [...bindings.slice(0, index), ...bindings.slice(index + 1)];
+ }
+
+ private async syncBindingUpdates(
+ updatedBindings: BindingEntryStruct[],
+ index: number,
+ ): Promise {
+ await this.client.setNodeBinding(
+ this.node!.node_id,
+ this.endpoint,
+ updatedBindings,
+ );
+
+ const attributePath = `${this.endpoint}/30/0`;
+ const updatedAttributes = {
+ ...this.node!.attributes,
+ [attributePath]: this.removeBindingAtIndex(
+ this.node!.attributes[attributePath],
+ index,
+ ),
+ };
+
+ this.node!.attributes = updatedAttributes;
+ this.requestUpdate();
+ }
+
+ private handleBindingDeletionError(error: unknown): void {
+ const errorMessage = error instanceof Error ? error.message : String(error);
+ console.error(`Binding deletion failed: ${errorMessage}`);
+ }
+
+ private async _updateEntry(
+ targetId: number,
+ path: string,
+ entry: T,
+ transformFn: (value: InputType) => T,
+ updateFn: (targetId: number, entries: T[]) => Promise,
+ ) {
+ try {
+ const rawEntries: [InputType] =
+ this.client.nodes[targetId].attributes[path];
+ const entries = Object.values(rawEntries).map(transformFn);
+ entries.push(entry);
+ return await updateFn(targetId, entries);
+ } catch (err) {
+ console.log(err);
+ }
+ }
+
+ private async add_target_acl(
+ targetNodeId: number,
+ entry: AccessControlEntryStruct,
+ ) {
+ try {
+ const result = (await this._updateEntry(
+ targetNodeId,
+ "0/31/0",
+ entry,
+ AccessControlEntryDataTransformer.transform,
+ this.client.setACLEntry.bind(this.client),
+ )) as { [key: string]: { Status: number } };
+ return result["0"].Status === 0;
+ } catch (err) {
+ console.error("add acl error:", err);
+ return false;
+ }
+ }
+
+ private async add_bindings(
+ endpoint: number,
+ bindingEntry: BindingEntryStruct,
+ ) {
+ const bindings = this.fetchBindingEntry();
+ bindings.push(bindingEntry);
+ try {
+ const result = (await this.client.setNodeBinding(
+ this.node!.node_id,
+ endpoint,
+ bindings,
+ )) as { [key: string]: { Status: number } };
+ return result["0"].Status === 0;
+ } catch (err) {
+ console.log("add bindings error:", err);
+ return false;
+ }
+ }
+
+ async addBindingHandler() {
+ const targetNodeId = this._targetNodeId.value
+ ? parseInt(this._targetNodeId.value, 10)
+ : undefined;
+ const targetEndpoint = this._targetEndpoint.value
+ ? parseInt(this._targetEndpoint.value, 10)
+ : undefined;
+ const targetCluster = this._targetCluster.value
+ ? parseInt(this._targetCluster.value, 10)
+ : undefined;
+
+ // Matter Server does not use random NodeIds, so this is ok for now, but needs to be adjusted later
+ if (
+ targetNodeId === undefined ||
+ targetNodeId <= 0 ||
+ targetNodeId > 65535
+ ) {
+ alert("Please enter a valid target node ID");
+ return;
+ }
+
+ if (
+ targetEndpoint === undefined ||
+ targetEndpoint <= 0 ||
+ targetEndpoint > 0xfffe
+ ) {
+ alert("Please enter a valid target endpoint");
+ return;
+ }
+
+ // cluster optional
+ if (targetCluster !== undefined) {
+ // We ignore vendor specific clusters for now
+ if (targetCluster < 0 || targetCluster > 0x7fff) {
+ alert("Please enter a valid target cluster");
+ return;
+ }
+ }
+
+ const targets: AccessControlTargetStruct = {
+ endpoint: targetEndpoint,
+ cluster: targetCluster,
+ deviceType: undefined,
+ };
+
+ const acl_entry: AccessControlEntryStruct = {
+ privilege: 5,
+ authMode: 2,
+ subjects: [this.node!.node_id],
+ targets: [targets],
+ fabricIndex: this.client.connection.serverInfo!.fabric_id,
+ };
+
+ const result_acl = await this.add_target_acl(targetNodeId, acl_entry);
+ if (!result_acl) {
+ alert("add target acl error!");
+ return;
+ }
+
+ const endpoint = this.endpoint;
+ const bindingEntry: BindingEntryStruct = {
+ node: targetNodeId,
+ endpoint: targetEndpoint,
+ group: undefined,
+ cluster: targetCluster,
+ fabricIndex: this.client.connection.serverInfo!.fabric_id,
+ };
+
+ const result_binding = await this.add_bindings(endpoint, bindingEntry);
+
+ if (result_binding) {
+ this._targetNodeId.value = "";
+ this._targetEndpoint.value = "";
+ this._targetCluster.value = "";
+ this.requestUpdate();
+ }
+ }
+
+ private _close() {
+ this.shadowRoot!.querySelector("md-dialog")!.close();
+ }
+
+ private _handleClosed() {
+ this.parentNode!.removeChild(this);
+ }
+
+ private onChange(e: Event) {
+ const textfield = e.target as MdOutlinedTextField;
+ const value = parseInt(textfield.value, 10);
+
+ if (
+ parseInt(textfield.max, 10) < value ||
+ value < parseInt(textfield.min, 10)
+ ) {
+ textfield.error = true;
+ textfield.errorText = "value error";
+ } else {
+ textfield.error = false;
+ }
+
+ // console.log(`value: ${value} error: ${textfield.error}`);
+ }
+
+ protected render() {
+ const bindings = Object.values(
+ this.node!.attributes[this.endpoint + "/30/0"],
+ ).map((entry) => BindingEntryDataTransformer.transform(entry));
+
+ return html`
+
+
+
+
+
+ ${Object.values(bindings).map(
+ (entry, index) => html`
+
+
+
node:${entry["node"]}
+
endpoint:${entry["endpoint"]}
+ ${entry["cluster"] ? html`
cluster:${entry["cluster"]}
` : nothing}
+
+
+
this.deleteBindingHandler(index)}
+ >delete
+
+ `,
+ )}
+
+
+
+
+ Note: The Cluster ID field is optional according to the Matter
+ specification. If you leave it blank, the binding applies to all
+ eligible clusters on the target endpoint. However, some devices
+ may require a specific cluster to be set in order for the
+ binding to function correctly. If you experience unexpected
+ behavior, try specifying the cluster explicitly.
+
+
+
+
+
+ Add
+ Cancel
+
+
+ `;
+ }
+
+ static styles = css`
+ .inline-group {
+ display: flex;
+ border: 2px solid #673ab7;
+ padding: 1px;
+ border-radius: 8px;
+ position: relative;
+ margin: 8px;
+ }
+
+ .group-input {
+ display: flex;
+ width: -webkit-fill-available;
+ }
+
+ .target-item {
+ display: inline-block;
+ padding: 20px 10px 10px 10px;
+ border-radius: 4px;
+ vertical-align: middle;
+ min-width: 80px;
+ text-align: center;
+ width: -webkit-fill-available;
+ }
+
+ .group-label {
+ position: absolute;
+ left: 15px;
+ top: -12px;
+ background: #673ab7;
+ color: white;
+ padding: 3px 15px;
+ border-radius: 4px;
+ }
+ `;
+}
+
+declare global {
+ interface HTMLElementTagNameMap {
+ "node-binding-dialog": NodeBindingDialog;
+ }
+}
diff --git a/dashboard/src/components/dialogs/binding/show-node-binding-dialog.ts b/dashboard/src/components/dialogs/binding/show-node-binding-dialog.ts
new file mode 100644
index 00000000..22351d8b
--- /dev/null
+++ b/dashboard/src/components/dialogs/binding/show-node-binding-dialog.ts
@@ -0,0 +1,17 @@
+import { MatterClient } from "../../../client/client";
+import { MatterNode } from "../../../client/models/node";
+
+export const showNodeBindingDialog = async (
+ client: MatterClient,
+ node: MatterNode,
+ endpoint: number,
+) => {
+ await import("./node-binding-dialog");
+ const dialog = document.createElement("node-binding-dialog");
+ dialog.client = client;
+ dialog.node = node;
+ dialog.endpoint = endpoint;
+ document
+ .querySelector("matter-dashboard-app")
+ ?.renderRoot.appendChild(dialog);
+};
diff --git a/dashboard/src/entrypoint/main.ts b/dashboard/src/entrypoint/main.ts
index 21c157f3..df6c6593 100644
--- a/dashboard/src/entrypoint/main.ts
+++ b/dashboard/src/entrypoint/main.ts
@@ -6,20 +6,26 @@ async function main() {
let url = "";
// Detect if we're running in the (production) webserver included in the matter server or not.
- const isProductionServer = location.href.includes(":5580") || location.href.includes("hassio_ingress");
+ const isProductionServer = location.origin.includes(":5580") || location.href.includes("hassio_ingress") || location.href.includes("/api/ingress/");
if (!isProductionServer) {
// development server, ask for url to matter server
let storageUrl = localStorage.getItem("matterURL");
if (!storageUrl) {
+ const urlParams = new URLSearchParams(window.location.search);
+ const suggestedUrl = urlParams.get('url');
storageUrl = prompt(
"Enter Websocket URL to a running Matter Server",
- "ws://localhost:5580/ws"
+ suggestedUrl || "ws://localhost:5580/ws"
);
if (!storageUrl) {
alert("Unable to connect without URL");
return;
}
+ if (suggestedUrl) {
+ // Remove suggested url from address without redirecting
+ history.pushState({}, "", window.location.pathname);
+ }
localStorage.setItem("matterURL", storageUrl);
}
url = storageUrl;
diff --git a/dashboard/src/pages/components/context.ts b/dashboard/src/pages/components/context.ts
new file mode 100644
index 00000000..f0a0c7d6
--- /dev/null
+++ b/dashboard/src/pages/components/context.ts
@@ -0,0 +1,5 @@
+
+import { createContext } from "@lit/context";
+
+// export const bindingContext = createContext
("");
+export const bindingContext = createContext("binding");
diff --git a/dashboard/src/pages/components/node-details.ts b/dashboard/src/pages/components/node-details.ts
index 437c9aeb..8cea5ce0 100644
--- a/dashboard/src/pages/components/node-details.ts
+++ b/dashboard/src/pages/components/node-details.ts
@@ -5,7 +5,15 @@ import "@material/web/divider/divider";
import "@material/web/iconbutton/icon-button";
import "@material/web/list/list";
import "@material/web/list/list-item";
-import { mdiChatProcessing, mdiShareVariant, mdiTrashCan, mdiUpdate } from "@mdi/js";
+import {
+ mdiChatProcessing,
+ mdiShareVariant,
+ mdiTrashCan,
+ mdiUpdate,
+ mdiLink,
+} from "@mdi/js";
+
+import { consume } from "@lit/context";
import { LitElement, css, html, nothing } from "lit";
import { customElement, property, state } from "lit/decorators.js";
import { MatterClient } from "../../client/client";
@@ -17,6 +25,8 @@ import {
} from "../../components/dialog-box/show-dialog-box";
import "../../components/ha-svg-icon";
import { getEndpointDeviceTypes } from "../matter-endpoint-view";
+import { bindingContext } from "./context";
+import { showNodeBindingDialog } from "../../components/dialogs/binding/show-node-binding-dialog";
function getNodeDeviceTypes(node: MatterNode): DeviceType[] {
const uniqueEndpoints = new Set(
@@ -40,8 +50,15 @@ export class NodeDetails extends LitElement {
@state()
private _updateInitiated: boolean = false;
+ @consume({ context: bindingContext })
+ @property({ attribute: false })
+ endpoint!: number;
+
protected render() {
if (!this.node) return html``;
+
+ const bindings = this.node.attributes[this.endpoint + "/30/0"];
+
return html`
@@ -90,6 +107,15 @@ export class NodeDetails extends LitElement {
Update in progress (${this.node.updateStateProgress || 0}%) `
: html`Update `}
+ ${bindings
+ ? html`
+
+ Binding
+
+
+ `
+ : nothing}
+
Share
Remove
@@ -144,6 +170,14 @@ export class NodeDetails extends LitElement {
}
}
+ private async _binding() {
+ try {
+ showNodeBindingDialog(this.client!, this.node!, this.endpoint!);
+ } catch (err: any) {
+ console.log(err);
+ }
+ }
+
private async _searchUpdate() {
const nodeUpdate = await this.client.checkNodeUpdate(this.node!.node_id);
if (!nodeUpdate) {
diff --git a/dashboard/src/pages/matter-cluster-view.ts b/dashboard/src/pages/matter-cluster-view.ts
index f604531a..3ca3ea4a 100644
--- a/dashboard/src/pages/matter-cluster-view.ts
+++ b/dashboard/src/pages/matter-cluster-view.ts
@@ -9,6 +9,9 @@ import { clusters } from "../client/models/descriptions";
import { MatterNode } from "../client/models/node";
import { showAlertDialog } from "../components/dialog-box/show-dialog-box";
import "../components/ha-svg-icon";
+import "../pages/components/node-details";
+import { provide } from "@lit/context";
+import { bindingContext } from "./components/context";
declare global {
interface HTMLElementTagNameMap {
@@ -37,8 +40,9 @@ class MatterClusterView extends LitElement {
@property()
public node?: MatterNode;
+ @provide({ context: bindingContext })
@property()
- public endpoint?: number;
+ public endpoint!: number;
@property()
public cluster?: number;
diff --git a/dashboard/src/pages/matter-endpoint-view.ts b/dashboard/src/pages/matter-endpoint-view.ts
index 09953e2b..f96b6436 100644
--- a/dashboard/src/pages/matter-endpoint-view.ts
+++ b/dashboard/src/pages/matter-endpoint-view.ts
@@ -27,7 +27,10 @@ function getUniqueClusters(node: MatterNode, endpoint: Number) {
export function getEndpointDeviceTypes(node: MatterNode, endpoint: Number): DeviceType[] {
const rawValues: Record[] | undefined = node.attributes[`${endpoint}/29/0`];
if (!rawValues) return [];
- return rawValues.map((rawValue) => { return device_types[rawValue["0"] || rawValue["deviceType"]] })
+ return rawValues.map((rawValue) => {
+ const id = rawValue["0"] ?? rawValue["deviceType"];
+ return device_types[id] || { id: id ?? -1, label: `Unknown Device Type (${id})`, clusters: [] };
+ });
}
@customElement("matter-endpoint-view")
diff --git a/dashboard/src/pages/matter-node-view.ts b/dashboard/src/pages/matter-node-view.ts
index 02df5e54..718f2950 100644
--- a/dashboard/src/pages/matter-node-view.ts
+++ b/dashboard/src/pages/matter-node-view.ts
@@ -11,6 +11,7 @@ import "./components/header";
import "./components/node-details";
import { mdiChevronRight } from "@mdi/js";
import { MatterNode } from "../client/models/node";
+import { getEndpointDeviceTypes } from "./matter-endpoint-view";
declare global {
interface HTMLElementTagNameMap {
@@ -72,6 +73,9 @@ class MatterNodeView extends LitElement {
Endpoint ${endPointId}
+
+ Device Type(s): ${getEndpointDeviceTypes(this.node!, endPointId).map(deviceType => { return deviceType.label }).join(" / ")}
+
`;
diff --git a/docs/docker.md b/docs/docker.md
new file mode 100644
index 00000000..42eb60a7
--- /dev/null
+++ b/docs/docker.md
@@ -0,0 +1,76 @@
+# Running Matter Server in Docker
+
+For testing/evaluation purposes or as a guideline towards other application developers that want to run the Matter Server, we do provide an [official Docker container image](https://github.com/matter-js/python-matter-server/pkgs/container/python-matter-server). Just make sure that the underlying operating system on which you intend to run the docker container matches the [requirements needed for Matter and Thread](os_requirements.md) so better not attempt to run it on a specific purpose operating system such as a NAS.
+
+> [!NOTE] **Attention Home Assistant users:** The docker image is provided as-is and without official support (due to all the complex requirements to the underlying host/OS). Use it at your own risk if you know what you're doing.
+
+We strongly recommend using Home Assistant OS along with the official Matter
+Server add-on to use Matter with Home Assistant. The Matter integration
+automatically installs the Matter Server as an add-on. Please refer to the
+[Home Assistant documentation](https://www.home-assistant.io/integrations/matter/).
+
+Home Assistant OS has been tested and tuned to be used with Matter and Thread,
+which makes this combination the best tested and largely worry free
+environment.
+
+If you still prefer a self-managed container installation, you might experience
+communication issues with Matter devices, especially Thread based devices.
+This is mostly because the container installation uses host networking, and
+relies on the networking managed by your operating system.
+
+## Running the Matter Server using container image
+
+With the following command you can run the Matter Server in a container using
+Docker. The Matter network data (fabric information) are stored in a newly
+created directory `data` in the current directory. Adjust the command to
+choose another location instead.
+
+```
+mkdir data
+docker run -d \
+ --name matter-server \
+ --restart=unless-stopped \
+ --security-opt apparmor=unconfined \
+ -v $(pwd)/data:/data \
+ --network=host \
+ ghcr.io/matter-js/python-matter-server:stable
+```
+
+> [!NOTE]
+> The container has a default command line set (see Dockerfile). If you intend to pass additional arguments, you have to pass the default command line as well.
+
+To use local commissioning with Bluetooth, make sure to pass the D-Bus socket as well:
+
+```sh
+docker run -d \
+ --name matter-server \
+ --restart=unless-stopped \
+ --security-opt apparmor=unconfined \
+ -v $(pwd)/data:/data \
+ -v /run/dbus:/run/dbus:ro \
+ --network=host \
+ ghcr.io/matter-js/python-matter-server:stable --storage-path /data --paa-root-cert-dir /data/credentials --bluetooth-adapter 0
+```
+
+## Running using Docker compose
+
+```yaml
+services:
+ # python-matter-server
+ matter-server:
+ image: ghcr.io/matter-js/python-matter-server:stable
+ container_name: matter-server
+ restart: unless-stopped
+ # Required for mDNS to work correctly
+ network_mode: host
+ security_opt:
+ # Needed for Bluetooth via dbus
+ - apparmor:unconfined
+ volumes:
+ # Create an .env file that sets the USERDIR environment variable.
+ - ${USERDIR:-$HOME}/docker/matter-server/data:/data/
+ # Required for Bluetooth via D-Bus
+ - /run/dbus:/run/dbus:ro
+ # If you adjust command line, make sure to pass the default CMD arguments too:
+ #command: --storage-path /data --paa-root-cert-dir /data/credentials --bluetooth-adapter 0
+```
diff --git a/docs/matter_logo.svg b/docs/matter_logo.svg
new file mode 100644
index 00000000..0843a0f9
--- /dev/null
+++ b/docs/matter_logo.svg
@@ -0,0 +1,11 @@
+
+
+ Bitmap
+
+
+
+
+
+
diff --git a/docs/os_requirements.md b/docs/os_requirements.md
new file mode 100644
index 00000000..f63139db
--- /dev/null
+++ b/docs/os_requirements.md
@@ -0,0 +1,75 @@
+# OS Requirements
+
+Matter is based on IPv6 link-local multicast protocols and thus running the Matter Server (or developing it) is not as straightforward as any other application, mostly due to the bad shape of IPv6 support in various Linux distributions, let alone the IPv6 Neighbor
+Discovery Protocol, which is required for Thread.
+
+## Networking
+
+Matter uses link-local multicast protocols which do not work across different LANs or VLANs so best to use either a complete flat network or ensure that the machine running Matter Server is on the same (v)LAN as the devices, any border routers and the phone/device used for commissioning.
+
+The host network interface needs IPv6 support enabled.
+
+Be aware of any (semi) professional networking gear such as Unifi or Omada which has options to filter multicast traffic, often called something like "Multicast optimizations" or something along those lines. Disable such features, they are helpful in a high density enterprise network, but they're killing domestic protocols that rely on multicast like Matter, Airplay etc.
+
+Also do not enable any mdns forwarders on the network (the option is called mDNS on Unifi for example) as they tend to corrupt or severely hinder the Matter packets on the network.
+
+In some cases it is known that IGMP/MLD snopping implementations on network gear may help or hinder Matter traffic. Play with these options if you have network equipment that offer it.
+
+As a general rule of thumb, if you use standard, home user oriented network equipment, you have the highest rate of success with Matter.
+
+## Operating system
+
+The only supported operating systems for developing or running the Matter Server are (recent) versions of (64 bits) MacOS and a very recent distribution (including kernel) of Linux. Running it on non 64 bits architecture or another operating system (even WSL) is not supported.
+
+For a MacOS (development) environment, things will work fine out of the box from MacOS 14 or higher (arm-based CPU). In combination with a python venv, it makes up for the recommended development environment for working on the Matter codebase.
+
+For a Linux operating system, keep the following recommendations in mind:
+
+> your host must process ICMPv6 Router Advertisements. See the [openthread.io
+> Bidirectional IPv6 Connectivity code labs](https://openthread.io/codelabs/openthread-border-router#6)
+> on how-to setup your host correctly. Note that NetworkManager has its own ICMPv6
+> Router Advertisement processing. A recent version of NetworkManager is
+> necessary, and there are still known issues (see NetworkManager issue
+> [#1232](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1232)).
+
+The Home Assistant Operating System 10 and newer correctly processes ICMPv6 Router Advertisements. The Matter Server is provided as an add-on to that operating system, thus including all the required fixes.
+
+### Requirements to communicate with Thread devices through Thread border routers
+
+For communication through Thread border routers which are not running on the same
+host as the Matter Controller server to work, IPv6 routing needs to be properly
+working. IPv6 routing is largely setup automatically through the IPv6 Neighbor
+Discovery Protocol, specifically the Route Information Options (RIO). However,
+if IPv6 Neighbor Discovery RIO's are processed, and processed correctly depends on the network
+management software your system is using. There may be bugs and caveats in
+processing this Route Information Options.
+
+In general, make sure the kernel option `CONFIG_IPV6_ROUTER_PREF` is enabled and
+that IPv6 forwarding is disabled (sysctl variable `net.ipv6.conf.all.forwarding`).
+If IPv6 forwarding is enabled, the Linux kernel doesn't employ reachability
+probing (RFC 4191), which can lead to longer outages (up to 30min) until
+network changes are detected.
+
+If you are using NetworkManager, make sure to use at least NetworkManager 1.42.
+Previous versions lose track of routes and stale routes can lead to unreachable
+Thread devices. All current released NetworkManager versions can't handle
+multiple routes to the same network properly. This means if you have multiple
+Thread border routers, the fallback won't work immediately (see [NetworkManager
+issue #1232](https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1232)).
+
+We currently don't have experience with systemd-networkd. It seems to have its
+own IPv6 Neighbor Discovery Protocol handling.
+
+If you don't use NetworkManager or systemd-networkd, you can use the kernel's
+IPv6 Neighbor Discovery Protocol handling.
+
+Make sure the kernel options `CONFIG_IPV6_ROUTE_INFO` is enabled and the
+following sysctl variables are set:
+
+```sh
+sysctl -w net.ipv6.conf.wlan0.accept_ra=1
+sysctl -w net.ipv6.conf.wlan0.accept_ra_rt_info_max_plen=64
+```
+
+If your system has IPv6 forwarding enabled (not recommended, see above), you'll
+have to use `2` for the accept_ra variable. See also the [Thread Border Router - Bidirectional IPv6 Connectivity and DNS-Based Service Discovery codelab](https://openthread.io/codelabs/openthread-border-router#6).
diff --git a/docs/websockets_api.md b/docs/websockets_api.md
new file mode 100644
index 00000000..a6b1cbb8
--- /dev/null
+++ b/docs/websockets_api.md
@@ -0,0 +1,208 @@
+# Websocket documentation
+
+This list is not intended to be complete, for a complete oversight see the client implementation.
+
+## Websocket commands
+
+Here are the most frequently used commands:
+
+**Set WiFi credentials**
+
+Inform the controller about the WiFi credentials it needs to send when commissioning a new device.
+
+```json
+{
+ "message_id": "1",
+ "command": "set_wifi_credentials",
+ "args": {
+ "ssid": "wifi-name-here",
+ "credentials": "wifi-password-here"
+ }
+}
+```
+
+**Set Thread dataset**
+
+Inform the controller about the Thread credentials it needs to use when commissioning a new device.
+
+```json
+{
+ "message_id": "1",
+ "command": "set_thread_dataset",
+ "args": {
+ "dataset": "put-credentials-here"
+ }
+}
+```
+
+**Commission with code**
+
+Commission a new device. For WiFi or Thread based devices, the credentials need to be set upfront, otherwise, commissioning will fail. Supports both QR-code syntax (MT:...) and manual pairing code as string.
+The controller will use bluetooth for the commissioning of wireless devices. If the machine running the Python Matter Server controller lacks Bluetooth support, commissioning will only work for devices already connected to the network (by cable or another controller).
+
+Matter QR-code
+
+```json
+{
+ "message_id": "2",
+ "command": "commission_with_code",
+ "args": {
+ "code": "MT:Y.ABCDEFG123456789"
+ }
+}
+```
+
+Manual pairing code
+
+```json
+{
+ "message_id": "2",
+ "command": "commission_with_code",
+ "args": {
+ "code": "35325335079",
+ "network_only": true
+ }
+}
+```
+
+**Open Commissioning window**
+
+Open a commissioning window to commission a device present on this controller to another.
+Returns code to use as discriminator.
+
+```json
+{
+ "message_id": "2",
+ "command": "open_commissioning_window",
+ "args": {
+ "node_id": 1
+ }
+}
+```
+
+**Get Nodes**
+
+Get all nodes already commissioned on the controller.
+
+```json
+{
+ "message_id": "2",
+ "command": "get_nodes"
+}
+```
+
+**Get Node**
+
+Get info of a single Node.
+
+```json
+{
+ "message_id": "2",
+ "command": "get_node",
+ "args": {
+ "node_id": 1
+ }
+}
+```
+
+**Start listening**
+
+When the start_listening command is issued, the server will dump all existing nodes. From that moment on all events (including node attribute changes) will be forwarded.
+
+```json
+{
+ "message_id": "3",
+ "command": "start_listening"
+}
+```
+
+**Read an attribute**
+
+Here is an example of reading `OnOff` attribute on a switch (OnOff cluster)
+
+```json
+{
+ "message_id": "read",
+ "command": "read_attribute",
+ "args": {
+ "node_id": 1,
+ "attribute_path": "1/6/0"
+ }
+}
+```
+
+**Write an attribute**
+
+Here is an example of writing `OnTime` attribute on a switch (OnOff cluster)
+
+```json
+{
+ "message_id": "write",
+ "command": "write_attribute",
+ "args": {
+ "node_id": 1,
+ "attribute_path": "1/6/16385",
+ "value": 10
+ }
+}
+```
+
+**Send a command**
+
+Here is an example of turning on a switch (OnOff cluster)
+
+```json
+{
+ "message_id": "example",
+ "command": "device_command",
+ "args": {
+ "endpoint_id": 1,
+ "node_id": 1,
+ "payload": {},
+ "cluster_id": 6,
+ "command_name": "On"
+ }
+}
+```
+
+**Python script to send a command**
+
+Because we use the datamodels of the Matter SDK, this is a little bit more involved.
+Here is an example of turning on a switch:
+
+```python
+import json
+
+# Import the CHIP clusters
+from chip.clusters import Objects as clusters
+
+# Import the ability to turn objects into dictionaries, and vice-versa
+from matter_server.common.helpers.util import dataclass_from_dict,dataclass_to_dict
+
+command = clusters.OnOff.Commands.On()
+payload = dataclass_to_dict(command)
+
+
+message = {
+ "message_id": "example",
+ "command": "device_command",
+ "args": {
+ "endpoint_id": 1,
+ "node_id": 1,
+ "payload": payload,
+ "cluster_id": command.cluster_id,
+ "command_name": "On"
+ }
+}
+
+print(json.dumps(message, indent=2))
+```
+
+You can also provide parameters for the cluster commands. Here's how to change the brightness for example:
+
+```python
+command = clusters.LevelControl.Commands.MoveToLevelWithOnOff(
+ level=int(value), # provide a percentage
+ transitionTime=0, # in seconds
+)
+```
diff --git a/matter_server/client/client.py b/matter_server/client/client.py
index aa5f629d..abba334f 100644
--- a/matter_server/client/client.py
+++ b/matter_server/client/client.py
@@ -4,7 +4,7 @@
import asyncio
import logging
-from typing import TYPE_CHECKING, Any, Final, Optional, cast
+from typing import TYPE_CHECKING, Any, Final, Self, cast
import uuid
from chip.clusters import Objects as Clusters
@@ -80,9 +80,9 @@ def server_info(self) -> ServerInfoMessage | None:
def subscribe_events(
self,
callback: Callable[[EventType, Any], None],
- event_filter: Optional[EventType] = None,
- node_filter: Optional[int] = None,
- attr_path_filter: Optional[str] = None,
+ event_filter: EventType | None = None,
+ node_filter: int | None = None,
+ attr_path_filter: str | None = None,
) -> Callable[[], None]:
"""
Subscribe to node and server events.
@@ -131,6 +131,12 @@ def get_node(self, node_id: int) -> MatterNode:
return node
raise NodeNotExists(f"Node {node_id} does not exist or is not yet interviewed")
+ async def set_default_fabric_label(self, label: str | None) -> None:
+ """Set the default fabric label."""
+ await self.send_command(
+ APICommand.SET_DEFAULT_FABRIC_LABEL, require_schema=11, label=label
+ )
+
async def commission_with_code(
self, code: str, network_only: bool = False
) -> MatterNodeData:
@@ -185,7 +191,7 @@ async def open_commissioning_window(
timeout: int = 300, # noqa: ASYNC109 timeout parameter required for native timeout
iteration: int = 1000,
option: int = 1,
- discriminator: Optional[int] = None,
+ discriminator: int | None = None,
) -> CommissioningParameters:
"""
Open a commissioning window to commission a device present on this controller to another.
@@ -248,7 +254,7 @@ async def get_matter_fabrics(self, node_id: int) -> list[MatterFabricData]:
fabric_id=f.fabricID,
vendor_id=f.vendorID,
fabric_index=f.fabricIndex,
- fabric_label=f.label if f.label else None,
+ fabric_label=f.label or None,
vendor_name=vendors_map.get(str(f.vendorID)),
)
for f in fabrics
@@ -606,6 +612,8 @@ async def connect(self) -> None:
if self.connection.connected:
# already connected
return
+
+ self._stop_called = False
# NOTE: connect will raise when connecting failed
await self.connection.connect()
@@ -763,8 +771,8 @@ def _signal_event(
self,
event: EventType,
data: Any = None,
- node_id: Optional[int] = None,
- attribute_path: Optional[str] = None,
+ node_id: int | None = None,
+ attribute_path: str | None = None,
) -> None:
"""Signal event to all subscribers."""
# instead of iterating all subscribers we iterate over subscription keys
@@ -780,7 +788,7 @@ def _signal_event(
for callback in self._subscribers.get(key, []):
callback(event, data)
- async def __aenter__(self) -> "MatterClient":
+ async def __aenter__(self) -> Self:
"""Initialize and connect the Matter Websocket client."""
await self.connect()
return self
diff --git a/matter_server/client/models/device_types.py b/matter_server/client/models/device_types.py
index 694532aa..1b93fa45 100644
--- a/matter_server/client/models/device_types.py
+++ b/matter_server/client/models/device_types.py
@@ -116,8 +116,8 @@ class Aggregator(DeviceType, device_type=0x000E):
}
-class BridgedDevice(DeviceType, device_type=0x0013):
- """Bridged Device."""
+class BridgedNode(DeviceType, device_type=0x0013):
+ """Bridged Node."""
clusters = {
all_clusters.Descriptor,
@@ -154,6 +154,30 @@ class DimmableLight(DeviceType, device_type=0x0101):
}
+class MountedOnOffControl(DeviceType, device_type=0x010F):
+ """Mounted On/Off Control."""
+
+ clusters = {
+ all_clusters.Groups,
+ all_clusters.Identify,
+ all_clusters.LevelControl,
+ all_clusters.OnOff,
+ all_clusters.ScenesManagement,
+ }
+
+
+class MountedDimmableLoadControl(DeviceType, device_type=0x0110):
+ """Mounted Dimmable Load Control."""
+
+ clusters = {
+ all_clusters.Groups,
+ all_clusters.Identify,
+ all_clusters.LevelControl,
+ all_clusters.OnOff,
+ all_clusters.ScenesManagement,
+ }
+
+
class ColorTemperatureLight(DeviceType, device_type=0x010C):
"""Color Temperature Light."""
@@ -594,7 +618,6 @@ class SmokeCoAlarm(DeviceType, device_type=0x0076):
"""Smoke CO Alarm."""
clusters = {
- all_clusters.Descriptor,
all_clusters.Identify,
all_clusters.Groups,
all_clusters.SmokeCoAlarm,
@@ -737,6 +760,7 @@ class RoboticVacuumCleaner(DeviceType, device_type=0x0074):
all_clusters.RvcRunMode,
all_clusters.RvcCleanMode,
all_clusters.RvcOperationalState,
+ all_clusters.ServiceArea,
}
@@ -796,11 +820,24 @@ class RainSensor(DeviceType, device_type=0x0044):
}
-class NetworkInfrastructureManager(DeviceType, device_type=0xFFF10010):
+class NetworkInfrastructureManager(DeviceType, device_type=0x0090):
"""Network Infrastructure Manager."""
clusters = {
all_clusters.Descriptor,
+ all_clusters.ThreadNetworkDirectory,
+ all_clusters.WiFiNetworkManagement,
+ all_clusters.ThreadBorderRouterManagement,
+ }
+
+
+class ThreadBorderRouter(DeviceType, device_type=0x0091):
+ """Thread Border Router."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.ThreadNetworkDiagnostics,
+ all_clusters.ThreadBorderRouterManagement,
}
@@ -811,7 +848,6 @@ class AllClustersAppServerExample(DeviceType, device_type=0xFFF10003):
all_clusters.Identify,
all_clusters.Descriptor,
all_clusters.Binding,
- all_clusters.BarrierControl,
all_clusters.ColorControl,
all_clusters.DoorLock,
all_clusters.Groups,
@@ -822,12 +858,15 @@ class AllClustersAppServerExample(DeviceType, device_type=0xFFF10003):
}
-class SecondaryNetworkCommissioningDeviceType(DeviceType, device_type=0xFFF10002):
- """Secondary Network Commissioning Device Type."""
+class SecondaryNetworkInterface(DeviceType, device_type=0x0019):
+ """Secondary Network Interface."""
clusters = {
all_clusters.NetworkCommissioning,
all_clusters.Descriptor,
+ all_clusters.EthernetNetworkDiagnostics,
+ all_clusters.WiFiNetworkDiagnostics,
+ all_clusters.ThreadNetworkDiagnostics,
}
@@ -845,6 +884,7 @@ class CookSurface(DeviceType, device_type=0x0077):
"""Cook Surface."""
clusters = {
+ all_clusters.OnOff,
all_clusters.Descriptor,
all_clusters.TemperatureControl,
all_clusters.TemperatureMeasurement,
@@ -861,3 +901,52 @@ class Evse(DeviceType, device_type=0x050C):
all_clusters.EnergyEvseMode,
all_clusters.TemperatureMeasurement,
}
+
+
+class DeviceEnergyManagement(DeviceType, device_type=0x050D):
+ """Device Energy Management."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.DeviceEnergyManagement,
+ all_clusters.DeviceEnergyManagementMode,
+ }
+
+
+class WaterHeater(DeviceType, device_type=0x050F):
+ """Water Heater."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.Identify,
+ all_clusters.Thermostat,
+ all_clusters.WaterHeaterManagement,
+ all_clusters.WaterHeaterMode,
+ }
+
+
+class HeatPump(DeviceType, device_type=0x0309):
+ """Heat Pump."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.Identify,
+ }
+
+
+class SolarPower(DeviceType, device_type=0x0017):
+ """Solar Power."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.Identify,
+ }
+
+
+class BatteryStorage(DeviceType, device_type=0x0018):
+ """Battery Storage."""
+
+ clusters = {
+ all_clusters.Descriptor,
+ all_clusters.Identify,
+ }
diff --git a/matter_server/client/models/node.py b/matter_server/client/models/node.py
index 81336e62..6d2c7a4a 100644
--- a/matter_server/client/models/node.py
+++ b/matter_server/client/models/node.py
@@ -19,7 +19,7 @@
from .device_types import (
ALL_TYPES as DEVICE_TYPES,
Aggregator,
- BridgedDevice,
+ BridgedNode,
DeviceType,
RootNode,
)
@@ -75,7 +75,7 @@ def __init__(
@property
def is_bridged_device(self) -> bool:
"""Return if this endpoint represents a Bridged device."""
- return BridgedDevice in self.device_types
+ return BridgedNode in self.device_types
@property
def is_composed_device(self) -> bool:
@@ -223,7 +223,7 @@ def update(self, attributes_data: dict[str, Any]) -> None:
self.set_attribute_value(attribute_path, attribute_value)
# extract device types from Descriptor Cluster
if cluster := self.get_cluster(Clusters.Descriptor):
- for dev_info in cluster.deviceTypeList: # type: ignore[unreachable]
+ for dev_info in cluster.deviceTypeList:
device_type = DEVICE_TYPES.get(dev_info.deviceType)
if device_type is None:
LOGGER.debug("Found unknown device type %s", dev_info)
@@ -352,13 +352,13 @@ def update(self, node_data: MatterNodeData) -> None:
endpoint.endpoint_id,
)
continue
- if descriptor.partsList: # type: ignore[unreachable]
+ if descriptor.partsList:
for endpoint_id in descriptor.partsList:
self._composed_endpoints[endpoint_id] = endpoint.endpoint_id
def update_attribute(self, attribute_path: str, new_value: Any) -> None:
"""Handle Attribute value update."""
- endpoint_id = int(attribute_path.split("/")[0])
+ endpoint_id = int(attribute_path.split("/", maxsplit=1)[0])
if endpoint_id not in self.endpoints:
# race condition when a bridge is in the process of adding a new endpoint
return
diff --git a/matter_server/common/const.py b/matter_server/common/const.py
index 26a4737e..f5ac9b2c 100644
--- a/matter_server/common/const.py
+++ b/matter_server/common/const.py
@@ -2,7 +2,7 @@
# schema version is used to determine compatibility between server and client
# bump schema if we add new features and/or make other (breaking) changes
-SCHEMA_VERSION = 10
+SCHEMA_VERSION = 11
VERBOSE_LOG_LEVEL = 5
diff --git a/matter_server/common/custom_clusters.py b/matter_server/common/custom_clusters.py
index b5e8d59b..aa3b89c6 100644
--- a/matter_server/common/custom_clusters.py
+++ b/matter_server/common/custom_clusters.py
@@ -12,9 +12,13 @@
ClusterObjectDescriptor,
ClusterObjectFieldDescriptor,
)
+from chip.clusters.Objects import BasicInformation, ElectricalPowerMeasurement
from chip.tlv import float32, uint
-from matter_server.common.helpers.util import parse_attribute_path
+from matter_server.common.helpers.util import (
+ create_attribute_path_from_attribute,
+ parse_attribute_path,
+)
if TYPE_CHECKING:
from matter_server.common.models import MatterNodeData
@@ -27,13 +31,19 @@
ALL_CUSTOM_CLUSTERS: dict[int, Cluster] = {}
ALL_CUSTOM_ATTRIBUTES: dict[int, dict[int, ClusterAttributeDescriptor]] = {}
+VENDOR_ID_EVE = 4874
+
@dataclass
class CustomClusterMixin:
"""Base model for a vendor specific custom cluster."""
id: ClassVar[int] # cluster id
- should_poll: bool = False # should the entire cluster be polled for state changes?
+
+ @staticmethod
+ def should_poll(node_data: MatterNodeData) -> bool: # noqa: ARG004
+ """Check if the (entire) custom cluster should be polled for state changes."""
+ return False
def __init_subclass__(cls: Cluster, *args, **kwargs) -> None:
"""Register a subclass."""
@@ -45,7 +55,10 @@ def __init_subclass__(cls: Cluster, *args, **kwargs) -> None:
class CustomClusterAttributeMixin:
"""Base model for a vendor specific custom cluster attribute."""
- should_poll: bool = False # should this attribute be polled ?
+ @staticmethod
+ def should_poll(node_data: MatterNodeData) -> bool: # noqa: ARG004
+ """Check if the custom attribute should be polled for state changes."""
+ return False
def __init_subclass__(cls: ClusterAttributeDescriptor, *args, **kwargs) -> None:
"""Register a subclass."""
@@ -55,6 +68,23 @@ def __init_subclass__(cls: ClusterAttributeDescriptor, *args, **kwargs) -> None:
ALL_CUSTOM_ATTRIBUTES[cls.cluster_id][cls.attribute_id] = cls
+def should_poll_eve_energy(node_data: MatterNodeData) -> bool:
+ """Check if the (Eve Energy) custom attribute should be polled for state changes."""
+ attr_path = create_attribute_path_from_attribute(
+ 0, BasicInformation.Attributes.VendorID
+ )
+ if node_data.attributes.get(attr_path) != VENDOR_ID_EVE:
+ # Some implementation (such as MatterBridge) use the
+ # Eve cluster to send the power measurements. Filter that out.
+ return False
+ # if the ElectricalPowerMeasurement cluster is NOT present,
+ # we should poll the custom Eve cluster attribute(s).
+ attr_path = create_attribute_path_from_attribute(
+ 2, ElectricalPowerMeasurement.Attributes.AttributeList
+ )
+ return node_data.attributes.get(attr_path) is None
+
+
@dataclass
class EveCluster(Cluster, CustomClusterMixin):
"""Custom (vendor-specific) cluster for Eve - Vendor ID 4874 (0x130a)."""
@@ -84,15 +114,24 @@ def descriptor(cls) -> ClusterObjectDescriptor:
ClusterObjectFieldDescriptor(
Label="current", Tag=0x130A0009, Type=float32
),
+ ClusterObjectFieldDescriptor(
+ Label="obstructionDetected", Tag=0x130A0010, Type=bool
+ ),
ClusterObjectFieldDescriptor(
Label="altitude", Tag=0x130A0013, Type=float32
),
ClusterObjectFieldDescriptor(
Label="pressure", Tag=0x130A0014, Type=float32
),
+ ClusterObjectFieldDescriptor(
+ Label="weatherTrend", Tag=0x130A0015, Type=int
+ ),
ClusterObjectFieldDescriptor(
Label="valvePosition", Tag=0x130A0018, Type=int
),
+ ClusterObjectFieldDescriptor(
+ Label="motionSensitivity", Tag=0x130A000D, Type=uint
+ ),
]
)
@@ -104,7 +143,10 @@ def descriptor(cls) -> ClusterObjectDescriptor:
current: float32 | None = None
altitude: float32 | None = None
pressure: float32 | None = None
+ weatherTrend: int | None = None
valvePosition: int | None = None
+ motionSensitivity: int | None = None
+ obstructionDetected: bool | None = None
class Attributes:
"""Attributes for the Eve Cluster."""
@@ -113,8 +155,6 @@ class Attributes:
class TimesOpened(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""TimesOpened Attribute within the Eve Cluster."""
- should_poll = True
-
@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
@@ -136,7 +176,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
class Watt(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""Watt Attribute within the Eve Cluster."""
- should_poll = True
+ should_poll = should_poll_eve_energy
@ChipUtility.classproperty
def cluster_id(cls) -> int:
@@ -159,7 +199,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
class WattAccumulated(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""WattAccumulated Attribute within the Eve Cluster."""
- should_poll = True
+ should_poll = should_poll_eve_energy
@ChipUtility.classproperty
def cluster_id(cls) -> int:
@@ -184,7 +224,7 @@ class WattAccumulatedControlPoint(
):
"""wattAccumulatedControlPoint Attribute within the Eve Cluster."""
- should_poll = True
+ should_poll = should_poll_eve_energy
@ChipUtility.classproperty
def cluster_id(cls) -> int:
@@ -207,7 +247,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
class Voltage(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""Voltage Attribute within the Eve Cluster."""
- should_poll = True
+ should_poll = should_poll_eve_energy
@ChipUtility.classproperty
def cluster_id(cls) -> int:
@@ -230,7 +270,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
class Current(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""Current Attribute within the Eve Cluster."""
- should_poll = True
+ should_poll = should_poll_eve_energy
@ChipUtility.classproperty
def cluster_id(cls) -> int:
@@ -249,6 +289,29 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
value: float32 = 0
+ @dataclass
+ class ObstructionDetected(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """ObstructionDetected Attribute within the Eve Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130AFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x130A0010
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=bool)
+
+ value: bool = False
+
@dataclass
class Altitude(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""Altitude Attribute within the Eve Cluster."""
@@ -291,12 +354,31 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
value: float32 = 0
+ @dataclass
+ class WeatherTrend(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """WeatherTrend Attribute within the Eve Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130AFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x130A0015
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=int)
+
+ value: int = 0
+
@dataclass
class ValvePosition(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
"""ValvePosition Attribute within the Eve Cluster."""
- should_poll = True
-
@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
@@ -314,6 +396,131 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
value: int = 0
+ @dataclass
+ class MotionSensitivity(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """MotionSensitivity Attribute within the Eve Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130AFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x130A000D
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: int = 0
+
+
+@dataclass
+class InovelliCluster(Cluster, CustomClusterMixin):
+ """Custom (vendor-specific) cluster for Inovelli - Vendor ID 4961 (0x1361)."""
+
+ id: ClassVar[int] = 0x122FFC31
+
+ @ChipUtility.classproperty
+ def descriptor(cls) -> ClusterObjectDescriptor:
+ """Return descriptor for this cluster."""
+ return ClusterObjectDescriptor(
+ Fields=[
+ ClusterObjectFieldDescriptor(
+ Label="ledIndicatorIntensityOn", Tag=0x122F0061, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="ledIndicatorIntensityOff", Tag=0x122F0062, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="clearNotificationWithConfigDoubleTap",
+ Tag=0x122F0106,
+ Type=bool,
+ ),
+ ]
+ )
+
+ ledIndicatorIntenstyOn: uint | None = None
+ ledIndicatorIntensityOff: uint | None = None
+ clearNotificationWithConfigDoubleTap: bool | None = None
+
+ class Attributes:
+ """Attributes for the Inovelli Cluster."""
+
+ @dataclass
+ class LEDIndicatorIntensityOn(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """LEDIndicatorIntensityOn Attribute within the Inovelli Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x122FFC31
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x122F0061
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class LEDIndicatorIntensityOff(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """LEDIndicatorIntensityOff Attribute within the Inovelli Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x122FFC31
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x122F0062
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class ClearNotificationWithConfigDoubleTap(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """ClearNotificationWithConfigDoubleTap Attribute within the Inovelli Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x122FFC31
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x122F0106
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=bool)
+
+ value: bool = False
+
@dataclass
class NeoCluster(Cluster, CustomClusterMixin):
@@ -435,10 +642,10 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
@dataclass
-class ThirdRealityMeteringCluster(Cluster, CustomClusterMixin):
- """Custom (vendor-specific) PowerMetering cluster for ThirdReality."""
+class HeimanCluster(Cluster, CustomClusterMixin):
+ """Custom (vendor-specific) cluster for Heiman - Vendor ID 4619 (0x120BFC01)."""
- id: ClassVar[int] = 0x130DFC02
+ id: ClassVar[int] = 0x120BFC01
@ChipUtility.classproperty
def descriptor(cls) -> ClusterObjectDescriptor:
@@ -446,41 +653,74 @@ def descriptor(cls) -> ClusterObjectDescriptor:
return ClusterObjectDescriptor(
Fields=[
ClusterObjectFieldDescriptor(
- Label="currentSummationDelivered", Tag=0x0000, Type=uint
+ Label="tamperAlarm", Tag=0x00120B0010, Type=uint
),
ClusterObjectFieldDescriptor(
- Label="instantaneousDemand", Tag=0x0400, Type=uint
+ Label="preheatingState", Tag=0x00120B0011, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="noDisturbingState", Tag=0x00120B0012, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="sensorType", Tag=0x00120B0013, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="sirenActive", Tag=0x00120B0014, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="alarmMute", Tag=0x00120B0015, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="lowPowerMode", Tag=0x00120B0016, Type=uint
),
]
)
- currentSummationDelivered: uint | None = None
- instantaneousDemand: uint | None = None
+ tamperAlarm: uint | None = None
+ preheatingState: uint | None = None
+ noDisturbingState: uint | None = None
+ sensorType: uint | None = None
+ sirenActive: uint | None = None
+ alarmMute: uint | None = None
+ lowPowerMode: uint | None = None
class Attributes:
- """Attributes for the custom Cluster."""
+ """Attributes for the Heiman Cluster."""
@dataclass
- class CurrentSummationDelivered(
- ClusterAttributeDescriptor, CustomClusterAttributeMixin
- ):
- """CurrentSummationDelivered represents the most recent summed value of Energy consumed in the premise.
+ class TamperAlarm(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """TamperAlarm Attribute within the Heiman Cluster."""
- CurrentSummationDelivered is updated continuously as new measurements are made.
- This attribute is Read only.
- Value is set to zero when leave command is received (beginning version 2.6.15),
- or local factory reset(10s) is performed on the device..
- """
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x120BFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00120B0010
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class PreheatingState(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """PreheatingState Attribute within the Heiman Cluster."""
@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
- return 0x130DFC02
+ return 0x120BFC01
@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
- return 0x0000
+ return 0x00120B0011
@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
@@ -490,29 +730,488 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
value: uint = 0
@dataclass
- class InstantaneousDemand(
+ class NoDisturbingState(
ClusterAttributeDescriptor, CustomClusterAttributeMixin
):
- """
- InstantaneousDemand represents the current Demand of Energy delivered at the premise.
+ """NoDisturbingState Attribute within the Heiman Cluster."""
- Device is able measure only positive values indicate Demand delivered to the premise.
- InstantaneousDemand is updated continuously as new measurements are made.
- The frequency of updates to this field is specific to the metering device,
- but should be within the range of once every second to once every 5 seconds.
- The same multiplier and divisor values used for Current Summation Delivered (Energy) will be used.
- If connected load is below 1W, this attribute is set to 0 and no accumulation of energy is done.
- """
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x120BFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00120B0012
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class SensorType(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """SensorType Attribute within the Heiman Cluster."""
@ChipUtility.classproperty
def cluster_id(cls) -> int:
"""Return cluster id."""
- return 0x130DFC02
+ return 0x120BFC01
@ChipUtility.classproperty
def attribute_id(cls) -> int:
"""Return attribute id."""
- return 0x0400
+ return 0x00120B0013
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class SirenActive(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """SirenActive Attribute within the Heiman Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x120BFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00120B0014
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AlarmMute(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """AlarmMute Attribute within the Heiman Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x120BFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00120B0015
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class LowPowerMode(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """LowPowerMode Attribute within the Heiman Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x120BFC01
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00120B0016
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+
+@dataclass
+class ThirdRealityMeteringCluster(Cluster, CustomClusterMixin):
+ """Custom (vendor-specific) PowerMetering cluster for ThirdReality."""
+
+ id: ClassVar[int] = 0x130DFC02
+
+ @ChipUtility.classproperty
+ def descriptor(cls) -> ClusterObjectDescriptor:
+ """Return descriptor for this cluster."""
+ return ClusterObjectDescriptor(
+ Fields=[
+ ClusterObjectFieldDescriptor(
+ Label="currentSummationDelivered", Tag=0x0000, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="instantaneousDemand", Tag=0x0400, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(Label="multiplier", Tag=0x0301, Type=uint),
+ ClusterObjectFieldDescriptor(Label="divisor", Tag=0x0302, Type=uint),
+ ]
+ )
+
+ currentSummationDelivered: uint | None = None
+ instantaneousDemand: uint | None = None
+ multiplier: uint = 1
+ divisor: uint = 1
+
+ class Attributes:
+ """Attributes for the custom Cluster."""
+
+ @dataclass
+ class CurrentSummationDelivered(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """CurrentSummationDelivered represents the most recent summed value of Energy consumed in the premise.
+
+ CurrentSummationDelivered is updated continuously as new measurements are made.
+ This attribute is Read only.
+ Value is set to zero when leave command is received (beginning version 2.6.15),
+ or local factory reset(10s) is performed on the device..
+ """
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130DFC02
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x0000
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class Divisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """Divisor Attribute within the ThirdRealityMeteringCluster Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130DFC02
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x0302
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 1
+
+ @dataclass
+ class Multiplier(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """Multiplier Attribute within the ThirdRealityMeteringCluster Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130DFC02
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x0301
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 1
+
+ @dataclass
+ class InstantaneousDemand(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """
+ InstantaneousDemand represents the current Demand of Energy delivered at the premise.
+
+ Device is able measure only positive values indicate Demand delivered to the premise.
+ InstantaneousDemand is updated continuously as new measurements are made.
+ The frequency of updates to this field is specific to the metering device,
+ but should be within the range of once every second to once every 5 seconds.
+ The same multiplier and divisor values used for Current Summation Delivered (Energy) will be used.
+ If connected load is below 1W, this attribute is set to 0 and no accumulation of energy is done.
+ """
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x130DFC02
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x0400
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+
+@dataclass
+class DraftElectricalMeasurementCluster(Cluster, CustomClusterMixin):
+ """Custom ElectricalMetering cluster from Matter 1.0 draft specification."""
+
+ id: ClassVar[int] = 0x00000B04
+
+ @ChipUtility.classproperty
+ def descriptor(cls) -> ClusterObjectDescriptor:
+ """Return descriptor for this cluster."""
+ return ClusterObjectDescriptor(
+ Fields=[
+ ClusterObjectFieldDescriptor(
+ Label="rmsVoltage", Tag=0x00000505, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="rmsCurrent", Tag=0x00000508, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="activePower", Tag=0x0000050B, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acVoltageMultiplier", Tag=0x00000600, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acVoltageDivisor", Tag=0x00000601, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acCurrentMultiplier", Tag=0x00000602, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acCurrentDivisor", Tag=0x00000603, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acPowerMultiplier", Tag=0x00000604, Type=uint
+ ),
+ ClusterObjectFieldDescriptor(
+ Label="acPowerDivisor", Tag=0x00000605, Type=uint
+ ),
+ ]
+ )
+
+ rmsVoltage: uint | None = None
+ rmsCurrent: uint | None = None
+ activePower: uint | None = None
+ acVoltageMultiplier: uint | None = None
+ acVoltageDivisor: uint | None = None
+ acCurrentMultiplier: uint | None = None
+ acCurrentDivisor: uint | None = None
+ acPowerMultiplier: uint | None = None
+ acPowerDivisor: uint | None = None
+
+ class Attributes:
+ """Attributes for the custom Cluster."""
+
+ @dataclass
+ class RmsVoltage(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """RmsVoltage Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000505
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class RmsCurrent(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """RmsCurrent Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000508
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class ActivePower(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """ActivePower Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x0000050B
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcVoltageMultiplier(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """AcVoltageMultiplier Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000600
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcVoltageDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """AcVoltageDivisor Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000601
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcCurrentMultiplier(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """AcCurrentMultiplier Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000602
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcCurrentDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """AcCurrentDivisor Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000603
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcPowerMultiplier(
+ ClusterAttributeDescriptor, CustomClusterAttributeMixin
+ ):
+ """AcPowerMultiplier Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000604
+
+ @ChipUtility.classproperty
+ def attribute_type(cls) -> ClusterObjectFieldDescriptor:
+ """Return attribute type."""
+ return ClusterObjectFieldDescriptor(Type=uint)
+
+ value: uint = 0
+
+ @dataclass
+ class AcPowerDivisor(ClusterAttributeDescriptor, CustomClusterAttributeMixin):
+ """AcPowerDivisor Attribute within the DraftElectricalMeasurement Cluster."""
+
+ @ChipUtility.classproperty
+ def cluster_id(cls) -> int:
+ """Return cluster id."""
+ return 0x00000B04
+
+ @ChipUtility.classproperty
+ def attribute_id(cls) -> int:
+ """Return attribute id."""
+ return 0x00000605
@ChipUtility.classproperty
def attribute_type(cls) -> ClusterObjectFieldDescriptor:
@@ -529,12 +1228,12 @@ def check_polled_attributes(node_data: MatterNodeData) -> set[str]:
endpoint_id, cluster_id, attribute_id = parse_attribute_path(attr_path)
if not (custom_cluster := ALL_CUSTOM_CLUSTERS.get(cluster_id)):
continue
- if custom_cluster.should_poll:
+ if custom_cluster.should_poll(node_data):
# the entire cluster needs to be polled
attributes_to_poll.add(f"{endpoint_id}/{cluster_id}/*")
continue
custom_attribute = ALL_CUSTOM_ATTRIBUTES[cluster_id].get(attribute_id)
- if custom_attribute and custom_attribute.should_poll:
+ if custom_attribute and custom_attribute.should_poll(node_data):
# this attribute needs to be polled
attributes_to_poll.add(attr_path)
return attributes_to_poll
diff --git a/matter_server/common/helpers/util.py b/matter_server/common/helpers/util.py
index 25f04ba7..ade69a54 100644
--- a/matter_server/common/helpers/util.py
+++ b/matter_server/common/helpers/util.py
@@ -91,7 +91,7 @@ def dataclass_to_dict(obj_in: DataclassInstance) -> dict:
def parse_utc_timestamp(datetime_string: str) -> datetime:
"""Parse datetime from string."""
- return datetime.fromisoformat(datetime_string.replace("Z", "+00:00"))
+ return datetime.fromisoformat(datetime_string)
def _get_descriptor_key(descriptor: ClusterObjectDescriptor, key: str | int) -> str:
@@ -143,7 +143,7 @@ def parse_value(
value = None
if is_dataclass(value_type) and isinstance(value, dict):
- return dataclass_from_dict(value_type, value)
+ return dataclass_from_dict(value_type, value) # type: ignore[arg-type]
# get origin value type and inspect one-by-one
origin: Any = get_origin(value_type)
if origin in (list, tuple, set) and isinstance(value, (list, tuple, set)):
@@ -267,7 +267,10 @@ def parse_value(
def dataclass_from_dict(
- cls: type[_T], dict_obj: dict, strict: bool = False, allow_sdk_types: bool = False
+ cls: type[_T],
+ dict_obj: dict,
+ strict: bool = False,
+ allow_sdk_types: bool = False,
) -> _T:
"""
Create (instance of) a dataclass by providing a dict with values.
@@ -280,7 +283,7 @@ def dataclass_from_dict(
extra_keys = dict_obj.keys() - {f.name for f in dc_fields}
if extra_keys:
raise KeyError(
- f'Extra key(s) {",".join(extra_keys)} not allowed for {str(cls)}'
+ f"Extra key(s) {','.join(extra_keys)} not allowed for {str(cls)}"
)
type_hints = cached_type_hints(cls)
return cls(
diff --git a/matter_server/common/models.py b/matter_server/common/models.py
index c7128eb0..d8376558 100644
--- a/matter_server/common/models.py
+++ b/matter_server/common/models.py
@@ -4,8 +4,8 @@
from collections.abc import Callable
from dataclasses import dataclass, field
-from datetime import datetime # noqa: TCH003
-from enum import Enum
+from datetime import datetime # noqa: TC003
+from enum import Enum, StrEnum
from typing import Any
# Enums and constants
@@ -25,7 +25,7 @@ class EventType(Enum):
ENDPOINT_REMOVED = "endpoint_removed"
-class APICommand(str, Enum):
+class APICommand(StrEnum):
"""Enum with all known API commands."""
START_LISTENING = "start_listening"
@@ -50,6 +50,9 @@ class APICommand(str, Enum):
IMPORT_TEST_NODE = "import_test_node"
CHECK_NODE_UPDATE = "check_node_update"
UPDATE_NODE = "update_node"
+ SET_DEFAULT_FABRIC_LABEL = "set_default_fabric_label"
+ SET_ACL_ENTRY = "set_acl_entry"
+ SET_NODE_BINDING = "set_node_binding"
EventCallBackType = Callable[[EventType, Any], None]
diff --git a/matter_server/server/client_handler.py b/matter_server/server/client_handler.py
index 2cdb8a84..60b317fd 100644
--- a/matter_server/server/client_handler.py
+++ b/matter_server/server/client_handler.py
@@ -9,7 +9,6 @@
from typing import TYPE_CHECKING, Any, Final
from aiohttp import WSMsgType, web
-import async_timeout
from chip.exceptions import ChipStackError
from matter_server.common.const import VERBOSE_LOG_LEVEL
@@ -76,7 +75,7 @@ async def handle_client(self) -> web.WebSocketResponse:
request = self.request
wsock = self.wsock
try:
- async with async_timeout.timeout(10):
+ async with asyncio.timeout(10):
await wsock.prepare(request)
except asyncio.TimeoutError:
self._logger.warning("Timeout preparing request from %s", request.remote)
diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py
index 54bf15b4..9df276c1 100644
--- a/matter_server/server/device_controller.py
+++ b/matter_server/server/device_controller.py
@@ -13,18 +13,25 @@
from datetime import datetime
from functools import cached_property, lru_cache
import logging
+import re
import secrets
import time
from typing import TYPE_CHECKING, Any, cast
from chip.ChipDeviceCtrl import ChipDeviceController
from chip.clusters import Attribute, Objects as Clusters
-from chip.clusters.Attribute import ValueDecodeFailure
+from chip.clusters.Attribute import AttributeWriteResult, ValueDecodeFailure
from chip.clusters.ClusterObjects import ALL_ATTRIBUTES, ALL_CLUSTERS, Cluster
from chip.discovery import DiscoveryType
from chip.exceptions import ChipStackError
from chip.native import PyChipError
-from zeroconf import BadTypeInNameException, IPVersion, ServiceStateChange, Zeroconf
+from zeroconf import (
+ BadTypeInNameException,
+ DNSQuestionType,
+ IPVersion,
+ ServiceStateChange,
+ Zeroconf,
+)
from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo, AsyncZeroconf
from matter_server.common.const import VERBOSE_LOG_LEVEL
@@ -78,6 +85,8 @@
DATA_KEY_LAST_NODE_ID = "last_node_id"
LOGGER = logging.getLogger(__name__)
+NODE_SUBSCRIPTION_FLOOR_DEFAULT = 1
+NODE_SUBSCRIPTION_FLOOR_ICD = 0
NODE_SUBSCRIPTION_CEILING_WIFI = 60
NODE_SUBSCRIPTION_CEILING_THREAD = 60
NODE_SUBSCRIPTION_CEILING_BATTERY_POWERED = 600
@@ -116,6 +125,13 @@
0, Clusters.BasicInformation.Attributes.SoftwareVersionString
)
)
+ICD_ATTR_LIST_ATTRIBUTE_PATH = create_attribute_path_from_attribute(
+ 0, Clusters.IcdManagement.Attributes.AttributeList
+)
+
+RE_MDNS_SERVICE_NAME = re.compile(
+ rf"^([0-9A-Fa-f]{{16}})-([0-9A-Fa-f]{{16}})\.{re.escape(MDNS_TYPE_OPERATIONAL_NODE)}$"
+)
# pylint: disable=too-many-lines,too-many-instance-attributes,too-many-public-methods
@@ -141,7 +157,6 @@ def __init__(
# we keep the last events in memory so we can include them in the diagnostics dump
self.event_history: deque[Attribute.EventReadResult] = deque(maxlen=25)
self._compressed_fabric_id: int | None = None
- self._fabric_id_hex: str | None = None
self._wifi_credentials_set: bool = False
self._thread_credentials_set: bool = False
self._setup_node_tasks = dict[int, asyncio.Task]()
@@ -161,13 +176,13 @@ def __init__(
self._custom_attribute_poller_timer: asyncio.TimerHandle | None = None
self._custom_attribute_poller_task: asyncio.Task | None = None
self._attribute_update_callbacks: dict[int, list[Callable]] = {}
+ self._default_fabric_label: str | None = None
async def initialize(self) -> None:
"""Initialize the device controller."""
self._compressed_fabric_id = (
await self._chip_device_controller.get_compressed_fabric_id()
)
- self._fabric_id_hex = hex(self._compressed_fabric_id)[2:]
await load_local_updates(self._ota_provider_dir)
async def start(self) -> None:
@@ -214,6 +229,7 @@ async def start(self) -> None:
self._aiozc.zeroconf,
services,
handlers=[self._on_mdns_service_state_change],
+ question_type=DNSQuestionType.QM,
)
async def stop(self) -> None:
@@ -232,8 +248,10 @@ async def stop(self) -> None:
LOGGER.debug("Stopped.")
@property
- def compressed_fabric_id(self) -> int | None:
+ def compressed_fabric_id(self) -> int:
"""Return the compressed fabric id."""
+ if self._compressed_fabric_id is None:
+ raise RuntimeError("Compressed Fabric ID not set")
return self._compressed_fabric_id
@property
@@ -275,6 +293,18 @@ def get_node(self, node_id: int) -> MatterNodeData:
return node
raise NodeNotExists(f"Node {node_id} does not exist or is not yet interviewed")
+ @api_command(APICommand.SET_DEFAULT_FABRIC_LABEL)
+ async def set_default_fabric_label(self, label: str | None) -> None:
+ """Set the default fabric label."""
+ if label is not None and len(label) > 32:
+ LOGGER.info(
+ "Fabric label '%s' exceeds 32 characters, truncating to '%s'",
+ label,
+ label[:32],
+ )
+ label = label[:32]
+ self._default_fabric_label = label
+
@api_command(APICommand.COMMISSION_WITH_CODE)
async def commission_with_code(
self, code: str, network_only: bool = False
@@ -325,9 +355,15 @@ async def commission_with_code(
retries = 3
while retries:
try:
- await self.interview_node(node_id)
+ await self._interview_node(node_id)
except (NodeNotResolving, NodeInterviewFailed) as err:
if retries <= 0:
+ try:
+ await self._chip_device_controller.unpair_device(node_id)
+ except ChipStackError as err_unpair:
+ LOGGER.warning(
+ "Removing current fabric from device failed: %s", err_unpair
+ )
raise err
retries -= 1
LOGGER.warning("Unable to interview Node %s: %s", node_id, err)
@@ -405,7 +441,7 @@ async def commission_on_network(
retries = 3
while retries:
try:
- await self.interview_node(node_id)
+ await self._interview_node(node_id)
except NodeInterviewFailed as err:
if retries <= 0:
raise err
@@ -540,24 +576,15 @@ async def discover_commissionable_nodes(
pairing_hint=x.pairingHint,
mrp_retry_interval_idle=x.mrpRetryIntervalIdle,
mrp_retry_interval_active=x.mrpRetryIntervalActive,
- supports_tcp=x.supportsTcp,
+ # TCP is provisional, so no devices out there anyway
+ supports_tcp=False,
addresses=x.addresses,
rotating_id=x.rotatingId,
)
for x in sdk_result
]
- @api_command(APICommand.INTERVIEW_NODE)
- async def interview_node(self, node_id: int) -> None:
- """Interview a node."""
- if node_id >= TEST_NODE_START:
- LOGGER.debug(
- "interview_node called for test node %s",
- node_id,
- )
- self.server.signal_event(EventType.NODE_UPDATED, self._nodes[node_id])
- return
-
+ async def _interview_node(self, node_id: int) -> None:
try:
LOGGER.info("Interviewing node: %s", node_id)
read_response: Attribute.AsyncReadTransaction.ReadResponse = (
@@ -570,6 +597,39 @@ async def interview_node(self, node_id: int) -> None:
except ChipStackError as err:
raise NodeInterviewFailed(f"Failed to interview node {node_id}") from err
+ # Set label if specified and needed
+ if self._default_fabric_label:
+ cluster = read_response.attributes[0][Clusters.OperationalCredentials]
+ fabrics: list[
+ Clusters.OperationalCredentials.Structs.FabricDescriptorStruct
+ ] = cluster[Clusters.OperationalCredentials.Attributes.Fabrics]
+ fabric_index = cluster[
+ Clusters.OperationalCredentials.Attributes.CurrentFabricIndex
+ ]
+
+ local_fabric = next(
+ (fabric for fabric in fabrics if fabric.fabricIndex == fabric_index),
+ None,
+ )
+ if local_fabric and local_fabric.label != self._default_fabric_label:
+ try:
+ LOGGER.debug(
+ "Setting fabric label for node %s to '%s'",
+ node_id,
+ self._default_fabric_label,
+ )
+ await self._chip_device_controller.send_command(
+ node_id,
+ 0,
+ Clusters.OperationalCredentials.Commands.UpdateFabricLabel(
+ self._default_fabric_label
+ ),
+ )
+ except ChipStackError as err:
+ LOGGER.warning(
+ "Failed to set fabric label for node %s: %s", node_id, err
+ )
+
is_new_node = node_id not in self._nodes
existing_info = self._nodes.get(node_id)
node = MatterNodeData(
@@ -602,6 +662,28 @@ async def interview_node(self, node_id: int) -> None:
LOGGER.debug("Interview of node %s completed", node_id)
+ @api_command(APICommand.INTERVIEW_NODE)
+ async def interview_node(self, node_id: int) -> None:
+ """Interview a node."""
+ if node_id >= TEST_NODE_START:
+ LOGGER.debug(
+ "interview_node called for test node %s",
+ node_id,
+ )
+ self.server.signal_event(EventType.NODE_UPDATED, self._nodes[node_id])
+ return
+
+ await self._interview_node(node_id)
+
+ if self._default_fabric_label:
+ await self._chip_device_controller.send_command(
+ node_id,
+ 0,
+ Clusters.OperationalCredentials.Commands.UpdateFabricLabel(
+ self._default_fabric_label
+ ),
+ )
+
@api_command(APICommand.DEVICE_COMMAND)
async def send_device_command(
self,
@@ -788,6 +870,29 @@ async def remove_node(self, node_id: int) -> None:
except ChipStackError as err:
LOGGER.warning("Removing current fabric from device failed: %s", err)
+ @api_command(APICommand.SET_ACL_ENTRY)
+ async def set_acl_entry(
+ self,
+ node_id: int,
+ entry: list[Clusters.AccessControl.Structs.AccessControlEntryStruct],
+ ) -> list[AttributeWriteResult] | None:
+ """Set acl entry"""
+ return await self._chip_device_controller.write_attribute(
+ node_id, [(0, Clusters.AccessControl.Attributes.Acl(entry))]
+ )
+
+ @api_command(APICommand.SET_NODE_BINDING)
+ async def set_node_binding(
+ self,
+ node_id: int,
+ endpoint: int,
+ bindings: list[Clusters.Binding.Structs.TargetStruct],
+ ) -> list[AttributeWriteResult] | None:
+ """Set node binding"""
+ return await self._chip_device_controller.write_attribute(
+ node_id, [(endpoint, Clusters.Binding.Attributes.Binding(bindings))]
+ )
+
@api_command(APICommand.PING_NODE)
async def ping_node(self, node_id: int, attempts: int = 1) -> NodePingResult:
"""Ping node on the currently known IP-address(es)."""
@@ -1037,10 +1142,12 @@ async def _check_node_update(
raise UpdateCheckError("Update found, but no OTA URL provided.")
node_logger.info(
- "New software update found: %s on %s (current %s).",
+ "Software update found: %s (%s) from %s, current %s (%s)).",
update["softwareVersionString"],
+ update["softwareVersion"],
update_source,
software_version_string,
+ software_version,
)
return update_source, update
@@ -1094,7 +1201,7 @@ def attribute_updated_callback(
and new_value != old_value
):
# schedule a full interview of the node if the software version changed
- self._loop.create_task(self.interview_node(node_id))
+ self._loop.create_task(self._interview_node(node_id))
# store updated value in node attributes
node.attributes[str(path)] = new_value
@@ -1221,7 +1328,6 @@ def resubscription_succeeded(
self.server.signal_event(EventType.NODE_UPDATED, node)
node_logger.info("Setting up attributes and events subscription.")
- interval_floor = 0
# determine subscription ceiling based on routing role
# Endpoint 0, ThreadNetworkDiagnostics Cluster, routingRole attribute
# for WiFi devices, this cluster doesn't exist.
@@ -1236,6 +1342,13 @@ def resubscription_succeeded(
interval_ceiling = NODE_SUBSCRIPTION_CEILING_BATTERY_POWERED
else:
interval_ceiling = NODE_SUBSCRIPTION_CEILING_THREAD
+ if node.attributes.get(ICD_ATTR_LIST_ATTRIBUTE_PATH) is not None:
+ # for ICD devices, the interval floor must be 0 according to the spec,
+ # to prevent additional battery drainage. See Matter core spec, chapter 8.5.2.2.
+ # TODO: revisit this after Matter 1.4 release (as that mighht change this again).
+ interval_floor = NODE_SUBSCRIPTION_FLOOR_ICD
+ else:
+ interval_floor = NODE_SUBSCRIPTION_FLOOR_DEFAULT
self._resubscription_attempt[node_id] = 0
# set-up the actual subscription
sub: Attribute.SubscriptionTransaction = (
@@ -1320,7 +1433,7 @@ async def _setup_node_try_once(
or node_data.interview_version != DATA_MODEL_SCHEMA_VERSION
):
try:
- await self.interview_node(node_id)
+ await self._interview_node(node_id)
except NodeInterviewFailed as err:
node_logger.warning(
"Setup for node failed: %s",
@@ -1410,7 +1523,7 @@ async def _handle_endpoints_added(
) -> None:
"""Handle callback for when bridge endpoint(s) get added."""
# we simply do a full interview of the node
- await self.interview_node(node_id)
+ await self._interview_node(node_id)
# signal event to consumers
for endpoint_id in endpoints:
self.server.signal_event(
@@ -1447,25 +1560,36 @@ def _on_mdns_service_state_change(
)
return
- if service_type == MDNS_TYPE_OPERATIONAL_NODE:
- if self._fabric_id_hex is None or self._fabric_id_hex not in name.lower():
- # filter out messages that are not for our fabric
- return
- # process the event with a debounce timer
+ if service_type != MDNS_TYPE_OPERATIONAL_NODE:
+ return
+
+ if not (match := RE_MDNS_SERVICE_NAME.match(name)):
+ LOGGER.getChild("mdns").warning(
+ "Service name doesn't match expected operational node pattern: %s", name
+ )
+ return
+
+ fabric_id_hex, node_id_hex = match.groups()
+
+ # Filter messages of other fabrics
+ if int(fabric_id_hex, 16) != self.compressed_fabric_id:
+ return
+
+ # Process the event with a debounce timer
self._mdns_event_timer[name] = self._loop.call_later(
- 0.5, self._on_mdns_operational_node_state, name, state_change
+ 0.5,
+ self._on_mdns_operational_node_state,
+ name,
+ int(node_id_hex, 16),
+ state_change,
)
def _on_mdns_operational_node_state(
- self, name: str, state_change: ServiceStateChange
+ self, name: str, node_id: int, state_change: ServiceStateChange
) -> None:
"""Handle a (operational) Matter node MDNS state change."""
self._mdns_event_timer.pop(name, None)
- logger = LOGGER.getChild("mdns")
- # the mdns name is constructed as [fabricid]-[nodeid]._matter._tcp.local.
- # extract the node id from the name
- node_id = int(name.split("-")[1].split(".")[0], 16)
- node_logger = self.get_node_logger(logger, node_id)
+ node_logger = self.get_node_logger(LOGGER.getChild("mdns"), node_id)
if not (node := self._nodes.get(node_id)):
return # this should not happen, but guard just in case
@@ -1577,6 +1701,11 @@ async def _node_offline(self, node_id: int) -> None:
node_logger.info("Node considered offline, shutdown subscription")
await self._chip_device_controller.shutdown_subscription(node_id)
+ # inform listeners for update callbacks that this subscription is now offline
+ if node_id in self._attribute_update_callbacks:
+ for callback in self._attribute_update_callbacks[node_id]:
+ self._loop.create_task(callback(None, None, None))
+
# mark node as unavailable (if it wasn't already)
self._node_unavailable(node_id)
diff --git a/matter_server/server/helpers/custom_web_runner.py b/matter_server/server/helpers/custom_web_runner.py
index d0233fd7..27aa96bb 100644
--- a/matter_server/server/helpers/custom_web_runner.py
+++ b/matter_server/server/helpers/custom_web_runner.py
@@ -21,7 +21,7 @@ class MultiHostTCPSite(web.BaseSite):
explicitly), we would like to pass an array of strings.
"""
- __slots__ = ("_host", "_port", "_reuse_address", "_reuse_port", "_hosturl")
+ __slots__ = ("_host", "_hosturl", "_port", "_reuse_address", "_reuse_port")
def __init__(
self,
diff --git a/matter_server/server/helpers/utils.py b/matter_server/server/helpers/utils.py
index a37425a5..a0a2ab49 100644
--- a/matter_server/server/helpers/utils.py
+++ b/matter_server/server/helpers/utils.py
@@ -4,8 +4,6 @@
from contextlib import suppress
import platform
-import async_timeout
-
PLATFORM_MAC = platform.system() == "Darwin"
@@ -24,7 +22,7 @@ async def ping_ip(ip_address: str, timeout: int = 2, attempts: int = 1) -> bool:
try:
# we add an additional timeout here as safeguard and to account for the fact
# that macos does not seem to have timeout on ping6
- async with async_timeout.timeout(timeout + 2):
+ async with asyncio.timeout(timeout + 2):
success = (await check_output(cmd))[0] == 0
if success or not attempts:
return success
diff --git a/matter_server/server/ota/__init__.py b/matter_server/server/ota/__init__.py
index 21cf52c7..b054d75f 100644
--- a/matter_server/server/ota/__init__.py
+++ b/matter_server/server/ota/__init__.py
@@ -8,7 +8,9 @@
from matter_server.common.models import UpdateSource
from matter_server.server.ota import dcl
-_local_updates: dict[tuple[int, int], dict] = {}
+MatterProduct = tuple[int, int]
+
+_local_updates: dict[MatterProduct, dict[int | str, dict]] = {}
async def load_local_updates(ota_provider_dir: Path) -> None:
@@ -21,9 +23,12 @@ def _load_update(ota_provider_dir: Path) -> None:
with open(update_file) as f:
update = json.load(f)
model_version = update["modelVersion"]
- _local_updates[(model_version["vid"], model_version["pid"])] = (
- model_version
- )
+ model_key = (model_version["vid"], model_version["pid"])
+ update_dict = _local_updates.get(model_key, {})
+ # Store by string or integer, this allows update by both
+ update_dict[model_version["softwareVersion"]] = model_version
+ update_dict[model_version["softwareVersionString"]] = model_version
+ _local_updates[model_key] = update_dict
await asyncio.get_running_loop().run_in_executor(
None, _load_update, ota_provider_dir
@@ -38,14 +43,16 @@ async def check_for_update(
requested_software_version: int | str | None = None,
) -> tuple[UpdateSource, dict] | tuple[None, None]:
"""Check for software updates."""
- if (vid, pid) in _local_updates:
- local_update = _local_updates[(vid, pid)]
- if (
- requested_software_version is None
- or local_update["softwareVersion"] == requested_software_version
- or local_update["softwareVersionString"] == requested_software_version
- ):
- return UpdateSource.LOCAL, local_update
+ if local_updates := _local_updates.get((vid, pid)):
+ logger.info("Local updates found for this device")
+ if requested_software_version is None:
+ # Use integer version to reliably determine absolute latest version
+ versions = filter(
+ lambda version: isinstance(version, int), local_updates.keys()
+ )
+ return UpdateSource.LOCAL, local_updates[max(versions)]
+ if requested_software_version in local_updates:
+ return UpdateSource.LOCAL, local_updates[requested_software_version]
if dcl_update := await dcl.check_for_update(
logger, vid, pid, current_software_version, requested_software_version
diff --git a/matter_server/server/ota/provider.py b/matter_server/server/ota/provider.py
index f53aa316..7702440e 100644
--- a/matter_server/server/ota/provider.py
+++ b/matter_server/server/ota/provider.py
@@ -149,13 +149,13 @@ async def _commission_ota_provider(
)
)
if write_result[0].Status != Status.Success:
- logging.error(
+ LOGGER.error(
"Failed writing adjusted OTA Provider App ACL: Status %s.",
str(write_result[0].Status),
)
raise UpdateError("Error while setting up OTA Provider.")
except ChipStackError as ex:
- logging.exception("Failed setting up OTA Provider.", exc_info=ex)
+ LOGGER.exception("Failed setting up OTA Provider.", exc_info=ex)
raise UpdateError("Error while setting up OTA Provider.") from ex
async def start_update(
@@ -320,10 +320,10 @@ async def fetch_update(self, update_desc: dict) -> None:
if parsed_url.scheme in ["http", "https"]:
file_path = await self._download_update(url, checksum_alg)
- elif parsed_url.scheme in ["file"]:
+ elif parsed_url.scheme == "file":
file_path = self._ota_provider_base_dir / Path(parsed_url.path[1:])
if not await asyncio.to_thread(file_path.exists):
- logging.warning("Local update file not found: %s", file_path)
+ LOGGER.warning("Local update file not found: %s", file_path)
raise UpdateError("Local update file not found")
if checksum_alg:
checksum_alg.update(await asyncio.to_thread(file_path.read_bytes))
@@ -353,6 +353,12 @@ async def check_update_state(
) -> None:
"""Check the update state of a node and take appropriate action."""
+ if path is None:
+ self._ota_done.set_exception(
+ UpdateError("Device went offline during OTA update")
+ )
+ return
+
if str(path) != OTA_SOFTWARE_UPDATE_REQUESTOR_UPDATE_STATE_ATTRIBUTE_PATH:
return
diff --git a/matter_server/server/sdk.py b/matter_server/server/sdk.py
index 3485c371..3add3f83 100644
--- a/matter_server/server/sdk.py
+++ b/matter_server/server/sdk.py
@@ -338,15 +338,17 @@ async def read(
allowPASE=False,
timeoutMs=None,
)
+ transaction = Attribute.AsyncReadTransaction(
+ future, self.server.loop, self._chip_controller, True
+ )
Attribute.Read(
- future=future,
- eventLoop=self.server.loop,
+ transaction=transaction,
device=device.deviceProxy,
- devCtrl=self._chip_controller,
attributes=attributes,
fabricFiltered=fabric_filtered,
).raise_on_error()
- return await future
+ await future
+ return transaction.GetReadResponse()
async def write_attribute(
self,
diff --git a/matter_server/server/server.py b/matter_server/server/server.py
index 68b78f00..e80c1aac 100644
--- a/matter_server/server/server.py
+++ b/matter_server/server/server.py
@@ -4,12 +4,13 @@
import asyncio
from functools import cached_property, partial
+import inspect
import ipaddress
import logging
import os
from pathlib import Path
import traceback
-from typing import TYPE_CHECKING, Any, cast
+from typing import TYPE_CHECKING, Any
import weakref
from aiohttp import web
@@ -100,7 +101,7 @@ class MatterServer:
_runner: web.AppRunner | None = None
_http: MultiHostTCPSite | None = None
- def __init__( # noqa: PLR0913, pylint: disable=too-many-arguments
+ def __init__( # noqa: PLR0913, pylint: disable=too-many-positional-arguments, too-many-arguments
self,
storage_path: str,
vendor_id: int,
@@ -146,6 +147,11 @@ def __init__( # noqa: PLR0913, pylint: disable=too-many-arguments
raise RuntimeError(
"Minimum supported schema version can't be higher than current schema version."
)
+ self.logger.info("Matter Server initialized")
+ self.logger.info(
+ "Using '%s' as primary interface (for link-local addresses)",
+ self.primary_interface,
+ )
@cached_property
def device_controller(self) -> MatterDeviceController:
@@ -287,11 +293,9 @@ def scope_ipv6_lla(self, ip_addr: str) -> str:
if not ip_addr_parsed.is_link_local or ip_addr_parsed.version != 6:
return ip_addr
- ip_addr_parsed = cast(ipaddress.IPv6Address, ip_addr_parsed)
-
if ip_addr_parsed.scope_id is not None:
# This type of IPv6 manipulation is not supported by the ipaddress lib
- ip_addr = ip_addr.split("%")[0]
+ ip_addr = ip_addr.split("%", maxsplit=1)[0]
# Rely on host OS routing table
if self.primary_interface is None:
@@ -315,18 +319,24 @@ def register_api_command(
def _register_api_commands(self) -> None:
"""Register all methods decorated as api_command."""
- for cls in (self, self._device_controller, self.vendor_info):
- for attr_name in dir(cls):
+ for obj in (self, self._device_controller, self.vendor_info):
+ cls = obj.__class__
+ for attr_name, attr in inspect.getmembers(cls):
if attr_name.startswith("_"):
continue
- val = getattr(cls, attr_name)
- if not hasattr(val, "api_cmd"):
+
+ if isinstance(attr, property):
+ continue # skip properties
+
+ # attr is the (unbound) function, we can check for the decorator
+ if not hasattr(attr, "api_cmd"):
continue
- if hasattr(val, "mock_calls"):
- # filter out mocks
+ if hasattr(attr, "mock_calls"):
continue
- # method is decorated with our api decorator
- self.register_api_command(val.api_cmd, val)
+
+ # Get the instance method before registering
+ bound_method = getattr(obj, attr_name)
+ self.register_api_command(attr.api_cmd, bound_method)
async def _handle_info(self, request: web.Request) -> web.Response:
"""Handle info endpoint to serve basic server (version) info."""
diff --git a/matter_server/server/stack.py b/matter_server/server/stack.py
index 2393bead..fd60f280 100644
--- a/matter_server/server/stack.py
+++ b/matter_server/server/stack.py
@@ -30,10 +30,10 @@
CHIP_DETAIL = logging.DEBUG - 1
CHIP_AUTOMATION = logging.DEBUG - 2
-_category_num: int = 4
+_category_num: int = 4 # pylint: disable=invalid-name
-@LogRedirectCallback_t # type: ignore[misc]
+@LogRedirectCallback_t # type: ignore[untyped-decorator]
def _redirect_to_python_logging(
category: int, raw_module: bytes, raw_message: bytes
) -> None:
diff --git a/matter_server/server/storage.py b/matter_server/server/storage.py
index eeb896aa..de15cc84 100644
--- a/matter_server/server/storage.py
+++ b/matter_server/server/storage.py
@@ -5,8 +5,11 @@
import asyncio
import logging
from pathlib import Path
+import shutil
from typing import TYPE_CHECKING, Any, cast
+from atomicwrites import atomic_write
+
from ..common.helpers.json import JSON_DECODE_EXCEPTIONS, json_dumps, json_loads
if TYPE_CHECKING:
@@ -152,11 +155,15 @@ async def async_save(self) -> None:
def do_save() -> None:
# make backup before we write a new file
+ self.filename_backup.unlink(True)
if self.filename.is_file():
- self.filename.replace(self.filename_backup)
+ shutil.copy(self.filename, self.filename_backup)
- with open(self.filename, "w", encoding="utf-8") as _file:
+ # use atomomic write to avoid corrupting the file
+ # if power is cut during write, we don't write a corrupted file
+ with atomic_write(self.filename, encoding="utf-8", overwrite=True) as _file:
_file.write(json_dumps(self._data))
+
LOGGER.debug("Saved data to persistent storage")
async with self._save_lock:
diff --git a/pyproject.toml b/pyproject.toml
index b79a65ed..90e37c70 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,54 +7,53 @@ authors = [
{name = "The Home Assistant Authors", email = "hello@home-assistant.io"},
]
classifiers = [
- "Development Status :: 3 - Alpha",
+ "Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Environment :: Console",
- "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
+ "Programming Language :: Python :: 3.13",
"Topic :: Home Automation",
]
dependencies = [
"aiohttp",
"aiorun",
- "async-timeout",
"coloredlogs",
"orjson",
- "home-assistant-chip-clusters==2024.7.1",
+ "home-assistant-chip-clusters==2025.7.0",
]
-description = "Python Matter WebSocket Server"
+description = "Open Home Foundation Matter Server"
license = {text = "Apache-2.0"}
name = "python-matter-server"
readme = "README.md"
-requires-python = ">=3.11"
+requires-python = ">=3.12"
# The version is set by GH action on release!
version = "0.0.0"
[project.optional-dependencies]
server = [
- "aiohttp==3.10.5",
- "aiorun==2024.8.1",
- "async-timeout==4.0.3",
+ "aiohttp==3.13.5",
+ "aiorun==2025.1.1",
+ "atomicwrites==1.4.1",
"coloredlogs==15.0.1",
- "cryptography==43.0.1",
- "orjson==3.10.7",
- "zeroconf==0.134.0",
- "home-assistant-chip-core==2024.7.1",
+ "cryptography==49.0.0",
+ "orjson==3.11.9",
+ "zeroconf==0.149.17",
+ "home-assistant-chip-core==2025.7.0",
]
test = [
- "aioresponses==0.7.6",
- "codespell==2.3.0",
- "isort==5.13.2",
- "mypy==1.11.2",
- "pre-commit==3.8.0",
- "pre-commit-hooks==4.6.0",
- "pylint==3.2.7",
- "pytest==8.3.3",
- "pytest-asyncio==0.24.0",
- "pytest-aiohttp==1.0.5",
- "pytest-cov==5.0.0",
- "ruff==0.6.5",
- "tomli==2.0.1",
+ "aioresponses==0.7.8",
+ "codespell==2.4.2",
+ "isort==8.0.1",
+ "mypy==2.1.0",
+ "pre-commit==4.6.0",
+ "pre-commit-hooks==6.0.0",
+ "pylint==4.0.6",
+ "pytest==9.1.1",
+ "pytest-asyncio==1.4.0",
+ "pytest-aiohttp==1.1.1",
+ "pytest-cov==7.1.0",
+ "ruff==0.15.18",
+ "tomli==2.4.1",
]
[project.scripts]
@@ -117,6 +116,7 @@ good-names = [
[tool.pylint.DESIGN]
max-args = 10
max-attributes = 12
+max-positional-arguments = 10
[tool.pylint."MESSAGES CONTROL"]
disable = [
@@ -154,7 +154,6 @@ convention = "pep257"
ignore = [
"ANN002", # Just annoying, not really useful
"ANN003", # Just annoying, not really useful
- "ANN101", # Self... explanatory
"ANN401", # Opinioated warning on disallowing dynamically typed expressions
"D203", # Conflicts with other rules
"D213", # Conflicts with other rules
@@ -169,6 +168,8 @@ ignore = [
"TD004", # Just annoying, not really useful
"COM812", # Conflict with the Ruff formatter
"ISC001", # Conflict with the Ruff formatter
+ # Quotes for typing.cast generally not necessary, only for performance critical paths
+ "TC006", # Add quotes to type expression in typing.cast()
"TID252", # TEMPORARY DISABLED
"N805", # TEMPORARY DISABLED
"EXE002", # TEMPORARY DISABLED
@@ -213,7 +214,6 @@ ignore = [
"N801", # TEMPORARY DISABLED
"N813", # TEMPORARY DISABLED
"RUF012", # TEMPORARY DISABLED
- "ANN102", # TEMPORARY DISABLED
"B007", # TEMPORARY DISABLED
"SIM102", # TEMPORARY DISABLED
"C901", # TEMPORARY DISABLED
@@ -222,7 +222,6 @@ ignore = [
"SLF001", # TEMPORARY DISABLED
"RUF010", # TEMPORARY DISABLED
"TRY300", # TEMPORARY DISABLED
- "UP038", # TEMPORARY DISABLED
"PTH118", # TEMPORARY DISABLED
"PTH112", # TEMPORARY DISABLED
"PTH102", # TEMPORARY DISABLED
@@ -239,6 +238,9 @@ ignore = [
select = ["ALL"]
+[tool.ruff.lint.flake8-builtins]
+builtins-allowed-modules = ["json"]
+
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
diff --git a/scripts/generate_devices.py b/scripts/generate_devices.py
index d073e13e..5d0ab1d9 100644
--- a/scripts/generate_devices.py
+++ b/scripts/generate_devices.py
@@ -32,7 +32,7 @@ def gen_cls_name(name: str):
if char in ("-", "/"):
next_upper = True
continue
- elif char in ("."):
+ elif char == ".":
continue
elif next_upper:
char = char.upper()
@@ -88,12 +88,6 @@ def __hash__(self) -> int:
for device in data["configurator"]["deviceType"]:
name = device["typeName"]
- if not name.startswith("Matter "):
- print("Unexpected: device doesn't start with Matter. Skipping")
- continue
-
- name = name[len("Matter ") :]
-
print(name, device["deviceId"]["#text"])
clusters = device["clusters"]["include"]
@@ -119,9 +113,6 @@ def __hash__(self) -> int:
# It's optional server cluster
or cluster["@serverLocked"] == "false"
)
- # Temporary: PollControl will be removed from matter_devices.xml
- # https://github.com/project-chip/connectedhomeip/pull/22718
- and cluster["@cluster"] != "Poll Control"
)
+ ",}" # extra comma to force black to do a cluster per line
)
diff --git a/tests/common/test_parser.py b/tests/common/test_parser.py
index 3867ec0f..bdce1289 100644
--- a/tests/common/test_parser.py
+++ b/tests/common/test_parser.py
@@ -3,7 +3,7 @@
from dataclasses import dataclass
import datetime
from enum import Enum, IntEnum
-from typing import Optional, Union
+from typing import Union
from chip.clusters.Types import Nullable, NullValue
import pytest
@@ -34,7 +34,7 @@ class BasicModelChild:
a: int
b: str
c: str
- d: Optional[int]
+ d: int | None
@dataclass
@@ -44,7 +44,7 @@ class BasicModel:
a: int
b: float
c: str
- d: Optional[int]
+ d: int | None
e: BasicModelChild
f: datetime.datetime
g: MatterEnum
diff --git a/tests/ruff.toml b/tests/ruff.toml
index 83ab9fd7..ea51db73 100644
--- a/tests/ruff.toml
+++ b/tests/ruff.toml
@@ -8,6 +8,6 @@ lint.extend-select = [
lint.extend-ignore = [
"S101", # Use of assert detected. As these are tests...
"SLF001", # Tests will access private/protected members...
- "TCH002", # pytest doesn't like this one...
+ "TC002", # pytest doesn't like this one...
"PT012", # annoying with tests
]
diff --git a/tests/server/ota/test_dcl.py b/tests/server/ota/test_dcl.py
index eb507aba..0509d98b 100644
--- a/tests/server/ota/test_dcl.py
+++ b/tests/server/ota/test_dcl.py
@@ -8,6 +8,7 @@
from aioresponses import aioresponses
import pytest
+from matter_server.server.helpers import DCL_PRODUCTION_URL
from matter_server.server.ota.dcl import check_for_update
@@ -24,22 +25,31 @@ def mock_aioresponse():
yield m
+def mock_dcl_version(
+ aioresponse, vid: int, pid: int, version: int | None = None, suffix: str = ""
+) -> dict:
+ """Test."""
+ if version:
+ data = _load_fixture(f"{vid}-{pid}-{version}{suffix}.json")
+ url = DCL_PRODUCTION_URL + f"/dcl/model/versions/{vid}/{pid}/{version}"
+ else:
+ data = _load_fixture(f"{vid}-{pid}{suffix}.json")
+ url = DCL_PRODUCTION_URL + f"/dcl/model/versions/{vid}/{pid}"
+ aioresponse.get(url=url, status=200, payload=data)
+ return data
+
+
@pytest.fixture(name="get_software_versions", autouse=True)
def _mock_get_software_versions(aioresponse) -> None:
"""Mock the _get_software_versions function."""
- data = _load_fixture("4447-8194.json")
- aioresponse.get(url="/dcl/model/versions/4447/8194", status=200, payload=data)
- aioresponse.get(
- url="/dcl/model/versions/4447/8194/1000",
- payload=_load_fixture("4447-8194-1000.json"),
- )
+ mock_dcl_version(aioresponse, 4447, 8194)
+ mock_dcl_version(aioresponse, 4447, 8194, 1000)
async def test_check_updates(aioresponse):
"""Test the case where the latest software version is applicable."""
# Call the function with a current software version of 1000
- data = _load_fixture("4447-8194-1011-valid.json")
- aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
+ data = mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
result = await check_for_update(MagicMock(), 4447, 8194, 1000)
assert result == data["modelVersion"]
@@ -48,8 +58,7 @@ async def test_check_updates(aioresponse):
async def test_check_updates_not_applicable(aioresponse):
"""Test the case where the latest software version is not applicable."""
# Call the function with a current software version of 2000
- data = _load_fixture("4447-8194-1011-valid.json")
- aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
+ mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
result = await check_for_update(MagicMock(), 4447, 8194, 2000)
assert result is None
@@ -57,8 +66,7 @@ async def test_check_updates_not_applicable(aioresponse):
async def test_check_updates_not_applicable_not_valid(aioresponse):
"""Test the case where the latest software version is not valid."""
- data = _load_fixture("4447-8194-1011-invalid.json")
- aioresponse.get(url="/dcl/model/versions/4447/8194/1011", status=200, payload=data)
+ mock_dcl_version(aioresponse, 4447, 8194, 1011, "-invalid")
result = await check_for_update(MagicMock(), 4447, 8194, 1000)
assert result is None
@@ -67,8 +75,7 @@ async def test_check_updates_not_applicable_not_valid(aioresponse):
async def test_check_updates_specific_version(aioresponse):
"""Test the case to get a specific version."""
# Call the function with a current software version of 1000 and request 1011 as update
- data = _load_fixture("4447-8194-1011-valid.json")
- aioresponse.get(url="/dcl/model/versions/4447/8194/1011", payload=data)
+ data = mock_dcl_version(aioresponse, 4447, 8194, 1011, "-valid")
result = await check_for_update(MagicMock(), 4447, 8194, 1000, 1011)
assert result == data["modelVersion"]
@@ -77,14 +84,10 @@ async def test_check_updates_specific_version(aioresponse):
async def test_check_no_update_if_url_empty(aioresponse):
"""Test the case checks if latest version gets picked version."""
# Call the function with a current software version of 1000 and request 1011 as update
- data = _load_fixture("4442-67.json")
- aioresponse.get(url="/dcl/model/versions/4442/67", payload=data)
- data = _load_fixture("4442-67-197888.json")
- aioresponse.get(url="/dcl/model/versions/4442/67/197888", payload=data)
- data = _load_fixture("4442-67-197910.json")
- aioresponse.get(url="/dcl/model/versions/4442/67/197910", payload=data)
- data = _load_fixture("4442-67-198340.json")
- aioresponse.get(url="/dcl/model/versions/4442/67/198340", payload=data)
+ mock_dcl_version(aioresponse, 4442, 67)
+ mock_dcl_version(aioresponse, 4442, 67, 197888)
+ mock_dcl_version(aioresponse, 4442, 67, 197910)
+ mock_dcl_version(aioresponse, 4442, 67, 198340)
result = await check_for_update(MagicMock(), 4442, 67, 197120)
assert result is None
diff --git a/tests/server/test_server.py b/tests/server/test_server.py
index 1afedd86..a8b9fbb6 100644
--- a/tests/server/test_server.py
+++ b/tests/server/test_server.py
@@ -77,11 +77,6 @@ def chip_stack_fixture() -> Generator[MagicMock, None, None]:
@pytest.fixture(name="certificate_authority_manager")
def certificate_authority_manager_fixture() -> Generator[MagicMock, None, None]:
"""Return a mocked certificate authority manager."""
-
- # Necessary for patching within tests
- # pylint: disable=unused-import,import-outside-toplevel
- import chip.CertificateAuthority # noqa: F401
-
with patch(
"matter_server.server.stack.chip.CertificateAuthority.CertificateAuthorityManager",
autospec=True,
diff --git a/tests/test_device_controller.py b/tests/test_device_controller.py
new file mode 100644
index 00000000..eb142595
--- /dev/null
+++ b/tests/test_device_controller.py
@@ -0,0 +1,39 @@
+"""Device controller tests."""
+
+import pytest
+
+from matter_server.server.device_controller import RE_MDNS_SERVICE_NAME
+
+
+@pytest.mark.parametrize(
+ ("name", "expected"),
+ [
+ (
+ "D22DC25523A78A89-0000000000000125._matter._tcp.local.",
+ ("D22DC25523A78A89", "0000000000000125"),
+ ),
+ (
+ "d22dc25523a78a89-0000000000000125._matter._tcp.local.",
+ ("d22dc25523a78a89", "0000000000000125"),
+ ),
+ ],
+)
+def test_valid_mdns_service_names(name, expected):
+ """Test valid mDNS service names."""
+ match = RE_MDNS_SERVICE_NAME.match(name)
+ assert match is not None
+ assert match.groups() == expected
+
+
+@pytest.mark.parametrize(
+ "name",
+ [
+ "D22DC25523A78A89-0000000000000125 (2)._matter._tcp.local.",
+ "D22DC25523A78A89-0000000000000125.._matter._tcp.local.",
+ "G22DC25523A78A89-0000000000000125._matter._tcp.local.", # invalid hex
+ "D22DC25523A78A89-0000000000000125._matterc._udp.local.",
+ ],
+)
+def test_invalid_mdns_service_names(name):
+ """Test invalid mDNS service names."""
+ assert RE_MDNS_SERVICE_NAME.match(name) is None
diff --git a/tests/test_fabric_label_validation.py b/tests/test_fabric_label_validation.py
new file mode 100644
index 00000000..bc609dcd
--- /dev/null
+++ b/tests/test_fabric_label_validation.py
@@ -0,0 +1,120 @@
+"""Test fabric label validation functionality."""
+# pylint: disable=protected-access
+
+import logging
+
+import pytest
+
+
+class MockDeviceController:
+ """Mock device controller with fabric label validation logic."""
+
+ def __init__(self):
+ """Initialize mock device controller."""
+ self._default_fabric_label = None
+ self.logger = logging.getLogger(__name__)
+
+ async def set_default_fabric_label(self, label: str | None) -> None:
+ """Set the default fabric label with validation."""
+ if label is not None and len(label) > 32:
+ self.logger.info(
+ "Fabric label '%s' exceeds 32 characters, truncating to '%s'",
+ label,
+ label[:32],
+ )
+ label = label[:32]
+ self._default_fabric_label = label
+
+
+class TestFabricLabelValidation:
+ """Test fabric label length validation."""
+
+ @pytest.fixture
+ def mock_device_controller(self):
+ """Create a mock device controller for testing."""
+ return MockDeviceController()
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_under_32_chars(self, mock_device_controller, caplog):
+ """Test that fabric labels under 32 characters are not modified."""
+ label = "Short Label"
+
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(label)
+
+ assert mock_device_controller._default_fabric_label == label
+ assert not caplog.records # No log messages should be generated
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_exactly_32_chars(self, mock_device_controller, caplog):
+ """Test that fabric labels exactly 32 characters are not modified."""
+ label = "A" * 32 # Exactly 32 characters
+
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(label)
+
+ assert mock_device_controller._default_fabric_label == label
+ assert len(mock_device_controller._default_fabric_label) == 32
+ assert not caplog.records # No log messages should be generated
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_over_32_chars_truncated(
+ self, mock_device_controller, caplog
+ ):
+ """Test that fabric labels over 32 characters are truncated."""
+ long_label = (
+ "This is a very long fabric label that exceeds the 32 character limit"
+ )
+ expected_truncated = long_label[:32]
+
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(long_label)
+
+ assert mock_device_controller._default_fabric_label == expected_truncated
+ assert len(mock_device_controller._default_fabric_label) == 32
+
+ # Check that a log message was generated
+ assert len(caplog.records) == 1
+ assert caplog.records[0].levelname == "INFO"
+ assert "exceeds 32 characters, truncating" in caplog.records[0].message
+ assert long_label in caplog.records[0].message
+ assert expected_truncated in caplog.records[0].message
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_none_value(self, mock_device_controller, caplog):
+ """Test that None values are handled properly."""
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(None)
+
+ assert mock_device_controller._default_fabric_label is None
+ assert not caplog.records # No log messages should be generated
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_empty_string(self, mock_device_controller, caplog):
+ """Test that empty strings are handled properly."""
+ label = ""
+
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(label)
+
+ assert mock_device_controller._default_fabric_label == label
+ assert not caplog.records # No log messages should be generated
+
+ @pytest.mark.asyncio
+ async def test_fabric_label_unicode_characters(
+ self, mock_device_controller, caplog
+ ):
+ """Test that unicode characters are handled properly in truncation."""
+ # Unicode string that's longer than 32 characters
+ unicode_label = "Café™ ★ 🏠 This is a unicode string that exceeds 32 chars"
+ expected_truncated = unicode_label[:32]
+
+ with caplog.at_level(logging.INFO):
+ await mock_device_controller.set_default_fabric_label(unicode_label)
+
+ assert mock_device_controller._default_fabric_label == expected_truncated
+ assert len(mock_device_controller._default_fabric_label) == 32
+
+ # Check that a log message was generated
+ assert len(caplog.records) == 1
+ assert "exceeds 32 characters, truncating" in caplog.records[0].message