From f16ea9d8cefd78a7d5717792c8331007367660a3 Mon Sep 17 00:00:00 2001 From: GeoDerp <18461782+GeoDerp@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:05:45 +0000 Subject: [PATCH 1/3] possible data path and addon arg fix --- src/emhass/web_server.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index 1b5bbe5e..f7b74dbf 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -318,9 +318,9 @@ def action_call(action_name): args = parser.parse_args() # Define the paths - DATA_PATH = os.getenv("DATA_PATH", default="/app/data/") + DATA_PATH = os.getenv("DATA_PATH", default="/data/") data_path = Path(DATA_PATH) - if args.addon: + if args.addon==1: OPTIONS_PATH = os.getenv('OPTIONS_PATH', default=data_path / "options.json") options_json = Path(OPTIONS_PATH) CONFIG_PATH = os.getenv("CONFIG_PATH", default="/usr/src/config_emhass.yaml") @@ -333,11 +333,10 @@ def action_call(action_name): else: app.logger.error("options.json does not exists") - DATA_PATH = "/share/" #"/data/" else: - CONFIG_PATH = os.getenv("CONFIG_PATH", default="/app/config_emhass.yaml") + CONFIG_PATH = os.getenv("CONFIG_PATH", default="/config_emhass.yaml") options = None - DATA_PATH = os.getenv("DATA_PATH", default="/app/data/") + DATA_PATH = os.getenv("DATA_PATH", default="/data/") config_path = Path(CONFIG_PATH) @@ -398,14 +397,14 @@ def action_call(action_name): 'alt': config_hass['elevation'] } except: #if addon testing (use secrets) - with open(os.getenv('SECRETS_PATH', default='/app/secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) params_secrets['hass_url'] = hass_url params_secrets['long_lived_token'] = long_lived_token else: costfun = os.getenv('LOCAL_COSTFUN', default='profit') logging_level = os.getenv('LOGGING_LEVEL', default='INFO') - with open(os.getenv('SECRETS_PATH', default='/app/secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) hass_url = params_secrets['hass_url'] From 4bc072f3a051bc8695f086ef829cf6a53467be56 Mon Sep 17 00:00:00 2001 From: GeoDerp <18461782+GeoDerp@users.noreply.github.com> Date: Mon, 29 Jan 2024 09:11:09 +0000 Subject: [PATCH 2/3] modified: src/emhass/web_server.py --- src/emhass/web_server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index f7b74dbf..7d782985 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -397,14 +397,14 @@ def action_call(action_name): 'alt': config_hass['elevation'] } except: #if addon testing (use secrets) - with open(os.getenv('SECRETS_PATH', default='secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='/secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) params_secrets['hass_url'] = hass_url params_secrets['long_lived_token'] = long_lived_token else: costfun = os.getenv('LOCAL_COSTFUN', default='profit') logging_level = os.getenv('LOGGING_LEVEL', default='INFO') - with open(os.getenv('SECRETS_PATH', default='secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='/secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) hass_url = params_secrets['hass_url'] From d6e12e70aee19bbe136b414d88b3304e1132d8e6 Mon Sep 17 00:00:00 2001 From: GeoDerp <18461782+GeoDerp@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:33:19 +0000 Subject: [PATCH 3/3] reverted /app change --- src/emhass/web_server.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index 7d782985..c810c886 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -318,12 +318,12 @@ def action_call(action_name): args = parser.parse_args() # Define the paths - DATA_PATH = os.getenv("DATA_PATH", default="/data/") + DATA_PATH = os.getenv("DATA_PATH", default="/app/data/") data_path = Path(DATA_PATH) if args.addon==1: OPTIONS_PATH = os.getenv('OPTIONS_PATH', default=data_path / "options.json") options_json = Path(OPTIONS_PATH) - CONFIG_PATH = os.getenv("CONFIG_PATH", default="/usr/src/config_emhass.yaml") + CONFIG_PATH = os.getenv("CONFIG_PATH", default="/app/config_emhass.yaml") hass_url = args.url key = args.key # Read options info @@ -332,11 +332,12 @@ def action_call(action_name): options = json.load(data) else: app.logger.error("options.json does not exists") - + + DATA_PATH = "/share/" #"/data/" else: - CONFIG_PATH = os.getenv("CONFIG_PATH", default="/config_emhass.yaml") + CONFIG_PATH = os.getenv("CONFIG_PATH", default="/app/config_emhass.yaml") options = None - DATA_PATH = os.getenv("DATA_PATH", default="/data/") + DATA_PATH = os.getenv("DATA_PATH", default="/app/data/") config_path = Path(CONFIG_PATH) @@ -397,14 +398,14 @@ def action_call(action_name): 'alt': config_hass['elevation'] } except: #if addon testing (use secrets) - with open(os.getenv('SECRETS_PATH', default='/secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='/app/secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) params_secrets['hass_url'] = hass_url params_secrets['long_lived_token'] = long_lived_token else: costfun = os.getenv('LOCAL_COSTFUN', default='profit') logging_level = os.getenv('LOGGING_LEVEL', default='INFO') - with open(os.getenv('SECRETS_PATH', default='/secrets_emhass.yaml'), 'r') as file: + with open(os.getenv('SECRETS_PATH', default='/app/secrets_emhass.yaml'), 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) hass_url = params_secrets['hass_url']