mirror of
https://github.com/hassio-addons/addon-airsonos.git
synced 2025-05-05 11:31:24 +00:00
🔨 Rewrite add-on onto Bashio
This commit is contained in:
parent
787a24b422
commit
a788dafffb
2 changed files with 29 additions and 33 deletions
|
@ -1,21 +1,18 @@
|
||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: AirSonos
|
# Community Hass.io Add-ons: AirSonos
|
||||||
# Checks latency settings before starting the AirSonos server
|
# Checks latency settings before starting the AirSonos server
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
declare latency
|
declare latency
|
||||||
|
|
||||||
# Create a configuration file, if it does not exist yet
|
# Create a configuration file, if it does not exist yet
|
||||||
if ! hass.file_exists '/config/airsonos.xml'; then
|
if ! bashio::fs.file_exists '/config/airsonos.xml'; then
|
||||||
cp /etc/airsonos.xml /config/airsonos.xml
|
cp /etc/airsonos.xml /config/airsonos.xml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Warn if latency is below 500ms
|
# Warn if latency is below 500ms
|
||||||
latency=$(hass.config.get 'latency_rtp')
|
latency=$(bashio::config 'latency_rtp')
|
||||||
if [[ "${latency}" -lt 500 && "${latency}" -ne 0 ]]; then
|
if [[ "${latency}" -lt 500 && "${latency}" -ne 0 ]]; then
|
||||||
hass.log.warning \
|
bashio::log.warning \
|
||||||
'Setting the RTP latency of AirPlay audio below 500ms is not recommended!'
|
'Setting the RTP latency of AirPlay audio below 500ms is not recommended!'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: AirSonos
|
# Community Hass.io Add-ons: AirSonos
|
||||||
# Runs the AirSonos server
|
# Runs the AirSonos server
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# shellcheck disable=SC1091
|
|
||||||
source /usr/lib/hassio-addons/base.sh
|
|
||||||
|
|
||||||
declare -a options
|
declare -a options
|
||||||
|
|
||||||
hass.log.info 'Starting the AirSonos server'
|
bashio::log.info 'Starting the AirSonos server...'
|
||||||
|
|
||||||
# Non-interactive
|
# Non-interactive
|
||||||
options+=(-Z)
|
options+=(-Z)
|
||||||
|
@ -20,12 +17,13 @@ options+=(-x '/config/airsonos.xml')
|
||||||
options+=(-I)
|
options+=(-I)
|
||||||
|
|
||||||
# Bind to a specific interface
|
# Bind to a specific interface
|
||||||
if hass.config.has_value 'address'; then
|
if bashio::config.has_value 'address'; then
|
||||||
options+=(-b "$(hass.config.get 'address'):$(hass.config.get 'port')")
|
options+=(-b "$(bashio::config 'address'):$(bashio::config 'port')")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the matching AirSonos log level
|
# Find the matching AirSonos log level
|
||||||
case "$(hass.string.lower "$(hass.config.get 'log_level')")" in
|
if bashio::config.exists 'log_level'; then
|
||||||
|
case "$(bashio::string.lower "$(bashio::config 'log_level')")" in
|
||||||
all|trace)
|
all|trace)
|
||||||
options+=(-d 'all=sdebug')
|
options+=(-d 'all=sdebug')
|
||||||
;;
|
;;
|
||||||
|
@ -42,12 +40,13 @@ case "$(hass.string.lower "$(hass.config.get 'log_level')")" in
|
||||||
options+=(-d 'all=error')
|
options+=(-d 'all=error')
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# Set latency
|
# Set latency
|
||||||
options+=(-l "$(hass.config.get 'latency_rtp'):$(hass.config.get 'latency_http')")
|
options+=(-l "$(bashio::config 'latency_rtp'):$(bashio::config 'latency_http')")
|
||||||
|
|
||||||
# Drift mode?
|
# Drift mode?
|
||||||
if hass.config.true 'drift'; then
|
if bashio::config.true 'drift'; then
|
||||||
options+=(-r)
|
options+=(-r)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue