home-assistant-libs / python-matter-server

Python server to interact with Matter
Apache License 2.0
463 stars 72 forks source link

Running Matter Server in docker #308

Closed marcelveldt closed 1 year ago

marcelveldt commented 1 year ago

Currently the only way to run the Matter Server provided in this repo for production is by running HAOS and the add-on provided by the Home Assistant team. We do NOT provide any (official) support for running the server yourself in docker or any other ways. If you do not want to run HAOS on a baremetal box, you could consider running it in a VM.

Matter (especially in combination with Thread devices) is complex on its own and at this point relies on kernel patches, specific network configuration etc. of the host. It will NOT run out of the box by spinning up a container, it requires more work. We adjusted HAOS with all the patches needed for a smooth experience (and we keep doing that, all day). Hence it is our recommended path to setup Matter.

That said, we do recognize that power users like to have more control and have no problem in configuring these dependencies on their own. That is why we will provide a Docker image soon including instructions for the configuration and requirements to the host OS. Just give us a few weeks to prepare all that.

Thanks for understanding!

dcplaya commented 1 year ago

Commit d4c1621ba923462a5c8e93f1be65cbff2b6b9f5f fixes the Dockerfile but that change isn't in the tagged branch for 3.5.0.

I only noticed it because I have a action that builds the container based on the tagged version.

thdxr commented 1 year ago

looking forward to this thank you!

wwwescape commented 1 year ago

Thanks for the update. Hopefully the Docker image will support Raspberry Pi 4 architectures as well. :+1:

marcelveldt commented 1 year ago

Thanks for the update. Hopefully the Docker image will support Raspberry Pi 4 architectures as well. 👍

Yes, but 64 bits only

marcelveldt commented 1 year ago

An official docker image is now available for both aarch64 and amd64 platforms (other architectures will not be available)! Also the readme has been updated to guide you through all requirements to the host machine/OS if you want to run the docker version of the Matter Server.

Do note that if you may run into issues with (mdns) discovery/availability of devices we may ask you to also test it with a Home Assistant OS installation to rule our host specific configuration.

wwwescape commented 1 year ago

Just gave this a try.

pi@raspberrypi:~/Docker/Python Matter Server $ uname -m
aarch64
pi@raspberrypi:~/Docker/Python Matter Server $ docker-compose up -d
Pulling home-assistant-libs (ghcr.io/home-assistant-libs/python-matter-server:stable)...
stable: Pulling from home-assistant-libs/python-matter-server
ERROR: no matching manifest for linux/arm/v8 in the manifest list entries

Am I doing something wrong?

ljmerza commented 1 year ago

Just gave this a try.

pi@raspberrypi:~/Docker/Python Matter Server $ uname -m
aarch64
pi@raspberrypi:~/Docker/Python Matter Server $ docker-compose up -d
Pulling home-assistant-libs (ghcr.io/home-assistant-libs/python-matter-server:stable)...
stable: Pulling from home-assistant-libs/python-matter-server
ERROR: no matching manifest for linux/arm/v8 in the manifest list entries

Am I doing something wrong?

Armv8 isn't supported. You'll have to install v7 64 bit

