forked from home-assistant/addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deconz: Refactor (home-assistant#1476)
* deconz: Refactor * Disable shellcheck warning * Fix wiringpi * Bump version 6.0.0 * fix osram ota * Revert file & update changelog * Small bugfixes * Exclude Co-authored-by: Pascal Vizeli <[email protected]>
- Loading branch information
Showing
25 changed files
with
302 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"build_from": { | ||
"aarch64": "homeassistant/aarch64-base-debian:stretch", | ||
"amd64": "homeassistant/amd64-base-ubuntu:18.04", | ||
"armhf": "homeassistant/armhf-base-raspbian:stretch" | ||
"aarch64": "homeassistant/aarch64-base-debian:buster", | ||
"amd64": "homeassistant/amd64-base-debian:buster", | ||
"armhf": "homeassistant/armhf-base-debian:buster" | ||
}, | ||
"args": { | ||
"DECONZ_VERSION": "2.05.78" | ||
"DECONZ_VERSION": "2.05.79" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# Manage deCONZ firmware | ||
# ============================================================================== | ||
|
||
bashio::log.info "$(/usr/bin/GCFFlasher_internal -l)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# Configure NGINX for use with deCONZ | ||
# ============================================================================== | ||
ingress_entry=$(bashio::addon.ingress_entry) | ||
sed -i "s#%%ingress_entry%%#${ingress_entry}#g" /etc/nginx/nginx.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# Configure VNC for use with deCONZ | ||
# ============================================================================== | ||
|
||
# Check if VNC is enabled | ||
VNC_PORT="$(bashio::addon.port 5900)" | ||
if ! bashio::var.has_value "${VNC_PORT}"; then | ||
# VNC is not enabled, skip this. | ||
bashio::exit.ok | ||
fi | ||
|
||
# Require password when VNC is enabled | ||
if ! bashio::config.has_value 'vnc_password'; then | ||
bashio::exit.nok "VNC has been enabled, but no password has been set!" | ||
fi | ||
|
||
VNC_PASSWORD=$(bashio::config 'vnc_password') | ||
echo "${VNC_PASSWORD}" | tigervncpasswd -f > /root/.vncpasswd |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/with-contenv bashio | ||
# ============================================================================== | ||
# Send deCONZ discovery information to Home Assistant | ||
# ============================================================================== | ||
readonly DATA_STORE="/data/.local/share/dresden-elektronik/deCONZ/zll.db" | ||
declare api_key | ||
declare config | ||
declare query | ||
declare retries | ||
declare serial | ||
|
||
# Wait for deCONZ to start before continuing | ||
bashio::net.wait_for 40850 | ||
|
||
# Remove old discovery data storage (cleanup) | ||
# We now query the deCONZ database for it directly. | ||
if bashio::fs.file_exists /data/hassio.json; then | ||
rm /data/hassio.json | ||
fi | ||
|
||
# Try to get API key from deCONZ database | ||
query='SELECT apikey FROM auth WHERE devicetype="Home Assistant" ORDER BY createdate DESC LIMIT 1' | ||
api_key=$(sqlite3 "${DATA_STORE}" "${query}" .exit) | ||
if ! bashio::var.has_value "${api_key}"; then | ||
# Register an API key for Home Assistant | ||
if ! result="$(curl --silent --show-error --request POST -d '{"devicetype": "Home Assistant"}' "http://127.0.0.1:40850/api")"; | ||
then | ||
bashio::log.debug "${result}" | ||
bashio::exit.nok "Can't get API key from deCONZ gateway" | ||
fi | ||
api_key="$(bashio::jq "${result}" '.[0].success.username')" | ||
fi | ||
|
||
# Try to get the bridge ID/serial, try to avoid using 0000000000000000 | ||
retries=25 | ||
serial="0000000000000000" | ||
while [[ "${serial}" = "0000000000000000" ]]; do | ||
bashio::log.debug "Waiting for bridge ID..." | ||
sleep 10 | ||
|
||
# If we tried 25 times, just abort. | ||
if [[ "${retries}" -eq 0 ]]; then | ||
bashio::exit.nok "Failed to get a valid bridge ID. Discovery aborted." | ||
fi | ||
|
||
# Get bridge ID from API | ||
if ! result="$(curl --silent --show-error --request GET "http://127.0.0.1:40850/api/${api_key}/config")"; | ||
then | ||
bashio::log.debug "${result}" | ||
bashio::exit.nok "Can't get data from deCONZ gateway" | ||
fi | ||
serial="$(bashio::jq "${result}" '.bridgeid')" | ||
|
||
((retries--)) | ||
done | ||
|
||
# Create config payload for Home Assistant | ||
config=$(bashio::var.json \ | ||
host "$(bashio::addon.ip_address)" \ | ||
port "^40850" \ | ||
api_key "${api_key}" \ | ||
serial "${serial}" \ | ||
) | ||
|
||
# Send discovery info | ||
if bashio::discovery "deconz" "${config}" > /dev/null; then | ||
bashio::log.info "Successfully send discovery information to Home Assistant." | ||
else | ||
bashio::log.error "Discovery message to Home Assistant failed!" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/execlineb -S1 | ||
# ============================================================================== | ||
# Take down the S6 supervision tree based on service exit code | ||
# ============================================================================== | ||
if { s6-test ${1} -ne 0 } | ||
if { s6-test ${1} -ne 256 } | ||
|
||
s6-svscanctl -t /var/run/s6/services |
Oops, something went wrong.