Skip to content

Commit

Permalink
allow multiple ism7mqtt instances
Browse files Browse the repository at this point in the history
  • Loading branch information
b3nn0 committed Oct 29, 2023
1 parent 5d82d2a commit 0b3203b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 28 deletions.
11 changes: 8 additions & 3 deletions ism7mqtt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
```
14 changes: 12 additions & 2 deletions ism7mqtt/config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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?"




69 changes: 47 additions & 22 deletions ism7mqtt/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions ism7mqtt/translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion ism7mqtt/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0b3203b

Please sign in to comment.