diff --git a/homematic/CHANGELOG.md b/homematic/CHANGELOG.md index 964c16c..9108fb7 100644 --- a/homematic/CHANGELOG.md +++ b/homematic/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 6 +- Allow customer firmware updates inside `/share` +- Update Hardware on startup +- Limit HmIP server to 64mb memory +- Set `rf_enable` default to `false` + ## 5 - Save hmip_address.conf persistent diff --git a/homematic/Dockerfile b/homematic/Dockerfile index 551de1d..ad18624 100644 --- a/homematic/Dockerfile +++ b/homematic/Dockerfile @@ -14,14 +14,14 @@ ARG BUILD_ARCH # Install OCCU WORKDIR /usr/src -RUN curl -sL -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 \ +RUN curl -SL https://github.com/eq-3/occu/archive/${OCCU_VERSION}.tar.gz | tar xzf - \ && cd occu-${OCCU_VERSION} \ && mkdir -p /opt/hm \ && mkdir -p /opt/hm/etc/config \ && mkdir -p /opt/HmIP \ && mkdir -p /opt/HMServer \ + && mkdir -p /boot \ + && echo "VERSION=${OCCU_VERSION}" > /boot/VERSION \ && ln -s /opt/hm/etc/config /etc/config \ && if [ "${BUILD_ARCH}" = "armhf" ]; \ then \ @@ -37,7 +37,8 @@ RUN curl -sL -o occu.tar.gz https://github.com/eq-3/occu/archive/${OCCU_VERSION} && cp -R packages-eQ-3/HS485D/bin /opt/hm/ \ && cp -R packages-eQ-3/HS485D/lib /opt/hm/ \ && cd ../ \ - && cp -r firmware /opt/hm/ \ + && cp -r firmware / \ + && mv /firmware/HmIP-RFUSB/hmip_coprocessor_update.eq3 /firmware/HmIP-RFUSB/hmip_coprocessor_update-2.8.6.eq3 \ && cp -R HMserver/etc/config_templates/* /opt/hm/etc/config/ \ && cp -R HMserver/opt/HmIP/* /opt/HmIP/ \ && cp -a HMserver/opt/HMServer/HMIPServer.jar /opt/HMServer/ \ @@ -52,6 +53,7 @@ COPY rfd.conf hs485d.conf crRFD.conf /etc/config/ # Setup start script COPY run.sh / +COPY hm-firmware.sh /usr/lib/ RUN chmod a+x /run.sh WORKDIR /data diff --git a/homematic/config.json b/homematic/config.json index 710e3be..6319e8f 100644 --- a/homematic/config.json +++ b/homematic/config.json @@ -1,10 +1,11 @@ { "name": "HomeMatic OCCU", - "version": "5", + "version": "6", "slug": "homematic", "description": "HomeMatic central based on OCCU", "url": "https://home-assistant.io/addons/homematic/", "arch": ["armhf", "i386", "amd64"], + "map": ["share:ro"], "startup": "system", "boot": "auto", "auto_uart": true, @@ -16,12 +17,11 @@ "2010/tcp": 2010 }, "options": { - "rf_enable": true, + "rf_enable": false, "rf": [ { "type": "CCU2", - "device": "/dev/ttyAMA0", - "reset": false + "device": "/dev/ttyAMA0" } ], "wired_enable": false, diff --git a/homematic/crRFD.conf b/homematic/crRFD.conf index 89275ea..87166b8 100644 --- a/homematic/crRFD.conf +++ b/homematic/crRFD.conf @@ -1,10 +1,10 @@ Config.Dir=/data/crRFD -Config.Include=hmip_user.conf +#Config.Include=hmip_user.conf # Directory Configuration Persistence.Home=/data/crRFD -FirmwareUpdate.BG.OTAU.Home=/opt/hm/firmware +FirmwareUpdate.BG.OTAU.Home=/share/hmip-firmware FirmwareUpdate.BG.OTAU.divergent.device.type.definition.file=/opt/HmIP/crrfd.fwfix # Legacy API Configuration diff --git a/homematic/hm-firmware.sh b/homematic/hm-firmware.sh new file mode 100644 index 0000000..aa839d7 --- /dev/null +++ b/homematic/hm-firmware.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2012 + + +function firmware_update_hmip() { + local DEVICE="$1" + local FROM_VERSION= + local TO_VERSION= + + FROM_VERSION="$(java -Xmx64m -jar /opt/HmIP/hmip-copro-update.jar -p "${DEVICE}" -v | grep "Application version =" | cut -d' ' -f5)" + TO_VERSION="$(ls /firmware/HmIP-RFUSB/hmip_coprocessor_update-*.eq3 | sed 's/.*hmip_coprocessor_update-\(.*\)\.eq3/\1/' | tail -n1)" + if [ "${FROM_VERSION}" != "${TO_VERSION}" ]; then + java -Xmx64m -jar /opt/HmIP/hmip-copro-update.jar -p "${DEVICE}" -f "/firmware/HmIP-RFUSB/hmip_coprocessor_update-${TO_VERSION}.eq3" + fi +} + + +function firmware_update_rfd() { + "${HM_HOME}/bin/eq3configcmd" update-coprocessor -lgw -u -rfdconf /etc/config/rfd.conf -l 1 +} + + +function firmware_update_wired() { + "${HM_HOME}/bin/eq3configcmd" update-lgw-firmware -m /firmware/fwmap -c /etc/config/hs485d.conf -l 1 +} diff --git a/homematic/hs485d.conf b/homematic/hs485d.conf index 4107be9..328cab7 100644 --- a/homematic/hs485d.conf +++ b/homematic/hs485d.conf @@ -5,7 +5,7 @@ Log Destination = None Persist Keys = 1 -Device Description Dir = /opt/hm/firmware/hs485types +Device Description Dir = /firmware/hs485types Device Files Dir = /data/hs485d -Firmware Dir = /opt/hm/firmware -User Firmware Dir = /data/firmware +Firmware Dir = /firmware +User Firmware Dir = /share/hm-firmware diff --git a/homematic/rfd.conf b/homematic/rfd.conf index 3209595..b197b35 100644 --- a/homematic/rfd.conf +++ b/homematic/rfd.conf @@ -5,10 +5,10 @@ Log Destination = None Persist Keys = 1 -Device Description Dir = /opt/hm/firmware/rftypes +Device Description Dir = /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 +Firmware Dir = /firmware +User Firmware Dir = /share/hm-firmware +Replacemap File = /firmware/rftypes/replaceMap/rfReplaceMap.xml diff --git a/homematic/run.sh b/homematic/run.sh index 903c8c5..ac60880 100644 --- a/homematic/run.sh +++ b/homematic/run.sh @@ -12,13 +12,14 @@ HMIP_DEVICES=$(jq --raw-output '.hmip | length' $CONFIG_PATH) WAIT_PIDS=() # Init folder -mkdir -p /data/firmware +mkdir -p /share/hm-firmware +mkdir -p /share/hmip-firmware mkdir -p /data/crRFD +mkdir -p /data/rfd +mkdir -p /data/hs485d -# Restore data -if [ -f /data/hmip_address.conf ]; then - cp -f /data/hmip_address.conf /etc/config/ -fi +# shellcheck disable=SC1091 +. /usr/lib/hm-firmware.sh # RF support if [ "$RF_ENABLE" == "true" ]; then @@ -36,9 +37,7 @@ if [ "$RF_ENABLE" == "true" ]; then echo "ResetFile = /sys/class/gpio/gpio18/value" ) >> /etc/config/rfd.conf - # Init GPIO - RESET=$(jq --raw-output ".rf[$i].reset // false" $CONFIG_PATH) if [ ! -d /sys/class/gpio/gpio18 ]; then echo 18 > /sys/class/gpio/export sleep 2 @@ -47,15 +46,15 @@ if [ "$RF_ENABLE" == "true" ]; then echo out > /sys/class/gpio/gpio18/direction sleep 2 fi - if [ "$RESET" == "true" ]; then - echo 1 > /sys/class/gpio/gpio18/value || echo "Can't reset module!" - sleep 0.5 - fi + echo 0 > /sys/class/gpio/gpio18/value || echo "Can't set default value!" sleep 0.5 fi done + # Update Firmware + firmware_update_rfd + # Run RFD "$HM_HOME/bin/rfd" -c -l 0 -f /opt/hm/etc/config/rfd.conf & WAIT_PIDS+=($!) @@ -78,6 +77,9 @@ if [ "$WIRED_ENABLE" == "true" ]; then ) >> /etc/config/hs485d.conf done + # Update Firmware + firmware_update_wired + # Run hs485d "$HM_HOME/bin/hs485d" -g -i 0 -f /opt/hm/etc/config/hs485d.conf & WAIT_PIDS+=($!) @@ -85,11 +87,20 @@ fi # HMIP support if [ "$HMIP_ENABLE" == "true" ]; then + # Restore data + if [ -f /data/hmip_address.conf ]; then + cp -f /data/hmip_address.conf /etc/config/ + fi + + # Setup settings for (( i=0; i < "$HMIP_DEVICES"; i++ )); do TYPE=$(jq --raw-output ".hmip[$i].type" $CONFIG_PATH) DEVICE=$(jq --raw-output ".hmip[$i].device" $CONFIG_PATH) ADAPTER=$((i+1)) + # Update Firmware + firmware_update_hmip "${DEVICE}" + # Update config ( echo "Adapter.${ADAPTER}.Type=${TYPE}" @@ -99,7 +110,7 @@ if [ "$HMIP_ENABLE" == "true" ]; then # Run HMIPServer # shellcheck disable=SC2086 - java -Xmx128m -Dos.arch=arm -Dlog4j.configuration=file:///etc/config/log4j.xml -Dfile.encoding=ISO-8859-1 -Dgnu.io.rxtx.SerialPorts=${DEVICE} -jar /opt/HMServer/HMIPServer.jar /etc/config/crRFD.conf & + java -Xmx64m -Dlog4j.configuration=file:///etc/config/log4j.xml -Dfile.encoding=ISO-8859-1 -jar /opt/HMServer/HMIPServer.jar /etc/config/crRFD.conf & WAIT_PIDS+=($!) if [ ! -f /data/hmip_address.conf ]; then