mirror of
https://github.com/aljazceru/addons.git
synced 2026-01-29 17:56:17 +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:
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 &
|
||||
|
||||
|
||||
Reference in New Issue
Block a user