diff --git a/nspanel-lovelace-ui/config.yaml b/nspanel-lovelace-ui/config.yaml index 90ecd6e7..01442cbb 100644 --- a/nspanel-lovelace-ui/config.yaml +++ b/nspanel-lovelace-ui/config.yaml @@ -1,8 +1,11 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: NSPanel Lovelace UI Addon -version: "4.7.4" +version: "4.7.11" slug: nspanel-lovelace-ui description: NSPanel Lovelace UI Addon +services: + - "mqtt:want" +homeassistant_api: true url: "https://github.com/joBr99/nspanel-lovelace-ui/tree/main/nspanel-lovelace-ui" arch: - armhf diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/config.yml b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/config.yml.example similarity index 100% rename from nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/config.yml rename to nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/config.yml.example diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py index c5c5a923..02ec4811 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py @@ -59,6 +59,12 @@ def on_message(client, userdata, msg): def get_config(): global settings + + settings["mqtt_username"] = os.getenv('MQTT_USER') + settings["mqtt_password"] = os.getenv('MQTT_PASS') + settings["mqtt_port"] = os.getenv('MQTT_PORT') + settings["mqtt_server"] = os.getenv('MQTT_SERVER') + CONFIG_FILE = os.getenv('CONFIG_FILE') if not CONFIG_FILE: CONFIG_FILE = 'config.yml' diff --git a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh index 46d5b5bd..cd9c38dc 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh @@ -1,10 +1,19 @@ -#!/bin/bash +#!/usr/bin/with-contenv bashio + +if [ -z ${STANDALONE+x} ]; then + export MQTT_USER=$(bashio::services "mqtt" "username") + export MQTT_PASS=$(bashio::services "mqtt" "password") + export MQTT_SERVER=$(bashio::services "mqtt" "host") + export MQTT_PORT=$(bashio::services "mqtt" "port") +else + echo "RUNNING IN STANDALONE MODE" +fi -#echo "All done!" > /share/example_addon_output.txt export CONFIG_FILE=/share/config.yml if test -f "$CONFIG_FILE"; then echo "$CONFIG_FILE exists." else cp /usr/bin/mqtt-manager/config.yml.example $CONFIG_FILE fi -python main.py \ No newline at end of file +sleep 100000 +python /usr/bin/mqtt-manager/main.py \ No newline at end of file