Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions matter_server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 25 additions & 10 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 @@ -122,18 +122,33 @@ 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)
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

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
Expand Down
3 changes: 3 additions & 0 deletions matter_server/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.