Add homematic wired support (#214)

This commit is contained in:
Pascal Vizeli
2017-12-16 02:57:52 +01:00
committed by GitHub
parent 9cbc42553c
commit df3c7733f3
6 changed files with 114 additions and 30 deletions

10
homematic/CHANGELOG.md Normal file
View File

@@ -0,0 +1,10 @@
# Changelog
## 2.29.22-1-p1
- Change config logic
- Add support for wired
## 2.29.22-1-p0
- Initial

View File

@@ -29,7 +29,7 @@ RUN curl -L -o occu.tar.gz https://github.com/eq-3/occu/archive/${OCCU_VERSION}.
ENV HM_HOME=/opt/hm LD_LIBRARY_PATH=/opt/hm/lib:${LD_LIBRARY_PATH}
# Update config files
COPY rfd.conf /etc/config
COPY rfd.conf hs485d.conf /etc/config
# Setup start script
COPY run.sh /

View File

@@ -1,6 +1,6 @@
{
"name": "HomeMatic OCCU",
"version": "2.29.22-1-p0",
"version": "2.29.22-1-p1",
"slug": "homematic",
"description": "HomeMatic central based on OCCU",
"url": "https://home-assistant.io/addons/homematic/",
@@ -13,12 +13,38 @@
"2001/tcp": 2001
},
"options": {
"type": "CCU2",
"device": "/dev/ttyAMA0"
"rf_enable": true,
"rf": [
{
"type": "CCU2",
"device": "/dev/ttyAMA0"
}
],
"wired_enable": false,
"wired": [
{
"serial": "xy",
"key": "abc",
"ip": "192.168.0.0"
}
]
},
"schema": {
"type": "match(CCU2)",
"device": "match(^/dev/.*$)"
"rf_enable": "bool",
"rf": [
{
"type": "match(CCU2)",
"device": "match(^/dev/.*$)"
}
],
"wired_enable": "bool",
"wired": [
{
"serial": "str",
"key": "str",
"ip": "str"
}
]
},
"image": "homeassistant/{arch}-addon-homeassistant"
}

11
homematic/hs485d.conf Normal file
View File

@@ -0,0 +1,11 @@
# TCP Port for XmlRpc connections
Listen Port = 2000
Log Destination = None
Persist Keys = 1
Device Description Dir = /opt/hm/firmware/hs485types
Device Files Dir = /data/hs485d
Firmware Dir = /opt/hm/firmware
User Firmware Dir = /data/firmware

View File

@@ -12,5 +12,3 @@ 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]

View File

@@ -3,31 +3,70 @@ 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
RF_ENABLE=$(jq --raw-output '.rf_enable' $CONFIG_PATH)
RF_DEVICES=$(jq --raw-output '.rf | lenght' $CONFIG_PATH)
WIRED_ENABLE=$(jq --raw-output '.wired_enable' $CONFIG_PATH)
WIRED_DEVICES=$(jq --raw-output '.wired | lenght' $CONFIG_PATH)
WAIT_PIDS=()
# 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
# RF support
if [ "$RF_ENABLE" == "true" ]; then
for (( i=0; i < "$RF_DEVICES"; i++ )); do
TYPE=$(jq --raw-output ".rf[$i].type" $CONFIG_PATH)
# Update config
if [ "$TYPE" == "CCU2" ]; then
DEVICE=$(jq --raw-output ".rf[$i].device" $CONFIG_PATH)
(
echo "[Interface $1]"
echo "Type = CCU2"
echo "ComPortFile = $DEVICE"
echo "AccessFile = /dev/null"
echo "ResetFile = /sys/class/gpio/gpio18/value"
) >> /etc/config/rfd.conf
# 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
fi
done
# Run RFD
"$HM_HOME/bin/rfd" -c -l 0 -f /opt/hm/etc/config/rfd.conf &
WAIT_PIDS+=($!)
fi
# Run RFID
"$HM_HOME/bin/rfd" -c -l 0 -f /opt/hm/etc/config/rfd.conf
# Wired support
if [ "$WIRED_ENABLE" == "true" ]; then
for (( i=0; i < "$WIRED_DEVICES"; i++ )); do
SERIAL=$(jq --raw-output ".wired[$i].serial" $CONFIG_PATH)
KEY=$(jq --raw-output ".wired[$i].key" $CONFIG_PATH)
IP=$(jq --raw-output ".wired[$i].ip" $CONFIG_PATH)
# Update config
(
echo "[Interface $1]"
echo "Type = HMWLGW"
echo "Serial Number = $SERIAL"
echo "Encryption Key = $KEY"
echo "IP Address = $IP"
) >> /etc/config/hs485d.conf
done
# Run hs485d
"$HM_HOME/bin/hs485d" -g -i 0 -f /opt/hm/etc/config/hs485d.conf &
WAIT_PIDS+=($!)
fi
# Wait until all is done
wait "${WAIT_PIDS[@]}"