From c207cf96f280929f373e7c3d3264c7b45f15ec4d Mon Sep 17 00:00:00 2001 From: davidusb-geek Date: Tue, 31 Jan 2023 09:27:11 +0100 Subject: [PATCH] Fix - Fixed access to injection_dict for the first time that emhass is used --- CHANGELOG.md | 4 ++++ docs/conf.py | 2 +- setup.py | 2 +- src/emhass/web_server.py | 10 +++++----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b13f3329..2e2afb27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.3.35] - 2023-01-31 +### Fix +- Fixed access to injection_dict for the first time that emhass is used. + ## [0.3.34] - 2023-01-30 ### Fix - Fixed bugs with paths again, now using the official pathlib everywhere. diff --git a/docs/conf.py b/docs/conf.py index 85c99429..76241ab9 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.3.34' +release = '0.3.35' # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index 7878c051..ab6da537 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ setup( name='emhass', # Required - version='0.3.34', # Required + version='0.3.35', # 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/web_server.py b/src/emhass/web_server.py index dae2f7bf..0bad35c9 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -116,12 +116,12 @@ def index(): file_loader = PackageLoader('emhass', 'templates') env = Environment(loader=file_loader) template = env.get_template('index.html') - # template = render_template('index.html') # Load cache dict - with open(str(data_path / 'injection_dict.pkl'), "rb") as fid: - injection_dict = pickle.load(fid) - if injection_dict is None: - app.logger.warning("Oops.. The data dictionary is empty... Please launch an optimization task") + if (data_path / 'injection_dict.pkl').exists(): + with open(str(data_path / 'injection_dict.pkl'), "rb") as fid: + injection_dict = pickle.load(fid) + else: + app.logger.warning("The data container dictionary is empty... Please launch an optimization task") injection_dict={} return make_response(template.render(injection_dict=injection_dict))