diff --git a/homematic/Dockerfile b/homematic/Dockerfile new file mode 100644 index 0000000..87a3296 --- /dev/null +++ b/homematic/Dockerfile @@ -0,0 +1,38 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +# Install packages +RUN apt-get update \ + && apt-get install -y \ + curl \ + jq \ + libusb-1.0 \ + && rm -rf /var/lib/apt/lists/* + +ARG OCCU_VERSION +ARG BUILD_ARCH + +# Install OCCU +WORKDIR /usr/src +RUN curl -L -o occu.tar.gz https://github.com/eq-3/occu/archive/${OCCU_VERSION}.tar.gz \ + && tar xzpf occu.tar.gz \ + && rm -f occu.tar.gz \ + && cd occu-${OCCU_VERSION} \ + && if [ "${BUILD_ARCH}" = "armhf" ]; then cd arm-gnueabihf; else cd X86_32_Debian_Wheezy; fi \ + && mkdir -p /opt/hm \ + && cp -R packages-eQ-3/RFD/* /opt/hm \ + && cp -R packages-eQ-3/LinuxBasis/* /opt/hm \ + && cp -R packages-eQ-3/HS485D/* /opt/hm \ + && ln -s /opt/hm/etc/config /etc/config \ + && cp -r ../firmware /opt/hm/ \ + && rm -rf /usr/src/occu-${OCCU_VERSION} +ENV HM_HOME=/opt/hm LD_LIBRARY_PATH=/opt/hm/lib:${LD_LIBRARY_PATH} + +# Update config files +COPY rfd.conf /etc/config + +# Setup start script +COPY run.sh / +RUN chmod a+x /run.sh + +CMD [ "/run.sh" ] diff --git a/homematic/build.json b/homematic/build.json new file mode 100644 index 0000000..ce82cb6 --- /dev/null +++ b/homematic/build.json @@ -0,0 +1,10 @@ +{ + "build_from": { + "armhf": "multiarch/ubuntu-core:armhf-xenial", + "amd64": "multiarch/ubuntu-core:i386-xenial", + "i386": "multiarch/ubuntu-core:i386-xenial" + }, + "args": { + "OCCU_VERSION": "2.29.22-1" + } +} diff --git a/homematic/config.json b/homematic/config.json new file mode 100644 index 0000000..8506054 --- /dev/null +++ b/homematic/config.json @@ -0,0 +1,24 @@ +{ + "name": "HomeMatic OCCU", + "version": "2.29.22-1-p0", + "slug": "homematic", + "description": "HomeMatic central based on OCCU", + "url": "https://home-assistant.io/addons/homematic/", + "arch": ["armhf", "i386", "amd64"], + "startup": "services", + "boot": "auto", + "auto_uart": true, + "gpio": true, + "ports": { + "2001/tcp": 2001 + }, + "options": { + "type": "CCU2", + "device": "/dev/ttyAMA0" + }, + "schema": { + "type": "match(CCU2)", + "device": "match(^/dev/.*$)" + }, + "image": "homeassistant/{arch}-addon-homeassistant" +} diff --git a/homematic/logo.png b/homematic/logo.png new file mode 100644 index 0000000..9c030d1 Binary files /dev/null and b/homematic/logo.png differ diff --git a/homematic/rfd.conf b/homematic/rfd.conf new file mode 100644 index 0000000..9baf51f --- /dev/null +++ b/homematic/rfd.conf @@ -0,0 +1,16 @@ +# TCP Port for XmlRpc connections +Listen Port = 2001 + +Log Destination = None + +Persist Keys = 1 + +Device Description Dir = /opt/hm/firmware/rftypes +Device Files Dir = /data/rfd +Key File = /data/keys +Address File = /data/ids +Firmware Dir = /opt/hm/firmware +User Firmware Dir = /data/firmware +Replacemap File = /opt/hm/firmware/rftypes/replaceMap/rfReplaceMap.xml + +[Interface 0] diff --git a/homematic/run.sh b/homematic/run.sh new file mode 100644 index 0000000..b19f1a5 --- /dev/null +++ b/homematic/run.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -e + +CONFIG_PATH=/data/options.json + +TYPE=$(jq --raw-output ".type" $CONFIG_PATH) +DEVICE=$(jq --raw-output ".device" $CONFIG_PATH) + +# Update config +if [ "$TYPE" == "CCU2" ]; then + ( + echo "Type = CCU2" + echo "ComPortFile = $DEVICE" + echo "AccessFile = /dev/null" + echo "ResetFile = /sys/class/gpio/gpio18/value" + ) >> /etc/config/rfd.conf +fi + +# Init folder +mkdir -p /data/firmware + +# Init GPIO +if [ ! -d /sys/class/gpio/gpio18 ]; then + echo 18 > /sys/class/gpio/export + sleep 2 +fi +if [ "$(cat /sys/class/gpio/gpio18/direction)" != "out" ]; then + echo out > /sys/class/gpio/gpio18/direction + sleep 2 +fi + +# Run RFID +"$HM_HOME/bin/rfd" -c -l 0 -f /opt/hm/etc/config/rfd.conf