* Added telldus-core daemon module Proof of concept to compile and install telldus-core as an addon. Needs more fixes to be able to communicate with python script in hassio docker. * Revert "Added telldus-core daemon module" This reverts commit 79c8e35b8379bed41bcf5e47923b2946525d2a2a. * Added telldus-core add-on, proof of concept Add-on will compile and install telldus-core as an add-on. Tested to work with hardware. Need more fixes in order for communication with homeassistant container to work. * Updated with tellstick.conf check after installation Secure that we have at least a basic tellstick.conf file. This will also allow user to migrate existing tellstick.conf file in to config without risking to have it overwritten. * Altered exec to use --nodaemon Using --nodaemon keeps the docker, daemon and add-on active, running just telldusd ends the docker unexpectedly. * Updated build method to match the one in hass.io docker Now using bjornes fork of telldus homeassistant-alpine as the source and thus sharing the same source as being used in the homeassistant docker. * Update Dockerfile * Compile telldus master branch rather than fork Instead of using forked static code, apply small fixes to enable compilation on alpine. * Removed search - replace of userid in tellstick.conf Moved in to dockerfile * Update run.sh * Update Dockerfile * Update config.json * Update Dockerfile * Rename telldus_core/Dockerfile to tellstick/Dockerfile * Rename telldus_core/run.sh to tellstick/run.sh * Rename telldus_core/config.json to tellstick/config.json * Update config.json * Update Dockerfile * Update Dockerfile * Update config.json * Update run.sh * Update run.sh * Update config.json * Update run.sh * fix lint * Update run.sh * Update run.sh * Update config.json * Update Dockerfile * Update Dockerfile * fix lint * Update Dockerfile * Update run.sh Altered some details for successful parsing of options into tellstick.conf. * Update run.sh * Update config.json * Update config.json Added example device to support the users getting started with configuration..
67 lines
2.2 KiB
Bash
67 lines
2.2 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
CONFIG_PATH=/data/options.json
|
|
DEVICES=$(jq --raw-output '.devices | length' $CONFIG_PATH)
|
|
|
|
echo "[Info] Initialize the tellstick configuration"
|
|
|
|
# User access
|
|
echo "user = \"root\"" > /etc/tellstick.conf
|
|
echo "group = \"plugdev\"" >> /etc/tellstick.conf
|
|
echo "ignoreControllerConfirmation = \"false\"" >> /etc/tellstick.conf
|
|
|
|
# devices
|
|
for (( i=0; i < "$DEVICES"; i++ )); do
|
|
DEV_ID=$(jq --raw-output ".devices[$i].id" $CONFIG_PATH)
|
|
DEV_NAME=$(jq --raw-output ".devices[$i].name" $CONFIG_PATH)
|
|
DEV_PROTO=$(jq --raw-output ".devices[$i].protocol" $CONFIG_PATH)
|
|
DEV_MODEL=$(jq --raw-output ".devices[$i].model // empty" $CONFIG_PATH)
|
|
ATTR_HOUSE=$(jq --raw-output ".devices[$i].house // empty" $CONFIG_PATH)
|
|
ATTR_CODE=$(jq --raw-output ".devices[$i].code // empty" $CONFIG_PATH)
|
|
ATTR_UNIT=$(jq --raw-output ".devices[$i].unit // empty" $CONFIG_PATH)
|
|
ATTR_FADE=$(jq --raw-output ".devices[$i].fade // empty" $CONFIG_PATH)
|
|
|
|
(
|
|
echo ""
|
|
echo "device {"
|
|
echo " id = $DEV_ID"
|
|
echo " name = \"$DEV_NAME\""
|
|
echo " protocol = \"$DEV_PROTO\""
|
|
|
|
if [ ! -z "$DEV_MODEL" ]; then
|
|
echo " model = \"$DEV_MODEL\""
|
|
fi
|
|
|
|
if [ ! -z "$ATTR_HOUSE" ] || [ ! -z "$ATTR_CODE" ] || [ ! -z "$ATTR_UNIT" ] || [ ! -z "$ATTR_FADE" ]; then
|
|
echo " parameters {"
|
|
|
|
if [ ! -z "$ATTR_HOUSE" ]; then
|
|
echo " house = \"$ATTR_HOUSE\""
|
|
fi
|
|
if [ ! -z "$ATTR_CODE" ]; then
|
|
echo " code = \"$ATTR_CODE\""
|
|
fi
|
|
if [ ! -z "$ATTR_UNIT" ]; then
|
|
echo " unit = \"$ATTR_UNIT\""
|
|
fi
|
|
if [ ! -z "$ATTR_FADE" ]; then
|
|
echo " fade = \"$ATTR_FADE\""
|
|
fi
|
|
|
|
echo " }"
|
|
fi
|
|
|
|
echo "}"
|
|
) >> /etc/tellstick.conf
|
|
done
|
|
|
|
echo "[Info] Run telldusd & socat"
|
|
|
|
# Expose the unix socket to internal network
|
|
socat TCP-LISTEN:50800,reuseaddr,fork UNIX-CONNECT:/tmp/TelldusClient &
|
|
socat TCP-LISTEN:50801,reuseaddr,fork UNIX-CONNECT:/tmp/TelldusEvents &
|
|
|
|
# Run telldus-core daemon
|
|
exec /usr/local/sbin/telldusd --nodaemon < /dev/null
|