mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 05:04:21 +01:00
OpenZWave 0.5.2 (#1489)
* OpenZWave 0.5.2 * Fix typo in code comment * LTW -> LWT * Convert mosquitto.conf dos2unix * Add additional MQTT bridge settings * Change client name to match add-on slug * Extract MQTT logic into a helper * Disable shellcheck SC1091
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 0.5.2
|
||||
|
||||
- Fix startup failure due to stray OZW Daemon status retained in MQTT
|
||||
- Propagate shutdown OZW Daemon status to upstream MQTT on shutdown
|
||||
- Update OpenZWave to 6cf3729
|
||||
|
||||
## 0.5.1
|
||||
|
||||
- Roll-back alpine to 3.11 and qt 5.12
|
||||
|
||||
@@ -16,6 +16,7 @@ RUN \
|
||||
eudev-libs \
|
||||
fontconfig \
|
||||
mosquitto \
|
||||
mosquitto-clients \
|
||||
openssl \
|
||||
pwgen \
|
||||
qt5-qtbase \
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
"aarch64": "homeassistant/aarch64-base:3.11"
|
||||
},
|
||||
"args": {
|
||||
"OZW_VERSION": "6c2ca6131cbba4200460256293d719053107a9e8",
|
||||
"OZW_VERSION": "6cf372959ee88baabfe68742297e7b13f57fef14",
|
||||
"QTOZW_VERSION": "3ad9138f40a856366a7d85fb110b1ed91e1534a0",
|
||||
"QTOZWADMIN_VERSION": "da04ebfbadc57484c487ebc846431eb283e83176",
|
||||
"QTMQTT_VERSION": "5.12.8",
|
||||
"QTWEBSOCKETS_VERSION": "5.12.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
{
|
||||
"name": "OpenZWave",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"slug": "zwave",
|
||||
"description": "Control a ZWave network with Home Assistant",
|
||||
"arch": [
|
||||
"amd64",
|
||||
"i386",
|
||||
"armhf",
|
||||
"armv7",
|
||||
"aarch64"
|
||||
],
|
||||
"arch": ["amd64", "i386", "armhf", "armv7", "aarch64"],
|
||||
"url": "https://github.com/home-assistant/hassio-addons/tree/master/zwave",
|
||||
"ingress": true,
|
||||
"ingress_entry": "vnc_lite.html",
|
||||
@@ -28,22 +22,13 @@
|
||||
"1983/tcp": "ozw-admin port",
|
||||
"5900/tcp": "VNC port"
|
||||
},
|
||||
"services": [
|
||||
"mqtt:want"
|
||||
],
|
||||
"discovery": [
|
||||
"ozw"
|
||||
],
|
||||
"services": ["mqtt:want"],
|
||||
"discovery": ["ozw"],
|
||||
"auto_uart": true,
|
||||
"gpio": true,
|
||||
"apparmor": false,
|
||||
"privileged": [
|
||||
"SYS_RAWIO"
|
||||
],
|
||||
"devices": [
|
||||
"/dev/bus/usb:/dev/bus/usb:rwm",
|
||||
"/dev/mem:/dev/mem:rw"
|
||||
],
|
||||
"privileged": ["SYS_RAWIO"],
|
||||
"devices": ["/dev/bus/usb:/dev/bus/usb:rwm", "/dev/mem:/dev/mem:rw"],
|
||||
"options": {
|
||||
"device": null,
|
||||
"network_key": ""
|
||||
@@ -54,4 +39,4 @@
|
||||
"instance": "int(1,)?"
|
||||
},
|
||||
"image": "homeassistant/{arch}-addon-zwave"
|
||||
}
|
||||
}
|
||||
|
||||
22
zwave/rootfs/etc/cont-finish.d/mqtt.sh
Normal file
22
zwave/rootfs/etc/cont-finish.d/mqtt.sh
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Ensure upstream MQTT server has the correct OZW status retained on shutdown.
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/mqtt_helper.sh
|
||||
|
||||
declare host
|
||||
declare password
|
||||
declare port
|
||||
declare username
|
||||
|
||||
if bashio::services.available "mqtt"; then
|
||||
bashio::log.info "Ensure upstream MQTT server has the correct OZW status"
|
||||
host=$(bashio::services "mqtt" "host")
|
||||
password=$(bashio::services "mqtt" "password")
|
||||
port=$(bashio::services "mqtt" "port")
|
||||
username=$(bashio::services "mqtt" "username")
|
||||
|
||||
mqtt::ensure_ozw_offline_status \
|
||||
"${host}" "${port}" "${username}" "${password}"
|
||||
fi
|
||||
@@ -1,7 +1,10 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Setup mqtt settings
|
||||
# Setup MQTT settings
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/mqtt_helper.sh
|
||||
|
||||
declare host
|
||||
declare password
|
||||
declare port
|
||||
@@ -18,6 +21,11 @@ else
|
||||
(
|
||||
echo "connection main-mqtt"
|
||||
echo "address ${host}:${port}"
|
||||
echo "remote_clientid zwave"
|
||||
echo "local_clientid zwave"
|
||||
echo "cleansession true"
|
||||
echo "notifications true"
|
||||
echo "try_private true"
|
||||
) >> /etc/mosquitto.conf
|
||||
|
||||
# Need auth?
|
||||
@@ -33,5 +41,13 @@ else
|
||||
echo "topic # IN OpenZWave/"
|
||||
) >> /etc/mosquitto.conf
|
||||
|
||||
bashio::log.info "Connect to internal MqTT service"
|
||||
# Ensure upstream MQTT server has the right OZW status
|
||||
# Workaround for an incorrect retained OZW status in MQTT
|
||||
# In this case, the LWT is not relayed to the upstream MQTT server.
|
||||
# https://github.com/home-assistant/hassio-addons/issues/1462
|
||||
mqtt::ensure_ozw_offline_status \
|
||||
"${host}" "${port}" "${username}" "${password}"
|
||||
|
||||
|
||||
bashio::log.info "Connected to internal MQTT service"
|
||||
fi
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
##
|
||||
# defaults
|
||||
listener 1883
|
||||
user root
|
||||
|
||||
##
|
||||
# logging
|
||||
log_dest stdout
|
||||
|
||||
##
|
||||
# datastore
|
||||
persistence true
|
||||
persistence_location /data/
|
||||
|
||||
##
|
||||
# auth
|
||||
allow_anonymous false
|
||||
password_file /data/auth.db
|
||||
|
||||
# Dynamic config
|
||||
##
|
||||
# defaults
|
||||
listener 1883
|
||||
user root
|
||||
|
||||
##
|
||||
# logging
|
||||
log_dest stdout
|
||||
|
||||
##
|
||||
# datastore
|
||||
persistence true
|
||||
persistence_location /data/
|
||||
|
||||
##
|
||||
# auth
|
||||
allow_anonymous false
|
||||
password_file /data/auth.db
|
||||
|
||||
# Dynamic config
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
# ==============================================================================
|
||||
# Start OpenZWave service for zwave radio
|
||||
# ==============================================================================
|
||||
# shellcheck disable=SC1091
|
||||
source /usr/lib/mqtt_helper.sh
|
||||
|
||||
export MQTT_PASSWORD
|
||||
export OZW_NETWORK_KEY
|
||||
|
||||
@@ -20,6 +23,12 @@ fi
|
||||
bashio::log.info "Starting OpenZWave..."
|
||||
bashio::net.wait_for 1883
|
||||
|
||||
# Ensure local MQTT server has the right OZW status
|
||||
# Workaround for an incorrect retained OZW status in MQTT
|
||||
# https://github.com/home-assistant/hassio-addons/issues/1462
|
||||
mqtt::ensure_ozw_offline_status \
|
||||
127.0.0.1 1883 ozw "${MQTT_PASSWORD}" "${OZW_INSTANCE}"
|
||||
|
||||
# Send out discovery information to Home Assistant
|
||||
./discovery &
|
||||
|
||||
|
||||
56
zwave/rootfs/usr/lib/mqtt_helper.sh
Normal file
56
zwave/rootfs/usr/lib/mqtt_helper.sh
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# MQTT helpers for the zwave add-on.
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Ensure upstream MQTT server has the correct OZW status retained on shutdown.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 MQTT Server host
|
||||
# $2 MQTT Server port
|
||||
# $3 MQTT Server username
|
||||
# $4 MQTT Server password
|
||||
# $5 OZW Instance ID (optional)
|
||||
# ------------------------------------------------------------------------------
|
||||
function mqtt::ensure_ozw_offline_status() {
|
||||
local host=${1}
|
||||
local port=${2}
|
||||
local username=${3}
|
||||
local password=${4}
|
||||
local ozw_instance=${5:-}
|
||||
local ozw_status
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}:" "$@"
|
||||
|
||||
if ! bashio::var.has_value "${ozw_instance}"; then
|
||||
ozw_instance=1
|
||||
if bashio::config.has_value 'instance'; then
|
||||
ozw_instance=$(bashio::config 'instance')
|
||||
fi
|
||||
fi
|
||||
|
||||
ozw_status=$(\
|
||||
mosquitto_sub \
|
||||
--host "${host}" \
|
||||
--port "${port}" \
|
||||
--username "${username}" \
|
||||
--pw "${password}" \
|
||||
-C 1 \
|
||||
-W 3 \
|
||||
--retained-only \
|
||||
--topic "OpenZWave/${ozw_instance}/status/" \
|
||||
)
|
||||
if bashio::var.has_value "${ozw_status}" \
|
||||
&& [[ $(bashio::jq "${ozw_status}" ".Status") != "Offline" ]];
|
||||
then
|
||||
mosquitto_pub \
|
||||
--host "${host}" \
|
||||
--port "${port}" \
|
||||
--username "${username}" \
|
||||
--pw "${password}" \
|
||||
--retain \
|
||||
--topic "OpenZWave/${ozw_instance}/status/" \
|
||||
--message "$(bashio::var.json "Status" "Offline")"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user