🎉 Initial add-on code

This commit is contained in:
Franck Nijhof 2017-12-25 11:17:18 +01:00
parent fd58ae5dba
commit 4aed54ed1f
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
10 changed files with 155 additions and 0 deletions

44
airsonos/Dockerfile Executable file
View file

@ -0,0 +1,44 @@
ARG BUILD_FROM=hassioaddons/debian-base-amd64:0.2.0
FROM ${BUILD_FROM}
# Setup base system
RUN \
echo 'deb http://deb.debian.org/debian jessie main' >> /etc/apt/sources.list \
\
&& apt-get update \
\
&& apt-get install -y --no-install-recommends libssl1.0.0 \
\
&& rm -f -r \
/tmp/* \
/var/lib/apt/lists/*
# Copy root filesystem
COPY rootfs /
# Add airsonos binary
ARG BUILD_ARCH
ADD bin/airsonos-${BUILD_ARCH} /usr/bin/airsonos
# Build arugments
ARG BUILD_DATE
ARG BUILD_REF
ARG BUILD_VERSION
# Labels
LABEL \
io.hass.name="AirSonos" \
io.hass.description="AirPlay capabilities for your Sonos (and UPnP) devices" \
io.hass.arch="${BUILD_ARCH}" \
io.hass.type="addon" \
io.hass.version=${BUILD_VERSION} \
maintainer="Franck Nijhof <frenck@addons.community>" \
org.label-schema.description="AirPlay capabilities for your Sonos (and UPnP) devices" \
org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="AirSonos" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://community.home-assistant.io/t/community-hass-io-add-on-airsonos/36796?u=frenck" \
org.label-schema.usage="https://github.com/hassio-addons/addon-airsonos/tree/master/README.md" \
org.label-schema.vcs-ref=${BUILD_REF} \
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-airsonos" \
org.label-schema.vendor="Community Hass.io Add-ons"

BIN
airsonos/bin/airsonos-aarch64 Executable file

Binary file not shown.

BIN
airsonos/bin/airsonos-amd64 Executable file

Binary file not shown.

BIN
airsonos/bin/airsonos-armhf Executable file

Binary file not shown.

BIN
airsonos/bin/airsonos-i386 Executable file

Binary file not shown.

9
airsonos/build.json Normal file
View file

@ -0,0 +1,9 @@
{
"build_from": {
"aarch64": "hassioaddons/debian-base-aarch64:0.2.0",
"amd64": "hassioaddons/debian-base-amd64:0.2.0",
"armhf": "hassioaddons/debian-base-armhf:0.2.0",
"i386": "hassioaddons/debian-base-i386:0.2.0"
},
"args": {}
}

31
airsonos/config.json Executable file
View file

@ -0,0 +1,31 @@
{
"name": "AirSonos",
"version": "dev",
"slug": "airsonos",
"description": "AirPlay capabilities for your Sonos (and UPnP) devices.",
"url": "https://community.home-assistant.io/t/community-hass-io-add-on-airsonos/36796?u=frenck",
"startup": "services",
"boot": "auto",
"hassio_api": true,
"homeassistant_api": false,
"host_network": true,
"options": {
"log_level": "info",
"address": "",
"port": 49152,
"latency_rtp": 1000,
"latency_http": 2000,
"drift": false
},
"schema": {
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)",
"address": "str",
"port": "port",
"latency_rtp": "int",
"latency_http": "int",
"drift": "bool"
},
"environment": {
"LOG_FORMAT": "{LEVEL}: {MESSAGE}"
}
}

View file

@ -0,0 +1,16 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# 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
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!'
fi

View file

@ -0,0 +1,9 @@
#!/usr/bin/execlineb -S0
# ==============================================================================
# Community Hass.io Add-ons: AirSonos
# Take down the S6 supervision tree when the AirSonos server fails
# ==============================================================================
if -n { s6-test $# -ne 0 }
if -n { s6-test ${1} -eq 256 }
s6-svscanctl -t /var/run/s6/services

View file

@ -0,0 +1,46 @@
#!/usr/bin/with-contenv bash
# ==============================================================================
# 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'
# Bind to a specific interface
if hass.config.has_value 'address'; then
options+=(-b "$(hass.config.get 'address'):$(hass.config.get '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
# Set latency
options+=(-l "$(hass.config.get 'latency_rtp'):$(hass.config.get 'latency_http')")
# Drift mode?
if hass.config.true 'drift'; then
options+=(-r)
fi
# Run the AirSonos server
exec airsonos "${options[@]}"