generated from home-assistant/addons-example
-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
44 lines (31 loc) · 1.18 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/with-contenv bashio
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')
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
set -x
cd /app
parameters="/config/ism7-parameters-$HA_DISCOVERY_ID.json"
if ! [ -f $parameters ]; then
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 Author"
exit -1
fi
fi
ISM_ARGS="--hass-id=$HA_DISCOVERY_ID --interval=$INTERVAL -t $parameters"
if [[ "$DEBUG_LOGGING" == "true" ]]; then
ISM_ARGS+=" -d"
fi
while [ true ]; do
echo "Starting ism7mqtt $ISM_ARGS"
/app/ism7mqtt $ISM_ARGS || echo "ism7mqtt unexpectedly quit with return code $?"
sleep 10
done