Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

Python server to interact with Matter

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

Python Matter Server

This project implements a Matter (formerly Home Assistant Connected Home over IP or CHIP) Controller Server using WebSockets.

⚠️ This is under development and in very early stage!

Usage

To use the Matter Server using the Supervisor add-on is the recommended path (tbd).

Development

The Home Assistant Matter Server uses the Python CHIP Controller part of the open source Matter/Project CHIP repository. The project offers a IPython based REPL for testing/exploring. The REPL is also available as Python CHIP Controller REPL Add-on.

Run from the source tree

The Server needs to be run in a Python environment where the Python CHIP Controller is installed. E.g.

source ../connectedhomeip/out/python_env/bin/activate

Also make sure that the default storage location is present:

mkdir $HOME/.chip-storage/

With the following command the server can be run directly from the source tree.

python3 -m matter_server.server

On MacOs you will have to run above command with 'sudo' as it requires to interact with BLE.

The client does not need to be run in the Python CHIP Controller environment. It can be run from the source tree using:

python3 -m matter_server.client

Build and install

To build the Python CHIP Controller follow the building instructions available at docs/guides/python_chip_controller_building.md. Once you have a working Python CHIP Controller Python environment, switch to this repository and install this project as follows:

pip install .

Creating a test device

Instruction on how to create a test device can be found here.

Commissioning a test device

Currently the easiest way to set up a test device is using the Python CHIP REPL. Start it by pointing it at the same storage location as the servier will run off:

chip-repl --storagepath=$HOME/.chip-storage/python-kv.json

On MacOs you will have to run above command with 'sudo' as it requires to interact with BLE.

Inside the Python REPL, configure your Wi-Fi credentials:

devCtrl.SetWiFiCredentials("SSID", "PW")

Once done, paste the following code to commission the device:

from chip.setup_payload import SetupPayload
setupPayload = SetupPayload().ParseQrCode("MT:Y.K9042C00KA0648G00")
import ctypes
longDiscriminator = ctypes.c_uint16(int(setupPayload.attributes['Discriminator']))
pincode = ctypes.c_uint32(int(setupPayload.attributes['SetUpPINCode']))

devCtrl.ConnectBLE(longDiscriminator, pincode, 4335)

If you have installed the lighting app, send the following command to test if it works:

await devCtrl.SendCommand(4335, 1, Clusters.OnOff.Commands.Toggle())

Installing custom component in Home Assistant

Inside your Home Assistant development environment.

pip3 install -e ../python-matter-server
cd config
mkdir custom_components
cd custom_components
ln -sf ../../../python-matter-server/custom_components/matter_experimental .

You can now add the custom component via the UI. It's called Matter (experimental):

Open your Home Assistant instance and start setting up a new integration.

About

Python server to interact with Matter

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages