Skip to content

Commit

Permalink
Merge pull request #4740 from ChrisHae/master
Browse files Browse the repository at this point in the history
Updated Homebridge Hue deCONZ
  • Loading branch information
manup authored Apr 18, 2021
2 parents 16845ef + bc30e64 commit 3a548d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
15 changes: 7 additions & 8 deletions linux/deCONZ/usr/bin/deCONZ-homebridge-install.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#!/bin/bash

UPDATE_VERSION_HB="1.1.0"
UPDATE_VERSION_HB_HUE="0.11.74"
UPDATE_VERSION_HB_LIB="4.7.15"
UPDATE_VERSION_NPM="6.14.7"
UPDATE_VERSION_NODE="12.18.4"
# use install name to install the specific node version via apt. Retrieve it via: apt-cache policy nodejs
UPDATE_VERSION_NODE_INSTALL_NAME="12.18.4-1nodesource1"
UPDATE_VERSION_HB="1.3.4"
UPDATE_VERSION_HB_HUE="0.13.5"
UPDATE_VERSION_HB_LIB="5.1.1"
UPDATE_VERSION_NPM="6.14.12"
UPDATE_VERSION_NODE="14.16.0"

# when increasing major version of node adjust downoload link
NODE_DOWNLOAD_LINK="https://deb.nodesource.com/setup_12.x"
NODE_DOWNLOAD_LINK="https://deb.nodesource.com/setup_14.x"

TIMEOUT=0
LOG_LEVEL=3
Expand Down
27 changes: 25 additions & 2 deletions linux/deCONZ/usr/bin/deCONZ-homebridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ function checkHomebridge {
local HOMEBRIDGE=""
local IP_ADDRESS=""
local HOMEBRIDGE_PIN=""
local hb_hue_version=$(npm list -g homebridge-hue | grep homebridge-hue | cut -d@ -f2 | xargs)

#hostline used in config
local hostline="\"hosts\": [\"127.0.0.1\"],"
if [ $(echo "$hb_hue_version" | cut -d'.' -f 2) -le 13 ]; then
if [ $(echo "$hb_hue_version" | cut -d'.' -f 3) -lt 2 ]; then
hostline="\"host\": \"127.0.0.1\","
fi
fi

## get database config
params=( [0]="homebridge" [1]="ipaddress" [2]="homebridge-pin")
Expand Down Expand Up @@ -333,7 +342,9 @@ function checkHomebridge {

APIKEY="$SQL_RESULT"

# create config file if not exists
# if config file exists check if parameters are still valid
# to prevent this skript from overwrite config file set name parameter to something different then Phoscon Homebridge
# else create config file if not exists
if [[ -f /home/$MAINUSER/.homebridge/config.json ]]; then
# existing config found
[[ $LOG_DEBUG ]] && echo "${LOG_DEBUG}found existing homebridge config.json"
Expand Down Expand Up @@ -375,6 +386,18 @@ function checkHomebridge {
sed -i "/\"pin\":/c\ \"pin\": \"${HB_PIN}\"" /home/$MAINUSER/.homebridge/config.json
updated=true
fi
# check if hostline is still correct
local hostline2="\"host\": \"127.0.0.1\""
if [[ $hostline == "\"hosts\": [\"127.0.0.1\"]," ]]; then
hostline2="\"hosts\": \[\"127.0.0.1\"\],"
fi
# hostline2 only needed for grep
if [ -z "$(cat /home/$MAINUSER/.homebridge/config.json | grep "$hostline2")" ]; then
# hostline is wrong format for this hb hue version
[[ $LOG_DEBUG ]] && echo "${LOG_DEBUG}update hostline format in config file for this hb hue version"
sed -i "/\"host/c\ $hostline" /home/$MAINUSER/.homebridge/config.json
updated=true
fi
if [[ $updated = true ]]; then
putHomebridgeUpdated "homebridge" "updated"
else
Expand Down Expand Up @@ -414,7 +437,7 @@ function checkHomebridge {
\"platforms\": [
{
\"platform\": \"Hue\",
\"host\": \"127.0.0.1\",
${hostline}
\"users\": {
\"${BRIDGEID}\": \"${APIKEY}\"
},
Expand Down

0 comments on commit 3a548d7

Please sign in to comment.