Telldus core (#201)
* 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..
This commit is contained in:
committed by
Pascal Vizeli
parent
543a592afc
commit
aa02ebf3b9
27
tellstick/Dockerfile
Normal file
27
tellstick/Dockerfile
Normal file
@@ -0,0 +1,27 @@
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Install Telldus library for TellStick (using same approach as in hassio docker installation)
|
||||
RUN apk add --no-cache \
|
||||
confuse libftdi1 libstdc++ jq socat \
|
||||
&& apk add --no-cache --virtual .build-dependencies \
|
||||
cmake build-base gcc doxygen confuse-dev argp-standalone libftdi1-dev git \
|
||||
&& ln -s /usr/include/libftdi1/ftdi.h /usr/include/ftdi.h \
|
||||
&& mkdir -p /usr/src \
|
||||
&& cd /usr/src \
|
||||
&& git clone -b master --depth 1 https://github.com/telldus/telldus \
|
||||
&& cd telldus/telldus-core \
|
||||
&& sed -i "/\<sys\/socket.h\>/a \#include \<sys\/select.h\>" common/Socket_unix.cpp \
|
||||
&& cmake . -DBUILD_LIBTELLDUS-CORE=ON -DBUILD_TDADMIN=OFF -DBUILD_TDTOOL=ON -DGENERATE_MAN=OFF -DFORCE_COMPILE_FROM_TRUNK=ON -DFTDI_LIBRARY=/usr/lib/libftdi1.so \
|
||||
&& make \
|
||||
&& make install \
|
||||
&& apk del .build-dependencies \
|
||||
&& rm -rf /usr/src/telldus
|
||||
|
||||
# Copy data for add-on
|
||||
COPY run.sh /
|
||||
RUN chmod a+x /run.sh
|
||||
|
||||
CMD [ "/run.sh" ]
|
||||
37
tellstick/config.json
Normal file
37
tellstick/config.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "Tellstick",
|
||||
"version": "0.1",
|
||||
"slug": "tellstick",
|
||||
"description": "Telldus Tellstick daemon and tools.",
|
||||
"url": "https://home-assistant.io/addons/tellstick/",
|
||||
"startup": "services",
|
||||
"boot": "auto",
|
||||
"devices": ["/dev/bus/usb:/dev/bus/usb:rwm"],
|
||||
"options": {
|
||||
"devices": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Example device",
|
||||
"protocol": "everflourish",
|
||||
"model": "selflearning-switch",
|
||||
"house": "A",
|
||||
"unit": "1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"schema": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "int(1,)",
|
||||
"name": "str",
|
||||
"protocol": "match(arctech|brateck|everflourish|fuhaote|hasta|ikea|kangtai|risingsun|sartano|silvanchip|upm|waveman|x10|yidong)",
|
||||
"model": "match(codeswitch|bell|selflearning-switch|selflearning-dimmer|selflearning|ecosavers|kp100)?",
|
||||
"house": "str?",
|
||||
"code": "str?",
|
||||
"unit": "str?",
|
||||
"fade": "str?"
|
||||
}
|
||||
]
|
||||
},
|
||||
"image": "homeassistant/{arch}-addon-tellstick"
|
||||
}
|
||||
66
tellstick/run.sh
Normal file
66
tellstick/run.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user