From 9aaa7d166e981670c4e0a2a53d6bdb7d1dd81fcd Mon Sep 17 00:00:00 2001 From: Thilo Frommeyer Date: Sat, 23 May 2026 08:55:03 +0200 Subject: [PATCH 1/4] feat(matter_server): allow configuring custom primary network interface --- matter_server/config.yaml | 1 + matter_server/translations/en.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/matter_server/config.yaml b/matter_server/config.yaml index a1f56d00d..739a42b01 100644 --- a/matter_server/config.yaml +++ b/matter_server/config.yaml @@ -35,6 +35,7 @@ schema: enable_test_net_dcl: bool? ble_proxy: bool? bluetooth_adapter_id: int? + matter_server_primary_interface: str? matter_server_args: - str? matter_server_env_vars: diff --git a/matter_server/translations/en.yaml b/matter_server/translations/en.yaml index 5becc2567..35cfd140e 100644 --- a/matter_server/translations/en.yaml +++ b/matter_server/translations/en.yaml @@ -65,5 +65,8 @@ configuration: Install custom Python Matter SDK wheels version (not applicable when using Beta flag). NOTE: The API might not be compatible with the Python Matter server. + matter_server_primary_interface: + name: "Primary Network Interface" + description: "Manually specify the primary network interface for the Matter Server (e.g., enp0s19). Leave empty to use the system default." network: 5580/tcp: Matter Server WebSocket server port. From 7b6de4012fa1b08f57df15f4dc096606e612afa4 Mon Sep 17 00:00:00 2001 From: Thilo Frommeyer Date: Sun, 24 May 2026 08:08:30 +0200 Subject: [PATCH 2/4] fix(matter_server): include runtime script logic for custom interface --- .../etc/s6-overlay/s6-rc.d/matter-server/run | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run index 540a0e81a..a6c8a26fe 100755 --- a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run +++ b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run @@ -122,18 +122,35 @@ if bashio::config.true "enable_test_net_dcl"; then extra_args+=('--enable-test-net-dcl') fi -primary_interface="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" - -# Try fallback method (e.g. in case NetworkManager is not available) -# shellcheck disable=SC2086 -if [ -z ${primary_interface} ]; then - bashio::log.warning 'Trying fallback method to determine primary interface' - primary_interface="$(ip --json route show default | jq --raw-output '.[0].dev')" +# Check if the user configured a custom primary interface +if bashio::config.has_value 'matter_server_primary_interface'; then + custom_interface=$(bashio::config 'matter_server_primary_interface') + + # Check if the configured interface actually exists in the system + if ip link show "$custom_interface" > /dev/null 2>&1; then + bashio::log.info "Using manually configured network interface: ${custom_interface}" + primary_interface="$custom_interface" + else + bashio::log.error "The configured network interface '${custom_interface}' was not found on the host!" + bashio::log.warning "Falling back to automatic interface detection." + fi fi -# shellcheck disable=SC2086 -if [ -z ${primary_interface} ] || [ ${primary_interface} == "null" ]; then - bashio::exit.nok "No primary network interface found!" +# Run automatic detection if no custom interface was set or if the custom one failed +if [ -z "${primary_interface}" ]; then + primary_interface="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" + + # Try fallback method (e.g. in case NetworkManager is not available) + # shellcheck disable=SC2086 + if [ -z ${primary_interface} ]; then + bashio::log.warning 'Trying fallback method to determine primary interface' + primary_interface="$(ip --json route show default | jq --raw-output '.[0].dev')" + fi + + # shellcheck disable=SC2086 + if [ -z ${primary_interface} ] || [ ${primary_interface} == "null" ]; then + bashio::exit.nok "No primary network interface found!" + fi fi if bashio::config.true "ble_proxy"; then From ec71a617244f25f9065016d2a1376b3db6517c44 Mon Sep 17 00:00:00 2001 From: Thilo Frommeyer Date: Sun, 24 May 2026 08:31:56 +0200 Subject: [PATCH 3/4] style(matter_server): quote variables and remove unnecessary shellcheck disables --- .../rootfs/etc/s6-overlay/s6-rc.d/matter-server/run | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run index a6c8a26fe..03677d160 100755 --- a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run +++ b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run @@ -141,14 +141,12 @@ if [ -z "${primary_interface}" ]; then primary_interface="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" # Try fallback method (e.g. in case NetworkManager is not available) - # shellcheck disable=SC2086 - if [ -z ${primary_interface} ]; then + if [ -z "${primary_interface}" ]; then bashio::log.warning 'Trying fallback method to determine primary interface' primary_interface="$(ip --json route show default | jq --raw-output '.[0].dev')" fi - # shellcheck disable=SC2086 - if [ -z ${primary_interface} ] || [ ${primary_interface} == "null" ]; then + if [ -z "${primary_interface}" ] || [ "${primary_interface}" == "null" ]; then bashio::exit.nok "No primary network interface found!" fi fi From 059982878ad1401f410413d4bf8a3b7d4162ed54 Mon Sep 17 00:00:00 2001 From: Thilo Date: Sun, 24 May 2026 08:43:40 +0200 Subject: [PATCH 4/4] Update matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run index 03677d160..f3feda28c 100755 --- a/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run +++ b/matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run @@ -141,7 +141,7 @@ if [ -z "${primary_interface}" ]; then primary_interface="$(bashio::api.supervisor 'GET' '/network/info' '' 'first(.interfaces[] | select (.primary == true)) .interface')" # Try fallback method (e.g. in case NetworkManager is not available) - if [ -z "${primary_interface}" ]; then + if [ -z "${primary_interface}" ] || [ "${primary_interface}" = "null" ]; then bashio::log.warning 'Trying fallback method to determine primary interface' primary_interface="$(ip --json route show default | jq --raw-output '.[0].dev')" fi