From df865371248b1349cb5c9c098f27e010dda38910 Mon Sep 17 00:00:00 2001 From: davidusb-geek Date: Sun, 28 May 2023 00:16:21 +0200 Subject: [PATCH] Fix - Added possibility to set logging level and prepared new version --- CHANGELOG.md | 1 + docs/conf.py | 2 +- setup.py | 2 +- src/emhass/templates/index.html | 2 +- src/emhass/web_server.py | 31 ++++++++++++++++++++++++------- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8f00f5..56709b27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Added new constraint to avoid battery discharging to the grid ### Fix - Bumped version of skforecast from 0.6.0 to 0.8.0. Doing this mainly implies changing how the exogenous data is passed to fit and predict methods. +- Fixed wrong path for csv files when using load cost and prod price forecasts. ## [0.4.10] - 2023-05-21 ### Fix diff --git a/docs/conf.py b/docs/conf.py index 1cb9dd18..4e274160 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -22,7 +22,7 @@ author = 'David HERNANDEZ' # The full version, including alpha/beta/rc tags -release = '0.4.10' +release = '0.4.11' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 06eae04d..9a69be18 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='emhass', # Required - version='0.4.10', # Required + version='0.4.11', # Required description='An Energy Management System for Home Assistant', # Optional long_description=long_description, # Optional long_description_content_type='text/markdown', # Optional (see note above) diff --git a/src/emhass/templates/index.html b/src/emhass/templates/index.html index c53da466..03587c94 100644 --- a/src/emhass/templates/index.html +++ b/src/emhass/templates/index.html @@ -22,7 +22,7 @@

Use the buttons below to fit - < diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index 15704be7..4f282637 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -17,15 +17,8 @@ from emhass.command_line import forecast_model_fit, forecast_model_predict, forecast_model_tune from emhass.command_line import publish_data - # Define the Flask instance app = Flask(__name__) -app.logger.setLevel(logging.DEBUG) -app.logger.propagate = False -ch = logging.StreamHandler() -formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') -ch.setFormatter(formatter) -app.logger.addHandler(ch) def get_injection_dict(df, plot_size = 1366): # Create plots @@ -301,6 +294,7 @@ def action_call(action_name): # The cost function costfun = options['costfun'] # Some data from options + logging_level = options['logging_level'] url_from_options = options['hass_url'] if url_from_options == 'empty': url = hass_url+"/config" @@ -328,6 +322,7 @@ def action_call(action_name): } else: costfun = os.getenv('LOCAL_COSTFUN', default='profit') + logging_level = os.getenv('LOGGING_LEVEL', default='INFO') with open('/app/secrets_emhass.yaml', 'r') as file: params_secrets = yaml.load(file, Loader=yaml.FullLoader) hass_url = params_secrets['hass_url'] @@ -337,6 +332,28 @@ def action_call(action_name): with open(str(data_path / 'params.pkl'), "wb") as fid: pickle.dump((config_path, params), fid) + # Define logger + ch = logging.StreamHandler() + formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') + ch.setFormatter(formatter) + if logging_level == "DEBUG": + app.logger.setLevel(logging.DEBUG) + ch.setLevel(logging.DEBUG) + elif logging_level == "INFO": + app.logger.setLevel(logging.INFO) + ch.setLevel(logging.INFO) + elif logging_level == "WARNING": + app.logger.setLevel(logging.WARNING) + ch.setLevel(logging.WARNING) + elif logging_level == "ERROR": + app.logger.setLevel(logging.ERROR) + ch.setLevel(logging.ERROR) + else: + app.logger.setLevel(logging.DEBUG) + ch.setLevel(logging.DEBUG) + app.logger.propagate = False + app.logger.addHandler(ch) + # Launch server port = int(os.environ.get('PORT', 5000)) app.logger.info("Launching the emhass webserver at: http://"+web_ui_url+":"+str(port))