Skip to content

Commit

Permalink
matter_server: Add optional settings for development and testing (#3744)
Browse files Browse the repository at this point in the history
* matter_server: Add support for extra Matter Server arguments

This adds an optional configuration to pass additional command line
arguments to the Matter Server. This is useful for not commonly used
settings (e.g. for testing and debugging) which we don't want to expose
as actual add-on configuration.

* matter_server: Allow to set a custom version to be installed

Add an option to install a custom Matter Server and Matter SDK (CHIP
wheels) version. This is an extension to the existing beta flag, but
instead of simply allowing the latest version, a version can be
specified. This can be helpful for development and testing.

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

---------

Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
agners and MartinHjelmare authored Sep 2, 2024
1 parent cca82be commit 5b8fa76
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
5 changes: 5 additions & 0 deletions matter_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.4.2

- Add support for custom Matter Server arguments
- Add support to install custom Matter Server and Matter SDK (CHIP) versions

## 6.4.1

- Bump Python Matter Server to [6.4.0](https://github.com/home-assistant-libs/python-matter-server/releases/tag/6.4.0)
Expand Down
6 changes: 5 additions & 1 deletion matter_server/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
version: 6.4.1
version: 6.4.2
slug: matter_server
name: Matter Server
description: Matter WebSocket Server for Home Assistant Matter support.
Expand Down Expand Up @@ -34,6 +34,10 @@ schema:
beta: bool?
enable_test_net_dcl: bool?
bluetooth_adapter_id: int?
matter_server_args:
- str?
matter_server_version: str?
matter_sdk_wheels_version: str?
ports:
5580/tcp: null
stage: stable
Expand Down
24 changes: 21 additions & 3 deletions matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ declare server_port
declare log_level
declare log_level_sdk
declare primary_interface
declare matter_server_version
declare chip_version
matter_server_args=()
extra_args=()

Expand All @@ -19,9 +21,21 @@ log_level=$(bashio::string.lower "$(bashio::config log_level info)")
# Make Matter SDK log level currently default to error
log_level_sdk=$(bashio::string.lower "$(bashio::config log_level_sdk error)")

if bashio::config.true "beta"; then
bashio::log.info 'Upgrading Python Matter Server to latest pre-release'
pip3 install --upgrade --pre python-matter-server[server]
if bashio::config.has_value "matter_server_version"; then
matter_server_version=$(bashio::config 'matter_server_version')
bashio::log.info "Installing Python Matter Server ${matter_server_version}"
pip3 install --pre python-matter-server[server]=="${matter_server_version}"
elif bashio::config.true "beta"; then
bashio::log.info 'Upgrading Python Matter Server to latest pre-release'
pip3 install --upgrade --pre python-matter-server[server]
fi

if bashio::config.has_value "matter_sdk_wheels_version"; then
chip_version=$(bashio::config 'matter_sdk_wheels_version')
bashio::log.info "Installing Matter SDK ${chip_version}"
pip3 install --pre --no-dependencies \
home-assistant-chip-clusters=="${chip_version}" \
home-assistant-chip-core=="${chip_version}"
fi

# Bind to internal hassio network only unless user requests to expose
Expand Down Expand Up @@ -51,6 +65,10 @@ if bashio::config.has_value "bluetooth_adapter_id"; then
extra_args+=('--bluetooth-adapter' $(bashio::config 'bluetooth_adapter_id'))
fi

if bashio::config.has_value "matter_server_args"; then
extra_args+=($(bashio::config 'matter_server_args'))
fi

bashio::log.info "Using '${primary_interface}' as primary network interface."

# Send out discovery information to Home Assistant
Expand Down
18 changes: 18 additions & 0 deletions matter_server/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,23 @@ configuration:
Home Assistant Companion app commissioning method is recommended as it is
better tested and allows to commission directly in proximity of the device
itself.
matter_server_args:
name: Extra Matter Server arguments
description: >-
This allows to pass additional command line arguments to the Python Matter
Server. Use `--help` to get a list of possible arguments. Note that
arguments are also added by the startup script controlled by other add-on
options.
matter_server_version:
name: Matter Server version
description: >-
Install custom Matter Server version. WARNING: An older version might have
an incompatible storage format! Use this feature with caution! Make sure
you have a recent backup of the add-on!
matter_sdk_wheels_version:
name: Matter SDK wheels version
description: >-
Install custom Matter SDK wheels version. NOTE: The API might not be
compatible with the Python Matter server.
network:
5580/tcp: Matter Server WebSocket server port.

0 comments on commit 5b8fa76

Please sign in to comment.