diff --git a/ism7mqtt/CHANGELOG.md b/ism7mqtt/CHANGELOG.md index 576df42..4f638c4 100644 --- a/ism7mqtt/CHANGELOG.md +++ b/ism7mqtt/CHANGELOG.md @@ -1,4 +1,9 @@ ## What's Changed -- Bump ism7mqtt to v0.0.14 -- fix localization inside docker images -- increase timeouts for ism7config +- Allow multiple instances of ism7mqtt to run. +Exmaple config for additional devices: +``` +- device_name: "WolfHeizung2" + ism7_ip: 192.168.x.x + ism7_password: xxxx + interval: 60 +``` diff --git a/ism7mqtt/config.yaml b/ism7mqtt/config.yaml index d851978..e80d442 100644 --- a/ism7mqtt/config.yaml +++ b/ism7mqtt/config.yaml @@ -1,6 +1,6 @@ name: "Ism7MQTT" description: "Addon for direct communication with a Wolf ISM7 module" -version: "v0.0.14" +version: "v0.0.14-1" slug: "ism7mqtt" init: false url: https://github.com/b3nn0/hassio-addon-ism7mqtt @@ -23,14 +23,24 @@ options: #ism7_password: "" device_name: Wolf interval: 60 + additional_devices: [] debug_logging: False + schema: + device_name: str ism7_ip: str ism7_password: password - device_name: str interval: int debug_logging: bool + + additional_devices: + - device_name: str + ism7_ip: str + ism7_password: password + interval: "int?" + + diff --git a/ism7mqtt/run.sh b/ism7mqtt/run.sh index 3e801e9..7b4365a 100644 --- a/ism7mqtt/run.sh +++ b/ism7mqtt/run.sh @@ -5,39 +5,64 @@ export CONFIG_PATH=/data/options.json export ISM7_MQTTHOST=$(bashio::services mqtt "host") export ISM7_MQTTUSERNAME=$(bashio::services mqtt "username") export ISM7_MQTTPASSWORD=$(bashio::services mqtt "password") - -export ISM7_IP=$(bashio::config 'ism7_ip') -export ISM7_PASSWORD=$(bashio::config 'ism7_password') -export HA_DISCOVERY_ID=$(bashio::config 'device_name') -export INTERVAL=$(bashio::config 'interval') export DEBUG_LOGGING=$(bashio::config 'debug_logging') -set -x -cd /app +function start_ism7mqtt() { + export ISM7_HOMEASSISTANT_ID=$1 + export ISM7_IP=$2 + export ISM7_PASSWORD=$3 + export ISM7_INTERVAL=$4 + + if [ $ISM7_INTERVAL = "" ]; then + export ISM7_INTERVAL=60 + fi -parameters="/config/ism7-parameters-$HA_DISCOVERY_ID.json" + cd /app -if ! [ -f $parameters ]; then - echo "Creating initial configuration $parameters" - /app/ism7config -t $parameters + parameters="/config/ism7-parameters-$HA_DISCOVERY_ID.json" if ! [ -f $parameters ]; then - echo "Parameter file creation seems to have failed. Please report to the ism7mqtt project: https://github.com/zivillian/ism7mqtt/issues/new" - exit -1 + echo "Creating initial configuration $parameters" + /app/ism7config -t $parameters + if ! [ -f $parameters ]; then + echo "Parameter file creation seems to have failed. Please report to the ism7mqtt project: https://github.com/zivillian/ism7mqtt/issues/new" + exit -1 + fi + fi + + # Not really needed, most of it could also be read from env, but helps identifying which process is which + ISM_ARGS="--hass-id=$ISM7_HOMEASSISTANT_ID --interval=$ISM7_INTERVAL --ipAddress=$ISM7_IP -t $parameters" + if [[ "$DEBUG_LOGGING" == "true" ]]; then + ISM_ARGS+=" -d" fi -fi + while [ true ]; do + echo "Starting ism7mqtt $ISM_ARGS" + /app/ism7mqtt $ISM_ARGS || echo "ism7mqtt unexpectedly quit with return code $?" + sleep 10 + done +} +HA_DISCOVERY_ID=$(bashio::config 'device_name') +ISM7_IP=$(bashio::config 'ism7_ip') +ISM7_PASSWORD=$(bashio::config 'ism7_password') +INTERVAL=$(bashio::config 'interval') -ISM_ARGS="--hass-id=$HA_DISCOVERY_ID --interval=$INTERVAL -t $parameters" -if [[ "$DEBUG_LOGGING" == "true" ]]; then - ISM_ARGS+=" -d" -fi +echo "Setting up ism7mqtt $HA_DISCOVERY_ID $ISM7_IP" +start_ism7mqtt $HA_DISCOVERY_ID $ISM7_IP $ISM7_PASSWORD $INTERVAL & -while [ true ]; do - echo "Starting ism7mqtt $ISM_ARGS" - /app/ism7mqtt $ISM_ARGS || echo "ism7mqtt unexpectedly quit with return code $?" - sleep 10 + +# Set username and password for the broker +for device in $(bashio::config 'additional_devices|keys'); do + devname=$(bashio::config "additional_devices[${device}].device_name") + ip=$(bashio::config "additional_devices[${device}].ism7_ip") + password=$(bashio::config "additional_devices[${device}].ism7_password") + interval=$(bashio::config "additional_devices[${device}].interval") + + echo "Setting up ism7mqtt $devname $ip" + start_ism7mqtt $devname $ip $password $interval & done + +wait \ No newline at end of file diff --git a/ism7mqtt/translations/de.yaml b/ism7mqtt/translations/de.yaml index 682c5a8..27b5cca 100644 --- a/ism7mqtt/translations/de.yaml +++ b/ism7mqtt/translations/de.yaml @@ -10,4 +10,14 @@ configuration: name: Update Intervall (Sekunden) debug_logging: name: Debug logging + additional_devices: + name: Weitere ISM7 Geräte + description: >- + Wenn weitere ISM7 Geräte vorhanden sind, können diese hier speizifiziert werden um mehrere ism7mqtt Instanzen zu starten. + Dazu mehrere Blöcke dieser Art angeben: + - device_name: "WolfHeizung2" + ism7_ip: 192.168.x.x + ism7_password: xxxx + interval: 60 + diff --git a/ism7mqtt/translations/en.yaml b/ism7mqtt/translations/en.yaml index 6dae74e..02e9a5a 100644 --- a/ism7mqtt/translations/en.yaml +++ b/ism7mqtt/translations/en.yaml @@ -10,4 +10,12 @@ configuration: name: Update interval (seconds) debug_logging: name: Debug logging - + additional_devices: + name: Additional ISM7 devices + description: >- + If you have multiple ISM7 Devices, specify them here to start ism7mqtt multiple times. + To do so, add multiple blocks like this: + - device_name: "WolfHeater2" + ism7_ip: 192.168.x.x + ism7_password: xxxx + interval: 60