kan84 commented 1 year ago
matter-server    | [1687540935.014643][1:1] CHIP:DL: Found the primary Ethernet interface:eno1
matter-server    | [1687540935.015531][1:1] CHIP:DL: Failed to get WiFi interface
matter-server    | [1687540935.015536][1:1] CHIP:DL: Failed to reset WiFi statistic counts
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] WARNING Initializing persistent storage from file: /data/chip.json
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] WARNING Loading configuration from /data/chip.json...
matter-server    | 2023-06-23 17:22:15 DropServer chip.TS[1] INFO Last Known Good Time: 2023-06-02T10:24:24
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] INFO SetSdkKey: g/gcc = b'\x18y\x00\x00'
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] INFO Committing...
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] INFO SetSdkKey: g/gdc = b'\x18y\x00\x00'
matter-server    | 2023-06-23 17:22:15 DropServer PersistentStorage[1] INFO Committing...
matter-server    | 2023-06-23 17:22:15 DropServer chip.ZCL[1] INFO Using ZAP configuration...
matter-server    | Traceback (most recent call last):
matter-server    |   File "/usr/local/bin/matter-server", line 8, in <module>
matter-server    |     sys.exit(main())
matter-server    |              ^^^^^^
matter-server    |   File "/usr/local/lib/python3.11/site-packages/matter_server/server/__main__.py", line 79, in main
matter-server    |     server = MatterServer(
matter-server    |              ^^^^^^^^^^^^^
matter-server    |   File "/usr/local/lib/python3.11/site-packages/matter_server/server/server.py", line 74, in __init__
matter-server    |     self.stack = MatterStack(self)
matter-server    |                  ^^^^^^^^^^^^^^^^^
matter-server    |   File "/usr/local/lib/python3.11/site-packages/matter_server/server/stack.py", line 32, in __init__
matter-server    |     self._chip_stack = ChipStack(
matter-server    |                        ^^^^^^^^^^
matter-server    |   File "/usr/local/lib/python3.11/site-packages/chip/ChipStack.py", line 64, in wrapper
matter-server    |     instance[0] = cls(*args, **kwargs)
matter-server    |                   ^^^^^^^^^^^^^^^^^^^^
matter-server    |   File "/usr/local/lib/python3.11/site-packages/chip/ChipStack.py", line 270, in __init__
matter-server    |     res.raise_on_error()
matter-server    |   File "/usr/local/lib/python3.11/site-packages/chip/native/__init__.py", line 67, in raise_on_error
matter-server    |     raise self.to_exception()
matter-server    | chip.exceptions.ChipStackError: src/system/SystemLayerImplSelect.cpp:268: CHIP Error 0x000000C1: Endpoint pool full

I am running this on x64 debian using docker-compose. Does the matter server require wifi connection or will it work over lan? Also I remembered that this PC does not have Bluetooth either. Could I use it as a matter server for devices over network connection and not for thread or adding new devices.

digiblur commented 1 year ago

@kan84 it usually gives another error about the adapter from what I've seen

amrutprabhu commented 1 year ago

I was able to run the matter server with docker compose on my raspberry pi and was able to connect it to Home Assistant. 🎉

version: '3'
services:
  matter-server:
    container_name: matter-server
    image: ghcr.io/home-assistant-libs/python-matter-server:stable
    restart: unless-stopped
    security_opt:
      - apparmor=unconfined
    volumes:
      - ./data:/data
      - /run/dbus:/run/dbus:ro
    network_mode: host
kan84 commented 1 year ago

run the matter server with docker compose

What port did you use in home assistant to connect to matter addon?

amrutprabhu commented 1 year ago

run the matter server with docker compose

What port did you use in home assistant to connect to matter addon?

I used this url ws://localhost:5580/wsto connect home assistant to the matter server

alex-cardenas commented 1 year ago

I, too, was easily able to run this docker container in Unraid and connect it to Home-Assistant-Core container. I used the default settings, nothing changed. I tested it with one Meross Matter smart plug and it was quite fast and simple. Thanks!

wwwescape commented 1 year ago

Just gave this a try.

pi@raspberrypi:~/Docker/Python Matter Server $ uname -m
aarch64
pi@raspberrypi:~/Docker/Python Matter Server $ docker-compose up -d
Pulling home-assistant-libs (ghcr.io/home-assistant-libs/python-matter-server:stable)...
stable: Pulling from home-assistant-libs/python-matter-server
ERROR: no matching manifest for linux/arm/v8 in the manifest list entries

Am I doing something wrong?

Armv8 isn't supported. You'll have to install v7 64 bit

Got it working after installing the 64-bit version of the OS on my Raspberry Pi 4.

marcelveldt commented 1 year ago

Locked this conversation. If you experience issues, please create an issue report but do realize that we will point you at the readme with all requirements to your host OS. For example availability issues or "endpoint full" are caused by the host/network configuration.

Thanks!