mirror of
https://github.com/hassio-addons/addon-airsonos.git
synced 2025-05-04 19:11:22 +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
|
||||
# Checks latency settings before starting the AirSonos server
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
declare latency
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
# 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
|
||||
hass.log.warning \
|
||||
bashio::log.warning \
|
||||
'Setting the RTP latency of AirPlay audio below 500ms is not recommended!'
|
||||
fi
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: AirSonos
|
||||
# Runs the AirSonos server
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
declare -a options
|
||||
|
||||
hass.log.info 'Starting the AirSonos server'
|
||||
bashio::log.info 'Starting the AirSonos server...'
|
||||
|
||||
# Non-interactive
|
||||
options+=(-Z)
|
||||
|
@ -20,34 +17,36 @@ options+=(-x '/config/airsonos.xml')
|
|||
options+=(-I)
|
||||
|
||||
# Bind to a specific interface
|
||||
if hass.config.has_value 'address'; then
|
||||
options+=(-b "$(hass.config.get 'address'):$(hass.config.get 'port')")
|
||||
if bashio::config.has_value 'address'; then
|
||||
options+=(-b "$(bashio::config 'address'):$(bashio::config 'port')")
|
||||
fi
|
||||
|
||||
# Find the matching AirSonos log level
|
||||
case "$(hass.string.lower "$(hass.config.get 'log_level')")" in
|
||||
all|trace)
|
||||
options+=(-d 'all=sdebug')
|
||||
;;
|
||||
debug)
|
||||
options+=(-d 'all=debug')
|
||||
;;
|
||||
info|notice)
|
||||
options+=(-d 'all=info')
|
||||
;;
|
||||
warning)
|
||||
options+=(-d 'all=warn')
|
||||
;;
|
||||
error|fatal|off)
|
||||
options+=(-d 'all=error')
|
||||
;;
|
||||
esac
|
||||
if bashio::config.exists 'log_level'; then
|
||||
case "$(bashio::string.lower "$(bashio::config 'log_level')")" in
|
||||
all|trace)
|
||||
options+=(-d 'all=sdebug')
|
||||
;;
|
||||
debug)
|
||||
options+=(-d 'all=debug')
|
||||
;;
|
||||
info|notice)
|
||||
options+=(-d 'all=info')
|
||||
;;
|
||||
warning)
|
||||
options+=(-d 'all=warn')
|
||||
;;
|
||||
error|fatal|off)
|
||||
options+=(-d 'all=error')
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# 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?
|
||||
if hass.config.true 'drift'; then
|
||||
if bashio::config.true 'drift'; then
|
||||
options+=(-r)
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue