Skip to content

Commit

Permalink
Fix - Small fixes, see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
davidusb-geek committed Sep 14, 2022
1 parent 16b8edb commit 956f033
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.3.19] - 2022-09-14
### Fix
- Updated default values for a working LP solver.
- Removed option to provide a custom web ui url.
- Added extra runtime parameters to use solcast PV forecast.

## [0.3.18] - 2022-08-27
### Improvement
- Improving documentation, added more information on forecast page.
Expand Down
4 changes: 2 additions & 2 deletions config_emhass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ optim_conf:
- prod_price_forecast_method: 'constant' # options are 'constant' for constant fixed value or 'csv' to load custom price forecast from a CSV file
- prod_sell_price: 0.065 # power production selling price in €/kWh (only needed if prod_price_forecast_method='constant')
- set_total_pv_sell: False # consider that all PV power is injected to the grid (self-consumption with total sell)
- lp_solver: 'PULP_CBC_CMD' # set the name of the linear programming solver that will be used
- lp_solver_path: 'empty' # set the path to the LP solver
- lp_solver: 'COIN_CMD' # set the name of the linear programming solver that will be used
- lp_solver_path: '/usr/bin/cbc' # set the path to the LP solver

plant_conf:
- P_grid_max: 9000 # The maximum power that can be supplied by the utility grid in Watts
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'David HERNANDEZ'

# The full version, including alpha/beta/rc tags
release = '0.3.18'
release = '0.3.19'

# -- General configuration ---------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ The following parameters and definitions are only needed if load_cost_forecast_m

- prod_price_forecast_method: Define the method that will be used for PV power production price forecast. This is the price that is payed by the utility for energy injected to the grid. The options are 'constant' for a constant fixed value or 'csv' to load custom price forecast from a CSV file. The default CSV file path that will be used is '/data/data_prod_price_forecast.csv'.
- prod_sell_price: The paid price for energy injected to the grid from excedent PV production in €/kWh. Defaults to 0.065. This parameter is only needed if prod_price_forecast_method='constant'.
- lp_solver: Set the name of the linear programming solver that will be used. Defaults to 'PULP_CBC_CMD'. The options are 'PULP_CBC_CMD', 'GLPK_CMD' and 'COIN_CMD'.
- lp_solver_path: Set the path to the LP solver. Defaults to 'empty. If using 'COIN_CMD' as the solver you will need to provide the correct path to this solver, ex: '/usr/bin/cbc'.
- lp_solver: Set the name of the linear programming solver that will be used. Defaults to 'COIN_CMD'. The options are 'PULP_CBC_CMD', 'GLPK_CMD' and 'COIN_CMD'.
- lp_solver_path: Set the path to the LP solver. Defaults to '/usr/bin/cbc'.

