diff --git a/.gitignore b/.gitignore index bbcc3968..886a9c86 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,8 @@ __pycache__/ # don't add nextion2text HMI/Nextion2Text.py +# dont add config.yml +config.yml + # don't add Webstorm project stuff .idea \ No newline at end of file diff --git a/nspanel-lovelace-ui/config.yaml b/nspanel-lovelace-ui/config.yaml index 361d7298..385c9105 100644 --- a/nspanel-lovelace-ui/config.yaml +++ b/nspanel-lovelace-ui/config.yaml @@ -1,6 +1,6 @@ # https://developers.home-assistant.io/docs/add-ons/configuration#add-on-config name: NSPanel Lovelace UI Addon -version: "4.7.12" +version: "4.7.14" slug: nspanel-lovelace-ui description: NSPanel Lovelace UI Addon services: 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 02ec4811..d750e7f5 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/main.py @@ -10,6 +10,7 @@ import yaml from uuid import getnode as get_mac from panel import LovelaceUIPanel import os +import environ settings = {} panels = {} @@ -60,11 +61,6 @@ 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' @@ -72,6 +68,21 @@ def get_config(): settings = yaml.safe_load(file) + environment = environ.Env() + if not settings.get("mqtt_username"): + settings["mqtt_username"] = environment('MQTT_USER') + if not settings.get("mqtt_password"): + settings["mqtt_password"] = environment('MQTT_PASS') + if not settings.get("mqtt_port"): + settings["mqtt_port"] = environment('MQTT_PORT') + if not settings.get("mqtt_server"): + settings["mqtt_server"] = environment('MQTT_SERVER') + + if "SUPERVISOR_TOKEN" in environment: + settings["home_assistant_token"] = environment('SUPERVISOR_TOKEN') + settings["home_assistant_address"] = "http://supervisor" + + def connect_and_loop(): global settings, home_assistant client.on_connect = on_connect 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 461ee591..aa1e0d47 100644 --- a/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh +++ b/nspanel-lovelace-ui/rootfs/usr/bin/mqtt-manager/run.sh @@ -8,7 +8,6 @@ if [ -z ${STANDALONE+x} ]; then else echo "RUNNING IN STANDALONE MODE" fi - export CONFIG_FILE=/share/config.yml if test -f "$CONFIG_FILE"; then echo "$CONFIG_FILE exists."