Add hook up with the MQTT service

This commit is contained in:
Franck Nijhof 2020-02-16 10:57:04 +01:00
parent 87e9e3695a
commit e7bb759397
No known key found for this signature in database
GPG key ID: D62583BA8AB11CA3
2 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,29 @@
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Home Assistant Community Add-on: Visual Studio Code
# Pre-configures the Mosquitto clients, if the service is available
# ==============================================================================
declare host
declare password
declare port
declare username
host=$(bashio::services "mqtt" "host")
if bashio::var.has_value "${host}"; then
password=$(bashio::services "mqtt" "password")
port=$(bashio::services "mqtt" "port")
username=$(bashio::services "mqtt" "username")
mkdir -p /root/.config
{
echo "-h ${host}"
echo "--pw ${password}"
echo "--port ${port}"
echo "--username ${username}"
} > /root/.config/mosquitto_sub
ln -s /root/.config/mosquitto_sub /root/.config/mosquitto_pub
ln -s /root/.config/mosquitto_sub /root/.config/mosquitto_rr
else
bashio::log.info "The above error can be ignored if you don't have Mosquitto installed"
fi