diff --git a/CHANGELOG.md b/CHANGELOG.md index f46a97bb..ec8ef8d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/config_emhass.yaml b/config_emhass.yaml index fb435909..99fe7880 100644 --- a/config_emhass.yaml +++ b/config_emhass.yaml @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 080b7c47..482c875e 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.18' +release = '0.3.19' # -- General configuration --------------------------------------------------- diff --git a/docs/config.md b/docs/config.md index 9d0ff9c3..45db4ece 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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 diff --git a/setup.py b/setup.py index 52c31e51..9683ced1 100644 --- a/setup.py +++ b/setup.py @@ -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) diff --git a/src/emhass/command_line.py b/src/emhass/command_line.py index 40133153..2dce62e4 100644 --- a/src/emhass/command_line.py +++ b/src/emhass/command_line.py @@ -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'], diff --git a/src/emhass/utils.py b/src/emhass/utils.py index 9f4800bb..ecfc4796 100644 --- a/src/emhass/utils.py +++ b/src/emhass/utils.py @@ -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]: diff --git a/src/emhass/web_server.py b/src/emhass/web_server.py index d1ff39b9..f0b7da13 100644 --- a/src/emhass/web_server.py +++ b/src/emhass/web_server.py @@ -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') @@ -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" @@ -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'] diff --git a/tests/test_command_line_utils.py b/tests/test_command_line_utils.py index 5f20ed1a..a8499952 100644 --- a/tests/test_command_line_utils.py +++ b/tests/test_command_line_utils.py @@ -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) @@ -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) @@ -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) @@ -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)