## System configuration parameters

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='emhass', # Required
version='0.3.18', # Required
version='0.3.19', # 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)
Expand Down
5 changes: 3 additions & 2 deletions src/emhass/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def set_input_data_dict(config_path: pathlib.Path, base_path: str, costfun: str,
# Parsing yaml
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(config_path, params=params)
# Treat runtimeparams
params, optim_conf = utils.treat_runtimeparams(runtimeparams, params, retrieve_hass_conf,
optim_conf, plant_conf, set_type, logger)
params, retrieve_hass_conf, optim_conf = utils.treat_runtimeparams(
runtimeparams, params, retrieve_hass_conf,
optim_conf, plant_conf, set_type, logger)
# Define main objects
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
Expand Down
6 changes: 5 additions & 1 deletion src/emhass/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ def treat_runtimeparams(runtimeparams: str, params:str, retrieve_hass_conf: dict
optim_conf['treat_def_as_semi_cont'] = runtimeparams['treat_def_as_semi_cont']
if 'set_def_constant' in runtimeparams.keys():
optim_conf['set_def_constant'] = runtimeparams['set_def_constant']
if 'solcast_api_key' in runtimeparams.keys():
retrieve_hass_conf['solcast_api_key'] = runtimeparams['solcast_api_key']
if 'solcast_rooftop_id' in runtimeparams.keys():
retrieve_hass_conf['solcast_rooftop_id'] = runtimeparams['solcast_rooftop_id']
params = json.dumps(params)
return params, optim_conf
return params, retrieve_hass_conf, optim_conf

def get_yaml_parse(config_path: str, use_secrets: Optional[bool] = True,
params: Optional[str] = None) -> Tuple[dict, dict, dict]:
Expand Down
3 changes: 1 addition & 2 deletions src/emhass/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def action_call(action_name):
params['retrieve_hass_conf'] = retrieve_hass_conf
params['optim_conf'] = optim_conf
params['plant_conf'] = plant_conf
web_ui_url = '0.0.0.0'

# Initialize this global dict
opt_res = pd.read_csv(base_path+'/data/opt_res_latest.csv', index_col='timestamp')
Expand All @@ -221,7 +222,6 @@ def action_call(action_name):
# The cost function
costfun = options['costfun']
# Some data from options
web_ui_url = options['web_ui_url']
url_from_options = options['hass_url']
if url_from_options == 'empty':
url = hass_url+"/config"
Expand Down Expand Up @@ -249,7 +249,6 @@ def action_call(action_name):
}
else:
costfun = os.getenv('LOCAL_COSTFUN', default='profit')
web_ui_url = '0.0.0.0'
with open('/app/secrets_emhass.yaml', 'r') as file:
params_secrets = yaml.load(file, Loader=yaml.FullLoader)
hass_url = params_secrets['hass_url']
Expand Down
20 changes: 12 additions & 8 deletions tests/test_command_line_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def test_treat_runtimeparams(self):
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(
pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True, params=self.params_json)
set_type = 'dayahead-optim'
params, optim_conf = utils.treat_runtimeparams(self.runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
params, retrieve_hass_conf, optim_conf = utils.treat_runtimeparams(
self.runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
self.assertIsInstance(params, str)
params = json.loads(params)
self.assertIsInstance(params['passed_data']['pv_power_forecast'], list)
Expand All @@ -78,8 +79,9 @@ def test_treat_runtimeparams(self):
self.assertTrue(optim_conf['load_cost_forecast_method'] == 'list')
self.assertTrue(optim_conf['prod_price_forecast_method'] == 'list')
set_type = 'naive-mpc-optim'
params, optim_conf = utils.treat_runtimeparams(self.runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
params, retrieve_hass_conf, optim_conf = utils.treat_runtimeparams(
self.runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
self.assertIsInstance(params, str)
params = json.loads(params)
self.assertTrue(params['passed_data']['prediction_horizon'] == 10)
Expand All @@ -90,8 +92,9 @@ def test_treat_runtimeparams(self):
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(
pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True, params=self.params_json)
params = json.dumps(None)
params, optim_conf = utils.treat_runtimeparams(self.runtimeparams_json, params,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
params, retrieve_hass_conf, optim_conf = utils.treat_runtimeparams(
self.runtimeparams_json, params,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
self.assertIsInstance(params, str)
params = json.loads(params)
self.assertIsInstance(params['passed_data']['pv_power_forecast'], list)
Expand All @@ -113,8 +116,9 @@ def test_treat_runtimeparams(self):
retrieve_hass_conf, optim_conf, plant_conf = utils.get_yaml_parse(
pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True, params=self.params_json)
set_type = 'dayahead-optim'
params, optim_conf = utils.treat_runtimeparams(runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
params, retrieve_hass_conf, optim_conf = utils.treat_runtimeparams(
runtimeparams_json, self.params_json,
retrieve_hass_conf, optim_conf, plant_conf, set_type, logger)
self.assertIsInstance(params, str)
params = json.loads(params)
self.assertIsInstance(params['passed_data']['pv_power_forecast'], list)
Expand Down

0 comments on commit 956f033

Please sign in to comment.