├── .github ├── ISSUE_TEMPLATE │ └── config.yml ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── pr-labels.yaml │ ├── release-drafter.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── .pre-commit-config.yaml ├── DEVELOPMENT.md ├── Dockerfile ├── Dockerfile.dev ├── LICENSE ├── README.md ├── dashboard ├── .gitignore ├── README.md ├── note.md ├── package-lock.json ├── package.json ├── public │ └── index.html ├── rollup.config.mjs ├── script │ ├── build │ ├── develop │ └── setup ├── src │ ├── client │ │ ├── client-context.ts │ │ ├── client.ts │ │ ├── connection.ts │ │ ├── exceptions.ts │ │ └── models │ │ │ ├── descriptions.ts │ │ │ ├── model.ts │ │ │ └── node.ts │ ├── components │ │ ├── dialog-box │ │ │ ├── dialog-box.ts │ │ │ └── show-dialog-box.ts │ │ ├── dialogs │ │ │ ├── acl │ │ │ │ └── model.ts │ │ │ ├── binding │ │ │ │ ├── model.ts │ │ │ │ ├── node-binding-dialog.ts │ │ │ │ └── show-node-binding-dialog.ts │ │ │ └── commission-node-dialog │ │ │ │ ├── commission-node-dialog.ts │ │ │ │ ├── commission-node-existing.ts │ │ │ │ ├── commission-node-thread.ts │ │ │ │ ├── commission-node-wifi.ts │ │ │ │ └── show-commission-node-dialog.ts │ │ └── ha-svg-icon.ts │ ├── entrypoint │ │ └── main.ts │ ├── pages │ │ ├── components │ │ │ ├── context.ts │ │ │ ├── footer.ts │ │ │ ├── header.ts │ │ │ ├── node-details.ts │ │ │ └── server-details.ts │ │ ├── matter-cluster-view.ts │ │ ├── matter-dashboard-app.ts │ │ ├── matter-endpoint-view.ts │ │ ├── matter-node-view.ts │ │ └── matter-server-view.ts │ └── util │ │ ├── clone_class.ts │ │ ├── fire_event.ts │ │ ├── prevent_default.ts │ │ └── routing.ts └── tsconfig.json ├── docker-entrypoint.sh ├── docs ├── docker.md ├── matter_logo.svg ├── os_requirements.md └── websockets_api.md ├── main.py ├── matter_server ├── __init__.py ├── client │ ├── __init__.py │ ├── client.py │ ├── connection.py │ ├── exceptions.py │ └── models │ │ ├── __init__.py │ │ ├── device_types.py │ │ └── node.py ├── common │ ├── __init__.py │ ├── const.py │ ├── custom_clusters.py │ ├── errors.py │ ├── helpers │ │ ├── api.py │ │ ├── json.py │ │ ├── logger.py │ │ └── util.py │ └── models.py ├── py.typed └── server │ ├── __init__.py │ ├── __main__.py │ ├── client_handler.py │ ├── const.py │ ├── device_controller.py │ ├── helpers │ ├── __init__.py │ ├── attributes.py │ ├── custom_web_runner.py │ ├── paa_certificates.py │ └── utils.py │ ├── ota │ ├── __init__.py │ ├── dcl.py │ └── provider.py │ ├── sdk.py │ ├── server.py │ ├── stack.py │ ├── storage.py │ └── vendor_info.py ├── pyproject.toml ├── scripts ├── beautify_diagnostics.py ├── example.py ├── generate_descriptions.py ├── generate_devices.py ├── run-in-env.sh └── setup.sh └── tests ├── __init__.py ├── common ├── __init__.py ├── test_parser.py └── test_utils.py ├── fixtures ├── __init__.py ├── nodes │ ├── _fake_template │ ├── contact-sensor-example-app.json │ ├── fake-bridge-two-light.json │ ├── fake-temperature-sensor.json │ ├── fake_color_temperature_light.json │ ├── fake_extended_color_light.json │ ├── fake_flow_sensor.json │ ├── fake_humidity_sensor.json │ ├── fake_light_sensor.json │ ├── fake_pressure_sensor.json │ ├── lighting-example-app.json │ └── onoff-switch-example-app.json └── nodes_in_ha │ ├── contact-sensor-example-app.json │ ├── fake-bridge-two-light.json │ ├── fake-temperature-sensor.json │ ├── fake_color_temperature_light.json │ ├── fake_extended_color_light.json │ ├── fake_flow_sensor.json │ ├── fake_humidity_sensor.json │ ├── fake_light_sensor.json │ ├── fake_pressure_sensor.json │ ├── lighting-example-app.json │ └── onoff-switch-example-app.json ├── ruff.toml ├── server ├── __init__.py ├── ota │ ├── fixtures │ │ ├── 4442-67-197888.json │ │ ├── 4442-67-197910.json │ │ ├── 4442-67-198340.json │ │ ├── 4442-67.json │ │ ├── 4447-8194-1000.json │ │ ├── 4447-8194-1011-invalid.json │ │ ├── 4447-8194-1011-valid.json │ │ └── 4447-8194.json │ └── test_dcl.py └── test_server.py └── test_device_controller.py /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: I have an issue or bug regarding using Matter with Home Assistant 4 | url: https://github.com/home-assistant/core/issues?q=is:issue+is:open+label:%22integration:+matter%22 5 | about: This is the issue tracker for the Matter server library. Unless you are an application developer utilizing this library, please do not post issues directly here. Instead report them at our Home Assistant core project. 6 | - name: I'm looking for documentation how to setup Matter in Home Assistant 7 | url: https://www.home-assistant.io/integrations/matter/ 8 | about: We have extensive documentation for Matter on our website. 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: daily 12 | open-pull-requests-limit: 10 13 | - package-ecosystem: "pip" 14 | directory: "/" # Location of package manifests 15 | schedule: 16 | interval: "weekly" 17 | open-pull-requests-limit: 10 18 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: '$RESOLVED_VERSION' 2 | tag-template: '$RESOLVED_VERSION' 3 | change-template: '- #$NUMBER - $TITLE (@$AUTHOR)' 4 | categories: 5 | - title: "⚠ Breaking Changes" 6 | labels: 7 | - 'breaking-change' 8 | - title: '⬆️ Dependencies and CI' 9 | collapse-after: 1 10 | labels: 11 | - 'dependencies' 12 | - 'ci' 13 | template: | 14 | ## What’s Changed 15 | 16 | $CHANGES 17 | version-resolver: 18 | major: 19 | labels: 20 | - 'breaking-change' 21 | minor: 22 | labels: 23 | - 'new-feature' 24 | - 'enhancement' 25 | default: patch 26 | -------------------------------------------------------------------------------- /.github/workflows/pr-labels.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: PR Labels 3 | 4 | # yamllint disable-line rule:truthy 5 | on: 6 | pull_request: 7 | types: 8 | - synchronize 9 | - labeled 10 | - unlabeled 11 | branches: 12 | - main 13 | 14 | jobs: 15 | pr_labels: 16 | name: Verify 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: 🏷 Verify PR has a valid label 20 | uses: ludeeus/action-require-labels@1.1.0 21 | with: 22 | labels: >- 23 | breaking-change, bugfix, refactor, new-feature, maintenance, ci, dependencies, docs 24 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | # Drafts your next Release notes as Pull Requests are merged into "master" 13 | - uses: release-drafter/release-drafter@v6.1.0 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Publish releases 2 | 3 | on: 4 | release: 5 | types: [published] 6 | env: 7 | PYTHON_VERSION: "3.12" 8 | NODE_VERSION: "18.x" 9 | 10 | jobs: 11 | build-and-publish-pypi: 12 | name: Builds and publishes releases to PyPI 13 | runs-on: ubuntu-latest 14 | outputs: 15 | version: ${{ steps.vars.outputs.tag }} 16 | steps: 17 | - uses: actions/checkout@v4.2.2 18 | - name: Get tag 19 | id: vars 20 | run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT 21 | - name: Validate version number 22 | run: >- 23 | if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then 24 | if ! [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then 25 | echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})" 26 | exit 1 27 | fi 28 | else 29 | if [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then 30 | echo "Release: Tag must not have a beta suffix (${{ steps.vars.outputs.tag }})" 31 | exit 1 32 | fi 33 | fi 34 | - name: Set up Python ${{ env.PYTHON_VERSION }} 35 | uses: actions/setup-python@v5.6.0 36 | with: 37 | python-version: ${{ env.PYTHON_VERSION }} 38 | - name: Set up Node ${{ env.NODE_VERSION }} 39 | uses: actions/setup-node@v4 40 | with: 41 | node-version: ${{ env.NODE_VERSION }} 42 | - name: Install build 43 | run: >- 44 | pip install build tomli tomli-w 45 | - name: Set Python project version from tag 46 | shell: python 47 | run: |- 48 | import tomli 49 | import tomli_w 50 | 51 | with open("pyproject.toml", "rb") as f: 52 | pyproject = tomli.load(f) 53 | 54 | pyproject["project"]["version"] = "${{ steps.vars.outputs.tag }}" 55 | 56 | with open("pyproject.toml", "wb") as f: 57 | tomli_w.dump(pyproject, f) 58 | - name: Build dashboard 59 | run: | 60 | pip install -e . 61 | dashboard/script/setup 62 | dashboard/script/build 63 | - name: Build python package 64 | run: >- 65 | python3 -m build 66 | - name: Publish release to PyPI 67 | uses: pypa/gh-action-pypi-publish@v1.12.4 68 | with: 69 | user: __token__ 70 | password: ${{ secrets.PYPI_TOKEN }} 71 | - name: Wait for PyPI 72 | run: sleep 300 73 | build-and-push-container-image: 74 | name: Builds and pushes the Matter Server container to ghcr.io 75 | runs-on: ubuntu-latest 76 | permissions: 77 | packages: write 78 | needs: build-and-publish-pypi 79 | steps: 80 | - uses: actions/checkout@v4.2.2 81 | - name: Log in to the GitHub container registry 82 | uses: docker/login-action@v3.4.0 83 | with: 84 | registry: ghcr.io 85 | username: ${{ github.repository_owner }} 86 | password: ${{ secrets.GITHUB_TOKEN }} 87 | - name: Set up Docker Buildx 88 | uses: docker/setup-buildx-action@v3.10.0 89 | - name: Version number for tags 90 | id: tags 91 | shell: bash 92 | run: |- 93 | patch=${GITHUB_REF#refs/*/} 94 | echo "patch=${patch}" >> $GITHUB_OUTPUT 95 | echo "minor=${patch%.*}" >> $GITHUB_OUTPUT 96 | echo "major=${patch%.*.*}" >> $GITHUB_OUTPUT 97 | - name: Build and Push release 98 | uses: docker/build-push-action@v6.18.0 99 | if: github.event.release.prerelease == false 100 | with: 101 | context: . 102 | platforms: linux/amd64,linux/arm64 103 | file: Dockerfile 104 | tags: |- 105 | ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.patch }}, 106 | ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.minor }}, 107 | ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.major }}, 108 | ghcr.io/${{ github.repository_owner }}/python-matter-server:stable 109 | push: true 110 | build-args: "PYTHON_MATTER_SERVER=${{ needs.build-and-publish-pypi.outputs.version }}" 111 | - name: Build and Push pre-release 112 | uses: docker/build-push-action@v6.18.0 113 | if: github.event.release.prerelease == true 114 | with: 115 | context: . 116 | platforms: linux/amd64,linux/arm64 117 | file: Dockerfile 118 | tags: |- 119 | ghcr.io/${{ github.repository_owner }}/python-matter-server:${{ steps.tags.outputs.patch }}, 120 | ghcr.io/${{ github.repository_owner }}/python-matter-server:beta 121 | push: true 122 | build-args: "PYTHON_MATTER_SERVER=${{ needs.build-and-publish-pypi.outputs.version }}" 123 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # This workflow will install Python dependencies, run tests and lint 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions 3 | 4 | name: Test 5 | 6 | on: 7 | push: 8 | branches: [main] 9 | pull_request: 10 | branches: [main] 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | continue-on-error: true 16 | 17 | steps: 18 | - name: Check out code from GitHub 19 | uses: actions/checkout@v4.2.2 20 | - name: Set up Python 21 | uses: actions/setup-python@v5.6.0 22 | with: 23 | python-version: "3.12" 24 | - name: Install dependencies 25 | run: | 26 | sudo apt-get update 27 | python -m pip install --upgrade pip 28 | pip install -e .[server] 29 | pip install -e .[test] 30 | - name: Lint/test with pre-commit 31 | run: SKIP=no-commit-to-branch pre-commit run --all-files 32 | 33 | test: 34 | runs-on: ubuntu-latest 35 | continue-on-error: true 36 | strategy: 37 | fail-fast: false 38 | matrix: 39 | python-version: 40 | - "3.12" 41 | - "3.13" 42 | 43 | steps: 44 | - name: Check out code from GitHub 45 | uses: actions/checkout@v4.2.2 46 | - name: Set up Python ${{ matrix.python-version }} 47 | uses: actions/setup-python@v5.6.0 48 | with: 49 | python-version: ${{ matrix.python-version }} 50 | - name: Install dependencies 51 | run: | 52 | sudo apt-get update 53 | sudo apt-get install -y libgirepository1.0-dev 54 | python -m pip install --upgrade pip 55 | pip install -e .[server] 56 | pip install -e .[test] 57 | - name: Pytest 58 | run: pytest --durations 10 --cov-report term-missing --cov=matter_server --cov-report=xml tests/ 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | .pybuilder/ 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # IPython 82 | profile_default/ 83 | ipython_config.py 84 | 85 | # pyenv 86 | # For a library or package, you might want to ignore these files since the code is 87 | # intended to run in multiple environments; otherwise, check them in: 88 | # .python-version 89 | 90 | # pipenv 91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 | # install all needed dependencies. 95 | #Pipfile.lock 96 | 97 | # poetry 98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 99 | # This is especially recommended for binary packages to ensure reproducibility, and is more 100 | # commonly ignored for libraries. 101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 102 | #poetry.lock 103 | 104 | # pdm 105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 106 | #pdm.lock 107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 108 | # in version control. 109 | # https://pdm.fming.dev/#use-with-ide 110 | .pdm.toml 111 | 112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 113 | __pypackages__/ 114 | 115 | # Celery stuff 116 | celerybeat-schedule 117 | celerybeat.pid 118 | 119 | # SageMath parsed files 120 | *.sage.py 121 | 122 | # Environments 123 | .env 124 | .venv 125 | env/ 126 | venv/ 127 | ENV/ 128 | env.bak/ 129 | venv.bak/ 130 | 131 | # Spyder project settings 132 | .spyderproject 133 | .spyproject 134 | 135 | # Rope project settings 136 | .ropeproject 137 | 138 | # mkdocs documentation 139 | /site 140 | 141 | # mypy 142 | .mypy_cache/ 143 | .dmypy.json 144 | dmypy.json 145 | 146 | # Pyre type checker 147 | .pyre/ 148 | 149 | # pytype static type analyzer 150 | .pytype/ 151 | 152 | # Cython debug symbols 153 | cython_debug/ 154 | 155 | # PyCharm 156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 158 | # and can be added to the global gitignore or merged into this file. For a more nuclear 159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 160 | #.idea/ 161 | 162 | # Visual Studio Code 163 | .vscode/* 164 | 165 | .DS_Store 166 | credentials/ 167 | venv39/ 168 | 169 | # ruff 170 | .ruff_cache/ 171 | 172 | # prebuilt dashboard files 173 | matter_server/dashboard/ 174 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | repos: 4 | - repo: local 5 | hooks: 6 | - id: ruff-check 7 | name: 🐶 Ruff Linter 8 | language: system 9 | types: [python] 10 | entry: scripts/run-in-env.sh ruff check --fix 11 | require_serial: true 12 | stages: [pre-commit, pre-push, manual] 13 | - id: ruff-format 14 | name: 🐶 Ruff Formatter 15 | language: system 16 | types: [python] 17 | entry: scripts/run-in-env.sh ruff format 18 | require_serial: true 19 | stages: [pre-commit, pre-push, manual] 20 | - id: check-ast 21 | name: 🐍 Check Python AST 22 | language: system 23 | types: [python] 24 | entry: scripts/run-in-env.sh check-ast 25 | - id: check-case-conflict 26 | name: 🔠 Check for case conflicts 27 | language: system 28 | entry: scripts/run-in-env.sh check-case-conflict 29 | - id: check-docstring-first 30 | name: ℹ️ Check docstring is first 31 | language: system 32 | types: [python] 33 | entry: scripts/run-in-env.sh check-docstring-first 34 | - id: check-executables-have-shebangs 35 | name: 🧐 Check that executables have shebangs 36 | language: system 37 | types: [text, executable] 38 | entry: scripts/run-in-env.sh check-executables-have-shebangs 39 | stages: [pre-commit, pre-push, manual] 40 | - id: check-json 41 | name: { Check JSON files 42 | language: system 43 | types: [json] 44 | entry: scripts/run-in-env.sh check-json 45 | - id: check-merge-conflict 46 | name: 💥 Check for merge conflicts 47 | language: system 48 | types: [text] 49 | entry: scripts/run-in-env.sh check-merge-conflict 50 | - id: check-symlinks 51 | name: 🔗 Check for broken symlinks 52 | language: system 53 | types: [symlink] 54 | entry: scripts/run-in-env.sh check-symlinks 55 | - id: check-toml 56 | name: ✅ Check TOML files 57 | language: system 58 | types: [toml] 59 | entry: scripts/run-in-env.sh check-toml 60 | - id: codespell 61 | name: ✅ Check code for common misspellings 62 | language: system 63 | types: [text] 64 | entry: scripts/run-in-env.sh codespell 65 | - id: detect-private-key 66 | name: 🕵️ Detect Private Keys 67 | language: system 68 | types: [text] 69 | entry: scripts/run-in-env.sh detect-private-key 70 | - id: end-of-file-fixer 71 | name: ⮐ Fix End of Files 72 | language: system 73 | types: [text] 74 | entry: scripts/run-in-env.sh end-of-file-fixer 75 | stages: [pre-commit, pre-push, manual] 76 | - id: no-commit-to-branch 77 | name: 🛑 Don't commit to main branch 78 | language: system 79 | entry: scripts/run-in-env.sh no-commit-to-branch 80 | pass_filenames: false 81 | always_run: true 82 | args: 83 | - --branch=main 84 | - id: pylint 85 | name: 🌟 Starring code with pylint 86 | language: system 87 | types: [python] 88 | entry: scripts/run-in-env.sh pylint matter_server/ tests/ 89 | require_serial: true 90 | pass_filenames: false 91 | - id: trailing-whitespace 92 | name: ✄ Trim Trailing Whitespace 93 | language: system 94 | types: [text] 95 | entry: scripts/run-in-env.sh trailing-whitespace-fixer 96 | stages: [pre-commit, pre-push, manual] 97 | - id: mypy 98 | name: mypy 99 | entry: scripts/run-in-env.sh mypy 100 | language: script 101 | types: [python] 102 | require_serial: true 103 | files: ^(matter_server|pylint)/.+\.py$ 104 | -------------------------------------------------------------------------------- /DEVELOPMENT.md: -------------------------------------------------------------------------------- 1 | # Setting up your development environment 2 | 3 | **For enabling Matter support within Home Assistant, please refer to the Home Assistant documentation. These instructions are for development only!** 4 | 5 | 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. 6 | 7 | - Download/clone the repo to your local machine. 8 | - Set-up the development environment: `scripts/setup.sh` 9 | - Create the `/data` directory if it does not exist with permissions for the user running the python-matter-server. 10 | 11 | ## Start Matter server 12 | 13 | You can check out the [example script](/scripts/example.py) in the scripts folder for generic directions to run the client and server. 14 | 15 | - To run the server in `info` log-level, you can run: `python -m matter_server.server` 16 | - To start the server in `debug` log-level, you can run: `python -m matter_server.server --log-level debug` 17 | - 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. 18 | 19 | Use `--help` to get a list of possible log levels and other command line arguments. 20 | 21 | 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). 22 | 23 | If you happen to get `OSError: [Errno 105] No buffer space available.`, increase the IPv4 group limits with: 24 | ``` 25 | echo "net.ipv4.igmp_max_memberships=1024" | sudo tee -a /etc/sysctl.d/local.conf 26 | sudo service procps force-reload 27 | ``` 28 | 29 | ## Python client library only 30 | 31 | There is also a Python client library hosted in this repository (used by Home Assistant), which consumes the Websockets API published from the server. 32 | 33 | 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 34 | 35 | To only install the client part: `pip install python-matter-server` 36 | 37 | ## Websocket commands 38 | 39 | [Websocket documentation](/docs/websockets_api.md) 40 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.12-slim-bookworm 2 | 3 | # Set shell 4 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] 5 | 6 | WORKDIR /app 7 | 8 | RUN \ 9 | set -x \ 10 | && apt-get update \ 11 | && apt-get install -y --no-install-recommends \ 12 | curl \ 13 | libuv1 \ 14 | zlib1g \ 15 | libjson-c5 \ 16 | libnl-3-200 \ 17 | libnl-route-3-200 \ 18 | unzip \ 19 | gdb \ 20 | iputils-ping \ 21 | iproute2 \ 22 | && apt-get purge -y --auto-remove \ 23 | && rm -rf \ 24 | /var/lib/apt/lists/* \ 25 | /usr/src/* 26 | 27 | ARG PYTHON_MATTER_SERVER 28 | 29 | ENV chip_example_url "https://github.com/home-assistant-libs/matter-linux-ota-provider/releases/download/2025.5.0" 30 | ARG TARGETPLATFORM 31 | 32 | RUN \ 33 | set -x \ 34 | && echo "${TARGETPLATFORM}" \ 35 | && if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \ 36 | curl -Lo /usr/local/bin/chip-ota-provider-app "${chip_example_url}/chip-ota-provider-app-x86-64"; \ 37 | elif [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \ 38 | curl -Lo /usr/local/bin/chip-ota-provider-app "${chip_example_url}/chip-ota-provider-app-aarch64"; \ 39 | else \ 40 | exit 1; \ 41 | fi \ 42 | && chmod +x /usr/local/bin/chip-ota-provider-app 43 | 44 | # hadolint ignore=DL3013 45 | RUN \ 46 | pip3 install --no-cache-dir "python-matter-server[server]==${PYTHON_MATTER_SERVER}" 47 | 48 | VOLUME ["/data"] 49 | EXPOSE 5580 50 | 51 | ENTRYPOINT [ "matter-server" ] 52 | CMD [ "--storage-path", "/data", "--paa-root-cert-dir", "/data/credentials" ] 53 | -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM python:3.11-slim-bullseye 2 | 3 | # Set shell 4 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] 5 | 6 | RUN \ 7 | set -x \ 8 | && apt-get update \ 9 | && apt-get install -y --no-install-recommends \ 10 | libuv1 \ 11 | zlib1g \ 12 | libjson-c5 \ 13 | libnl-3-200 \ 14 | libnl-route-3-200 \ 15 | unzip \ 16 | libcairo2 \ 17 | gdb \ 18 | curl 19 | 20 | RUN \ 21 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ 22 | && export NVM_DIR="$HOME/.nvm" \ 23 | && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \ 24 | && nvm install 18 25 | 26 | RUN \ 27 | apt-get purge -y --auto-remove \ 28 | && rm -rf \ 29 | /var/lib/apt/lists/* \ 30 | /usr/src/* 31 | 32 | WORKDIR /app 33 | COPY . ./ 34 | 35 | WORKDIR /app/dashboard/script 36 | RUN ./setup 37 | RUN ./build 38 | 39 | WORKDIR /app 40 | 41 | # hadolint ignore=DL3013 42 | RUN \ 43 | pip3 install -U pip && \ 44 | pip3 install --no-cache-dir .[server] 45 | 46 | VOLUME ["/data"] 47 | EXPOSE 5580 48 | ENTRYPOINT ["./docker-entrypoint.sh"] 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Home Foundation Matter Server 2 | 3 |  4 | 5 | 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. 6 | 7 | This project implements a Matter Controller Server over WebSockets using the 8 | [official Matter (formerly CHIP) SDK](https://github.com/project-chip/connectedhomeip) 9 | as a base and provides both a server and client implementation. 10 | 11 | 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/). 12 | 13 | ## Support 14 | 15 | For developers, making use of this component or contributing to it, use the issue tracker within this repository and/or reach out on discord. 16 | 17 | For users of Home Assistant, seek support in the official Home Assistant support channels. 18 | 19 | - The Home Assistant [Community Forum](https://community.home-assistant.io/). 20 | - The Home Assistant [Discord Chat Server](https://discord.gg/c5DvZ4e). 21 | - Join [the Reddit subreddit in /r/homeassistant](https://reddit.com/r/homeassistant). 22 | 23 | - If you experience issues using Matter with Home Assistant, please open an issue 24 | report in the [Home Assistant Core repository](https://github.com/home-assistant/core/issues/new/choose). 25 | 26 | Please do not create Home Assistant enduser support issues in the issue tracker of this repository. 27 | 28 | ## Development 29 | 30 | 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. 31 | 32 | [Development documentation](DEVELOPMENT.md) 33 | 34 | ## Installation / Running the Matter Server 35 | 36 | - 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. 37 | 38 | - For running the server and/or client in your development environment, see the [Development documentation](DEVELOPMENT.md). 39 | 40 | - For running the Matter Server as a standalone docker container, see our instructions [here](docs/docker.md). 41 | 42 | > [!NOTE] 43 | > 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. 44 | -------------------------------------------------------------------------------- /dashboard/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /dashboard/README.md: -------------------------------------------------------------------------------- 1 | # Matter Dashboard 2 | 3 | This is the dashboard for the Python Matter Server project. It is meant to be used for debugging and testing. 4 | 5 | ## Development 6 | 7 | Install the dependencies: 8 | 9 | ```bash 10 | script/setup 11 | ``` 12 | 13 | NOTE: The python matter server (dependencies) also need to be present in order for the setup to succeed. 14 | 15 | Run the development server: 16 | 17 | ```bash 18 | script/develop 19 | ``` 20 | 21 | 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. 22 | 23 | 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`. 24 | 25 | 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. 26 | 27 | ## Production build 28 | 29 | The production build is generated when you run 30 | 31 | ```bash 32 | script/build 33 | ``` 34 | 35 | The production build is generated into the matter_server folder, to be picked up by 36 | the webserver of the python matter server. 37 | -------------------------------------------------------------------------------- /dashboard/note.md: -------------------------------------------------------------------------------- 1 | ``` 2 |