mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2025-12-19 22:24:15 +01:00
fix addon startup
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -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
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user