Skip to content

Commit

Permalink
one config for multiple or single device
Browse files Browse the repository at this point in the history
  • Loading branch information
bkbilly committed Mar 21, 2020
1 parent 6ab6695 commit 38962df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,9 @@ docker run --rm -v "$PWD/data":/data gree-hvac-mqtt-bridge

### Multiple devices

As of 1.2.0 the Hassio addon supports multiple devices by running paralell NodeJS processes in PM2. Old configurations will work, but are deprecated.
As of 1.2.0 the Hassio addon supports multiple devices by running paralell NodeJS processes in PM2. Old configurations will work, but will run without PM2.

Deprecated config example:

```json
"hvac_host": "192.168.0.255",
"mqtt": {
"broker_url": "mqtt:https://localhost",
"topic_prefix": "/my/topic/prefix",
}
```

Correct config example:
config example:

```json
"mqtt": {
Expand Down Expand Up @@ -170,6 +160,10 @@ Note: This command may vary depending on your OS (e.g. Linux, macOS, CygWin). If

## Changelog

[1.2.3]

- Fix run script for single device with same configuration

[1.2.2]

- Fix incorrect state checks
Expand Down
11 changes: 7 additions & 4 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
set -e

CONFIG_PATH=/data/options.json
CONFIG_PATH=data/options.json

HVAC_HOST=$(jq -r ".hvac_host" $CONFIG_PATH)
MQTT_BROKER_URL=$(jq -r ".mqtt.broker_url" $CONFIG_PATH)
Expand Down Expand Up @@ -29,11 +29,14 @@ if [ "$INSTANCES" -gt 0 ]; then
done
npx pm2 logs /HVAC_/
else
echo "Running in single-instance mode (DEPRECATED)"
node index.js \
HVAC_HOST=$(jq -r ".devices[0].hvac_host" $CONFIG_PATH);
MQTT_TOPIC_PREFIX=$(jq -r ".devices[0].mqtt_topic_prefix" $CONFIG_PATH);
echo "Running instance 0 for $HVAC_HOST"
#echo "${HVAC_HOST}, ${MQTT_BROKER_URL}, ${MQTT_TOPIC_PREFIX}, ${MQTT_USERNAME}, ${MQTT_PASSWORD}"
/usr/bin/node index.js \
--hvac-host="${HVAC_HOST}" \
--mqtt-broker-url="${MQTT_BROKER_URL}" \
--mqtt-topic-prefix="${MQTT_TOPIC_PREFIX}" \
--mqtt-username="${MQTT_USERNAME}" \
--mqtt-password="${MQTT_PASSWORD}"
fi
fi

0 comments on commit 38962df

Please sign in to comment.