Files
addons/zwave/rootfs/etc/cont-init.d/mqtt.sh
Pascal Vizeli 9e18140dd6 Add support for new openzwave (#1273)
* Add support for new openzwave

* Fix pipeline

* fix log output

* Support auth / discovery

* Add basic structs

* fix lint

* Fix start order
2020-05-07 14:12:27 +02:00

38 lines
1.1 KiB
Bash

#!/usr/bin/with-contenv bashio
# ==============================================================================
# Setup mqtt settings
# ==============================================================================
declare host
declare password
declare port
declare username
if ! bashio::services.available "mqtt"; then
bashio::log.info "No internal MqTT service found"
else
host=$(bashio::services "mqtt" "host")
password=$(bashio::services "mqtt" "password")
port=$(bashio::services "mqtt" "port")
username=$(bashio::services "mqtt" "username")
(
echo "connection main-mqtt"
echo "address ${host}:${port}"
) >> /etc/mosquitto.conf
# Need auth?
if bashio::var.has_value "${username}" && bashio::var.has_value "${password}"; then
(
echo "username ${username}"
echo "password ${password}"
) >> /etc/mosquitto.conf
fi
(
echo "topic OpenZWave/# out"
echo "topic # IN OpenZWave/"
) >> /etc/mosquitto.conf
bashio::log.info "Connect to internal MqTT service"
fi