mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 13:14:21 +01:00
deconz: Add Ingress (#922)
* deconz: Bump deCONZ to 2.05.72 * deconz: Remove UPnP support * deconz: Add Ingress support and improve discovery * deconz: Bump add-on version, update changelog
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 4.0
|
||||||
|
|
||||||
|
- Bump deCONZ to 2.05.72
|
||||||
|
- Add support for Hass.io Ingress
|
||||||
|
- Improve auto discovery handling
|
||||||
|
- Remove support for UPnP
|
||||||
|
|
||||||
## 3.9
|
## 3.9
|
||||||
|
|
||||||
- Adds support for enabling UPnP
|
- Adds support for enabling UPnP
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ RUN apt-get update \
|
|||||||
libqt5widgets5 \
|
libqt5widgets5 \
|
||||||
lsof \
|
lsof \
|
||||||
netcat \
|
netcat \
|
||||||
|
nginx \
|
||||||
sqlite3 \
|
sqlite3 \
|
||||||
tigervnc-common \
|
tigervnc-common \
|
||||||
tigervnc-standalone-server \
|
tigervnc-standalone-server \
|
||||||
@@ -54,7 +55,8 @@ RUN if [ "${BUILD_ARCH}" = "armhf" ]; \
|
|||||||
&& chown root:root /usr/bin/deCONZ* \
|
&& chown root:root /usr/bin/deCONZ* \
|
||||||
&& sed -i 's/\/root/\/data/' /etc/passwd
|
&& sed -i 's/\/root/\/data/' /etc/passwd
|
||||||
|
|
||||||
COPY data/run.sh data/discovery.sh /
|
|
||||||
COPY data/ika-otau-dl.sh /bin/
|
COPY data/ika-otau-dl.sh /bin/
|
||||||
|
COPY data/nginx.conf /etc/nginx/nginx.conf
|
||||||
|
COPY data/run.sh data/discovery.sh /
|
||||||
|
|
||||||
CMD ["/run.sh"]
|
CMD ["/run.sh"]
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ If you're using Hass.io you may find the correct value for this on the
|
|||||||
1. Replace `null` in the `device` option in the add-on configuration and specify
|
1. Replace `null` in the `device` option in the add-on configuration and specify
|
||||||
the device name in quotes: (e.g. `"/dev/ttyUSB0"`, `"/dev/ttyAMA0"`, or `"/dev/ttyACM0"`).
|
the device name in quotes: (e.g. `"/dev/ttyUSB0"`, `"/dev/ttyAMA0"`, or `"/dev/ttyACM0"`).
|
||||||
2. Click on "SAVE" to save the add-on configuration.
|
2. Click on "SAVE" to save the add-on configuration.
|
||||||
3. Start the add-on.
|
3. Toggle the "Show in sidebar" to add it to your Home Assistant side bar.
|
||||||
|
4. Start the add-on.
|
||||||
|
|
||||||
After installing and starting this add-on, access the deCONZ WebUI ("Phoscon")
|
After installing and starting this add-on, access the deCONZ WebUI ("Phoscon")
|
||||||
with "WEB UI" button.
|
with "WEB UI" button.
|
||||||
@@ -122,25 +123,6 @@ Example add-on config with `dbg_aps` enabled on log level 1:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Enabling UPnP
|
|
||||||
|
|
||||||
The add-on, by default, disables the native UPnP functionality of deCONZ.
|
|
||||||
This is because the add-on uses an alternative discovery mechanism that allows
|
|
||||||
for an improved integration experience.
|
|
||||||
|
|
||||||
Nevertheless, the add-on allows you to enable UPnP again, in case you want
|
|
||||||
deCONZ to be discovered by other applications (that are not Home Assistant).
|
|
||||||
|
|
||||||
Add the `upnp` add-on option, and set it to `true` to enable UPnP:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"device": "/dev/ttyUSB0",
|
|
||||||
"vnc_password": "",
|
|
||||||
"upnp": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Add-on configuration:
|
Add-on configuration:
|
||||||
@@ -168,6 +150,7 @@ In most cases this is one of the following:
|
|||||||
|
|
||||||
- Use at least 2.5A power supply for your Raspberry Pi!
|
- Use at least 2.5A power supply for your Raspberry Pi!
|
||||||
This avoids strange behavior when using this add-on.
|
This avoids strange behavior when using this add-on.
|
||||||
|
- The add-on has no UPnP support. UPnP interferes with Ingress.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
"armhf": "homeassistant/armhf-base-raspbian:stretch"
|
"armhf": "homeassistant/armhf-base-raspbian:stretch"
|
||||||
},
|
},
|
||||||
"args": {
|
"args": {
|
||||||
"DECONZ_VERSION": "2.05.71"
|
"DECONZ_VERSION": "2.05.72"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "deCONZ",
|
"name": "deCONZ",
|
||||||
"version": "3.9",
|
"version": "4.0",
|
||||||
"slug": "deconz",
|
"slug": "deconz",
|
||||||
"description": "Control a ZigBee network with ConBee or RaspBee by Dresden Elektronik",
|
"description": "Control a ZigBee network with ConBee or RaspBee by Dresden Elektronik",
|
||||||
"arch": ["amd64", "armhf", "aarch64"],
|
"arch": ["amd64", "armhf", "aarch64"],
|
||||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/deconz",
|
"url": "https://github.com/home-assistant/hassio-addons/tree/master/deconz",
|
||||||
"startup": "system",
|
"startup": "system",
|
||||||
"boot": "auto",
|
"boot": "auto",
|
||||||
|
"ingress": true,
|
||||||
|
"ingress_entry": "pwa/index.html",
|
||||||
|
"panel_icon": "mdi:zigbee",
|
||||||
"homeassistant": "0.91.2",
|
"homeassistant": "0.91.2",
|
||||||
"webui": "http://[HOST]:[PORT:80]/pwa/index.html",
|
|
||||||
"discovery": ["deconz"],
|
"discovery": ["deconz"],
|
||||||
"ports": {
|
"ports": {
|
||||||
"80/tcp": 40850,
|
"5900/tcp": null
|
||||||
"5900/tcp": null,
|
|
||||||
"8080/tcp": 40860
|
|
||||||
},
|
},
|
||||||
"ports_description": {
|
"ports_description": {
|
||||||
"80/tcp": "deCONZ API backend",
|
"5900/tcp": "deCONZ graphical desktop via VNC"
|
||||||
"5900/tcp": "deCONZ graphical desktop via VNC",
|
|
||||||
"8080/tcp": "deCONZ WebSocket Server"
|
|
||||||
},
|
},
|
||||||
"host_network": true,
|
|
||||||
"kernel_modules": true,
|
"kernel_modules": true,
|
||||||
"auto_uart": true,
|
"auto_uart": true,
|
||||||
"udev": true,
|
"udev": true,
|
||||||
@@ -39,8 +36,7 @@
|
|||||||
"dbg_info": "int?",
|
"dbg_info": "int?",
|
||||||
"dbg_otau": "int?",
|
"dbg_otau": "int?",
|
||||||
"dbg_zcl": "int?",
|
"dbg_zcl": "int?",
|
||||||
"dbg_zdp": "int?",
|
"dbg_zdp": "int?"
|
||||||
"upnp": "bool?"
|
|
||||||
},
|
},
|
||||||
"image": "homeassistant/{arch}-addon-deconz"
|
"image": "homeassistant/{arch}-addon-deconz"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,73 +3,66 @@
|
|||||||
DATA_STORE="/data/hassio.json"
|
DATA_STORE="/data/hassio.json"
|
||||||
|
|
||||||
|
|
||||||
function _discovery_config() {
|
|
||||||
local api_key=${1}
|
|
||||||
local serial=${2}
|
|
||||||
local config
|
|
||||||
|
|
||||||
config=$(bashio::var.json \
|
|
||||||
host "$(bashio::addon.ip_address)" \
|
|
||||||
port "^$(bashio::addon.port 80)" \
|
|
||||||
api_key "${api_key}" \
|
|
||||||
serial "${serial}" \
|
|
||||||
)
|
|
||||||
|
|
||||||
bashio::var.json \
|
|
||||||
service deconz \
|
|
||||||
config "^${config}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function _save_data() {
|
|
||||||
local api_key=${1}
|
|
||||||
local serial=${2}
|
|
||||||
local config
|
|
||||||
|
|
||||||
bashio::var.json api_key "${api_key}" serial "${serial}" > ${DATA_STORE}
|
|
||||||
bashio::log.debug "Store API information to ${DATA_STORE}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function _deconz_api() {
|
function _deconz_api() {
|
||||||
local api_key
|
local api_key
|
||||||
local result
|
local result
|
||||||
local api_port
|
local serial
|
||||||
|
|
||||||
api_port=$(bashio::addon.port 80)
|
# Register an API key for Home Assistant
|
||||||
while ! nc -z localhost "${api_port}" < /dev/null; do sleep 10; done
|
if ! result="$(curl --silent --show-error --request POST -d '{"devicetype": "Home Assistant"}' "http://127.0.0.1:8080/api")"; then
|
||||||
|
|
||||||
if ! result="$(curl --silent --show-error --request POST -d '{"devicetype": "Home Assistant"}' "http://127.0.0.1:${api_port}/api")"; then
|
|
||||||
bashio::log.debug "${result}"
|
bashio::log.debug "${result}"
|
||||||
bashio::exit.nok "Can't get API key from deCONZ gateway"
|
bashio::exit.nok "Can't get API key from deCONZ gateway"
|
||||||
fi
|
fi
|
||||||
api_key="$(echo "${result}" | jq --raw-output '.[0].success.username')"
|
api_key="$(bashio::jq "${result}" '.[0].success.username')"
|
||||||
|
|
||||||
sleep 15
|
# Try to get the bridge ID/serial, try to avoid using 0000000000000000
|
||||||
if ! result="$(curl --silent --show-error --request GET "http://127.0.0.1:${api_port}/api/${api_key}/config")"; then
|
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:8080/api/${api_key}/config")";
|
||||||
|
then
|
||||||
bashio::log.debug "${result}"
|
bashio::log.debug "${result}"
|
||||||
bashio::exit.nok "Can't get data from deCONZ gateway"
|
bashio::exit.nok "Can't get data from deCONZ gateway"
|
||||||
fi
|
fi
|
||||||
serial="$(echo "${result}" | jq --raw-output '.bridgeid')"
|
serial="$(bashio::jq "${result}" '.bridgeid')"
|
||||||
|
|
||||||
_save_data "${api_key}" "${serial}"
|
((retries--))
|
||||||
|
done
|
||||||
|
|
||||||
|
bashio::var.json api_key "${api_key}" serial "${serial}" > "${DATA_STORE}"
|
||||||
|
bashio::log.debug "Stored API information to ${DATA_STORE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _send_discovery() {
|
function _send_discovery() {
|
||||||
local api_key
|
local api_key
|
||||||
|
local config
|
||||||
local result
|
local result
|
||||||
local payload
|
|
||||||
|
|
||||||
api_key="$(jq --raw-output '.api_key' "${DATA_STORE}")"
|
api_key="$(bashio::jq "${DATA_STORE}" '.api_key')"
|
||||||
serial="$(jq --raw-output '.serial' "${DATA_STORE}")"
|
serial="$(bashio::jq "${DATA_STORE}" '.serial')"
|
||||||
|
|
||||||
|
config=$(bashio::var.json \
|
||||||
|
host "$(hostname)" \
|
||||||
|
port "^8080" \
|
||||||
|
api_key "${api_key}" \
|
||||||
|
serial "${serial}" \
|
||||||
|
)
|
||||||
|
|
||||||
# Send discovery info
|
# Send discovery info
|
||||||
payload="$(_discovery_config "${api_key}" "${serial}")"
|
if bashio::discovery "deconz" "${config}" > /dev/null; then
|
||||||
if bashio::api.hassio "POST" "/discovery" "${payload}"; then
|
bashio::log.info "Successfully send discovery information to Home Assistant."
|
||||||
bashio::log.info "Success send discovery information to Home Assistant"
|
|
||||||
else
|
else
|
||||||
bashio::log.error "Discovery message to Home Assistant fails!"
|
bashio::log.error "Discovery message to Home Assistant failed!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +70,7 @@ function _send_discovery() {
|
|||||||
function hassio_discovery() {
|
function hassio_discovery() {
|
||||||
|
|
||||||
# No API data exists - generate
|
# No API data exists - generate
|
||||||
if [ ! -f "$DATA_STORE" ]; then
|
if ! bashio::fs.file_exists "${DATA_STORE}"; then
|
||||||
bashio::log.info "Create API data for Home Assistant"
|
bashio::log.info "Create API data for Home Assistant"
|
||||||
_deconz_api
|
_deconz_api
|
||||||
fi
|
fi
|
||||||
|
|||||||
62
deconz/data/nginx.conf
Normal file
62
deconz/data/nginx.conf
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
worker_processes 1;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
error_log /dev/stdout info;
|
||||||
|
daemon off;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
sendfile on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
proxy_read_timeout 1200;
|
||||||
|
gzip on;
|
||||||
|
gzip_disable "msie6";
|
||||||
|
resolver 127.0.0.11;
|
||||||
|
|
||||||
|
map $http_upgrade $connection_upgrade {
|
||||||
|
default upgrade;
|
||||||
|
'' close;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ingress
|
||||||
|
server {
|
||||||
|
listen 8099 default_server;
|
||||||
|
|
||||||
|
allow 172.30.32.2;
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
server_name _;
|
||||||
|
access_log /dev/stdout combined;
|
||||||
|
|
||||||
|
client_max_body_size 4G;
|
||||||
|
keepalive_timeout 5;
|
||||||
|
|
||||||
|
root /dev/null;
|
||||||
|
|
||||||
|
# The websocket isn't used yet. This is a stub for the future.
|
||||||
|
location /api/websocket {
|
||||||
|
proxy_pass http://localhost:8081;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_pass http://localhost:8080;
|
||||||
|
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,14 +16,9 @@ WAIT_PIDS=()
|
|||||||
# Default QT platform
|
# Default QT platform
|
||||||
PLATFORM="minimal"
|
PLATFORM="minimal"
|
||||||
|
|
||||||
# Load config
|
|
||||||
DECONZ_DEVICE=$(bashio::config 'device')
|
|
||||||
API_PORT=$(bashio::addon.port 80)
|
|
||||||
VNC_PORT=$(bashio::addon.port 5900)
|
|
||||||
VNC_PASSWORD=$(bashio::config 'vnc_password')
|
|
||||||
WEBSOCKET_PORT=$(bashio::addon.port 8080)
|
|
||||||
|
|
||||||
# Lookup udev link
|
# Lookup udev link
|
||||||
|
bashio::log.info "Waiting for device..."
|
||||||
|
DECONZ_DEVICE=$(bashio::config 'device')
|
||||||
if [[ -c "${DECONZ_DEVICE}" ]]; then
|
if [[ -c "${DECONZ_DEVICE}" ]]; then
|
||||||
bashio::log.debug "Specified device points to a character special file, continuing"
|
bashio::log.debug "Specified device points to a character special file, continuing"
|
||||||
else
|
else
|
||||||
@@ -53,32 +48,13 @@ bashio::config.has_value 'dbg_zcl' \
|
|||||||
bashio::config.has_value 'dbg_zdp' \
|
bashio::config.has_value 'dbg_zdp' \
|
||||||
&& DBG_ZDP="$(bashio::config 'dbg_zdp')" || DBG_ZDP=0
|
&& DBG_ZDP="$(bashio::config 'dbg_zdp')" || DBG_ZDP=0
|
||||||
|
|
||||||
# Handle UPNP
|
|
||||||
bashio::config.true 'upnp' \
|
|
||||||
&& UPNP=1 || UPNP=0
|
|
||||||
|
|
||||||
# Check if port is available
|
|
||||||
if bashio::var.is_empty "${API_PORT}" \
|
|
||||||
|| bashio::var.is_empty "${WEBSOCKET_PORT}";
|
|
||||||
then
|
|
||||||
bashio::exit.nok "You need set API and Websocket port!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if VNC is enabled
|
# Check if VNC is enabled
|
||||||
|
VNC_PORT="$(bashio::addon.port 5900)"
|
||||||
if bashio::var.has_value "${VNC_PORT}"; then
|
if bashio::var.has_value "${VNC_PORT}"; then
|
||||||
if [[ "${VNC_PORT}" -lt 5900 ]]; then
|
|
||||||
bashio::exit.nok "VNC requires the port number to be set to 5900 or higher!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if configured VNC port is free
|
|
||||||
if nc -z 127.0.0.1 "${VNC_PORT}"; then
|
|
||||||
bashio::log.fatal "VNC port ${VNC_PORT} is already in use!"
|
|
||||||
bashio::exit.nok "Please change the port number"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TMP_FOLDER=$(mktemp -d)
|
TMP_FOLDER=$(mktemp -d)
|
||||||
export XDG_RUNTIME_DIR="${TMP_FOLDER}"
|
export XDG_RUNTIME_DIR="${TMP_FOLDER}"
|
||||||
export DISPLAY=":$((VNC_PORT-5900))"
|
export DISPLAY=":0"
|
||||||
PLATFORM="xcb"
|
PLATFORM="xcb"
|
||||||
|
|
||||||
# Require password when VNC is enabled
|
# Require password when VNC is enabled
|
||||||
@@ -87,6 +63,7 @@ if bashio::var.has_value "${VNC_PORT}"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
bashio::log.info "Starting VNC server..."
|
bashio::log.info "Starting VNC server..."
|
||||||
|
VNC_PASSWORD=$(bashio::config 'vnc_password')
|
||||||
echo "${VNC_PASSWORD}" | tigervncpasswd -f > /root/.vncpasswd
|
echo "${VNC_PASSWORD}" | tigervncpasswd -f > /root/.vncpasswd
|
||||||
tigervncserver \
|
tigervncserver \
|
||||||
-name "Hass.io - deCONZ" \
|
-name "Hass.io - deCONZ" \
|
||||||
@@ -108,19 +85,19 @@ deCONZ \
|
|||||||
--dbg-otau="${DBG_OTAU}" \
|
--dbg-otau="${DBG_OTAU}" \
|
||||||
--dbg-zcl="${DBG_ZCL}" \
|
--dbg-zcl="${DBG_ZCL}" \
|
||||||
--dbg-zdp="${DBG_ZDP}" \
|
--dbg-zdp="${DBG_ZDP}" \
|
||||||
--http-port="${API_PORT}" \
|
--upnp=0 \
|
||||||
--ws-port="${WEBSOCKET_PORT}" \
|
--http-port=8080 \
|
||||||
--upnp="${UPNP}" \
|
--ws-port=8081 \
|
||||||
--dev="${DECONZ_DEVICE}" &
|
--dev="${DECONZ_DEVICE}" &
|
||||||
WAIT_PIDS+=($!)
|
WAIT_PIDS+=($!)
|
||||||
|
|
||||||
# Start OTA updates for deCONZ
|
# Wait for deCONZ to start before continuing
|
||||||
bashio::log.info "Running the deCONZ OTA updater..."
|
bashio::net.wait_for 8080
|
||||||
deCONZ-otau-dl.sh &> /dev/null &
|
|
||||||
|
|
||||||
# Start OTA updates for IKEA
|
# Start Nginx proxy
|
||||||
bashio::log.info "Running the IKEA OTA updater..."
|
bashio::log.info "Starting Nginx..."
|
||||||
ika-otau-dl.sh &> /dev/null &
|
nginx &
|
||||||
|
WAIT_PIDS+=($!)
|
||||||
|
|
||||||
# Register stop
|
# Register stop
|
||||||
function stop_addon() {
|
function stop_addon() {
|
||||||
@@ -134,7 +111,15 @@ trap "stop_addon" SIGTERM SIGHUP
|
|||||||
|
|
||||||
# Start Hass.io discovery
|
# Start Hass.io discovery
|
||||||
bashio::log.info "Running Hass.io discovery task..."
|
bashio::log.info "Running Hass.io discovery task..."
|
||||||
hassio_discovery
|
hassio_discovery &
|
||||||
|
|
||||||
|
# Start OTA updates for deCONZ
|
||||||
|
bashio::log.info "Running the deCONZ OTA updater..."
|
||||||
|
deCONZ-otau-dl.sh &> /dev/null &
|
||||||
|
|
||||||
|
# Start OTA updates for IKEA
|
||||||
|
bashio::log.info "Running the IKEA OTA updater..."
|
||||||
|
ika-otau-dl.sh &> /dev/null &
|
||||||
|
|
||||||
# Wait until all is done
|
# Wait until all is done
|
||||||
bashio::log.info "deCONZ is set up and running!"
|
bashio::log.info "deCONZ is set up and running!"
|
||||||
|
|||||||
Reference in New Issue
Block a user