Adds support for tweaking AirSonos using its configuration file

This commit is contained in:
Franck Nijhof 2018-07-22 19:25:03 +02:00
parent f22416b468
commit e1a7ac068d
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
4 changed files with 29 additions and 1 deletions

View file

@ -15,6 +15,9 @@
"hassio_api": true,
"homeassistant_api": false,
"host_network": true,
"map": [
"config:rw"
],
"options": {
"log_level": "info",
"address": "",

View file

@ -0,0 +1,14 @@
<?xml version="1.0"?>
<aircast>
<common>
<enabled>1</enabled>
<stop_receiver>0</stop_receiver>
<latency></latency>
<codec>pcm</codec>
<artwork></artwork>
</common>
<main_log>info</main_log>
<cast_log>info</cast_log>
<util_log>warn</util_log>
<log_limit>-1</log_limit>
</aircast>

View file

@ -8,8 +8,13 @@ source /usr/lib/hassio-addons/base.sh
declare latency
latency=$(hass.config.get 'latency_rtp')
# Create a configuration file, if it does not exist yet
if ! hass.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')
if [[ "${latency}" -lt 500 && "${latency}" -ne 0 ]]; then
hass.log.warning \
'Setting the RTP latency of AirPlay audio below 500ms is not recommended!'

View file

@ -13,6 +13,12 @@ hass.log.info 'Starting the AirSonos server'
# Non-interactive
options+=(-Z)
# Configuration file
options+=(-x '/config/airsonos.xml')
# Update configuration file when new devices where detected
options+=(-I)
# Bind to a specific interface
if hass.config.has_value 'address'; then
options+=(-b "$(hass.config.get 'address'):$(hass.config.get 'port')")