Skip to content

Commit

Permalink
Merge pull request #160 from davidusb-geek/davidusb-geek/dev/new_ver_0p7
Browse files Browse the repository at this point in the history
Feat - Prepared new version, see CHANGELOG
  • Loading branch information
davidusb-geek authored Jan 28, 2024
2 parents c0d2adf + e1d5446 commit d9f6bfb
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
36 changes: 22 additions & 14 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"configurations": [
{
"name": "EMHASS run",
"type": "python",
"request": "launch",
"program": "web_server.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/emhass/",
"purpose":["debug-in-terminal"],
"justMyCode": true,
"env": {
"CONFIG_PATH": "/workspaces/emhass/config_emhass.yaml",
"OPTIONS_PATH": "/workspaces/emhass/options.json",
"SECRETS_PATH": "/workspaces/emhass/secrets_emhass.yaml",
"DATA_PATH": "/workspaces/emhass/data/",
}
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "EMHASS run",
"type": "python",
"request": "launch",
"program": "web_server.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src/emhass/",
"purpose":["debug-in-terminal"],
"justMyCode": true,
"env": {
"CONFIG_PATH": "/workspaces/emhass/config_emhass.yaml",
"OPTIONS_PATH": "/workspaces/emhass/options.json",
"SECRETS_PATH": "/workspaces/emhass/secrets_emhass.yaml",
"DATA_PATH": "/workspaces/emhass/data/",
}
},
{
"name": "EMHASS run ADDON",
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [0.7.0] - 2024-01-28
### Improvement
- Added a new feature to provide operating time windows for deferrable loads. Thanks to @michaelpiron
- Added lots of new options to be configured by the user. Thanks to @GeoDerp
- Updated stylesheet with mobile & dark theme by @GeoDerp
- Improved launch.json to fully test EMHASS on different configurations. Thanks to @GeoDerp
- Added new script to debug and develop new time series clustering feature
- Improved documentation. Thanks to @g1za
### Fix
- Updated github workflow actions/checkout to v4 and actions/setup-python to v5
- Changed default values for weight_battery_discharge and weight_battery_charge to zero
- Renamed classes to conform to PEP8
- Bump markupsafe from 2.1.3 to 2.1.4

## [0.6.2] - 2024-01-04
### Improvement
- Added option to pass additional weight for battery usage
Expand Down
4 changes: 2 additions & 2 deletions config_emhass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ optim_conf:
set_battery_dynamic: False # add a constraint to limit the dynamic of the battery power in power per time unit
battery_dynamic_max: 0.9 # maximum dynamic positive power variation in percentage of battery maximum power
battery_dynamic_min: -0.9 # minimum dynamic negative power variation in percentage of battery maximum power
weight_battery_discharge: 1.0 # weight applied in cost function to battery usage for discharge
weight_battery_charge: 1.0 # weight applied in cost function to battery usage for charge
weight_battery_discharge: 0.0 # weight applied in cost function to battery usage for discharge
weight_battery_charge: 0.0 # weight applied in cost function to battery usage for charge

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.6.2'
release = '0.7.0'

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

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
wheel
numpy<=1.26.0
pandas<=2.0.3
scipy<=1.11.3
pandas<=2.0.3
pvlib>=0.10.2
protobuf>=3.0.0
pytz>=2021.1
Expand Down
6 changes: 3 additions & 3 deletions scripts/load_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
pio.renderers.default = 'browser'
pd.options.plotting.backend = "plotly"

from emhass.retrieve_hass import retrieve_hass
from emhass.forecast import forecast
from emhass.retrieve_hass import RetrieveHass
from emhass.forecast import Forecast
from emhass.utils import get_root, get_yaml_parse, get_days_list, get_logger

from sklearn.cluster import KMeans
Expand Down Expand Up @@ -55,7 +55,7 @@
else:
logger.info("Using EMHASS methods to retrieve the new forecast model train data")
retrieve_hass_conf, _, _ = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True)
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger, get_data_from_file=False)

Expand Down
14 changes: 7 additions & 7 deletions scripts/load_forecast_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
pio.renderers.default = 'browser'
pd.options.plotting.backend = "plotly"

from emhass.retrieve_hass import retrieve_hass
from emhass.forecast import forecast
from emhass.retrieve_hass import RetrieveHass
from emhass.forecast import Forecast
from emhass.utils import get_root, get_yaml_parse, get_days_list, get_logger

from sklearn.linear_model import LinearRegression
Expand Down Expand Up @@ -63,7 +63,7 @@ def neg_r2_score(y_true, y_pred):
else:
logger.info("Using EMHASS methods to retrieve the new forecast model train data")
retrieve_hass_conf, _, _ = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True)
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger, get_data_from_file=False)

Expand Down Expand Up @@ -240,14 +240,14 @@ def neg_r2_score(y_true, y_pred):

# Let's perform a naive load forecast for comparison
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True)
fcst = forecast(retrieve_hass_conf, optim_conf, plant_conf,
fcst = Forecast(retrieve_hass_conf, optim_conf, plant_conf,
params, root, logger)
P_load_forecast = fcst.get_load_forecast(method='naive')

# Then retrieve some data and perform a prediction mocking a production env
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger, get_data_from_file=False)
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger, get_data_from_file=False)

days_list = get_days_list(days_needed)
var_model = retrieve_hass_conf['var_load']
Expand Down
16 changes: 8 additions & 8 deletions scripts/optim_results_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
pio.renderers.default = 'browser'
pd.options.plotting.backend = "plotly"

from emhass.retrieve_hass import retrieve_hass
from emhass.optimization import optimization
from emhass.forecast import forecast
from emhass.retrieve_hass import RetrieveHass
from emhass.optimization import Optimization
from emhass.forecast import Forecast
from emhass.utils import get_root, get_yaml_parse, get_days_list, get_logger

# the root folder
Expand All @@ -21,14 +21,14 @@

def get_forecast_optim_objects(retrieve_hass_conf, optim_conf, plant_conf,
params, get_data_from_file):
fcst = forecast(retrieve_hass_conf, optim_conf, plant_conf,
fcst = Forecast(retrieve_hass_conf, optim_conf, plant_conf,
params, root, logger, get_data_from_file=get_data_from_file)
df_weather = fcst.get_weather_forecast(method=optim_conf['weather_forecast_method'])
P_PV_forecast = fcst.get_power_from_weather(df_weather)
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
df_input_data_dayahead.columns = ['P_PV_forecast', 'P_load_forecast']
opt = optimization(retrieve_hass_conf, optim_conf, plant_conf,
opt = Optimization(retrieve_hass_conf, optim_conf, plant_conf,
fcst.var_load_cost, fcst.var_prod_price,
'profit', root, logger)
return fcst, P_PV_forecast, P_load_forecast, df_input_data_dayahead, opt
Expand All @@ -41,9 +41,9 @@ def get_forecast_optim_objects(retrieve_hass_conf, optim_conf, plant_conf,
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'), use_secrets=False)
retrieve_hass_conf, optim_conf, plant_conf = \
retrieve_hass_conf, optim_conf, plant_conf
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
if get_data_from_file:
with open(pathlib.Path(root+'/data/test_df_final.pkl'), 'rb') as inp:
rh.df_final, days_list, var_list = pickle.load(inp)
Expand Down
16 changes: 8 additions & 8 deletions scripts/special_config_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
pio.renderers.default = 'browser'
pd.options.plotting.backend = "plotly"

from emhass.retrieve_hass import retrieve_hass
from emhass.optimization import optimization
from emhass.forecast import forecast
from emhass.retrieve_hass import RetrieveHass
from emhass.optimization import Optimization
from emhass.forecast import Forecast
from emhass.utils import get_root, get_yaml_parse, get_days_list, get_logger

# the root folder
Expand All @@ -31,14 +31,14 @@

def get_forecast_optim_objects(retrieve_hass_conf, optim_conf, plant_conf,
params, get_data_from_file):
fcst = forecast(retrieve_hass_conf, optim_conf, plant_conf,
fcst = Forecast(retrieve_hass_conf, optim_conf, plant_conf,
params, root, logger, get_data_from_file=get_data_from_file)
df_weather = fcst.get_weather_forecast(method='solar.forecast')
P_PV_forecast = fcst.get_power_from_weather(df_weather)
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
df_input_data_dayahead.columns = ['P_PV_forecast', 'P_load_forecast']
opt = optimization(retrieve_hass_conf, optim_conf, plant_conf,
opt = Optimization(retrieve_hass_conf, optim_conf, plant_conf,
fcst.var_load_cost, fcst.var_prod_price,
'cost', root, logger)
return fcst, P_PV_forecast, P_load_forecast, df_input_data_dayahead, opt
Expand Down Expand Up @@ -152,9 +152,9 @@ def build_params(params, options):
else:

retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(config_path, use_secrets=True, params = json.dumps(params))
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
days_list = get_days_list(retrieve_hass_conf['days_to_retrieve'])
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
rh.get_data(days_list, var_list,
Expand Down
16 changes: 8 additions & 8 deletions scripts/use_cases_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
pio.renderers.default = 'browser'
pd.options.plotting.backend = "plotly"

from emhass.retrieve_hass import retrieve_hass
from emhass.optimization import optimization
from emhass.forecast import forecast
from emhass.retrieve_hass import RetrieveHass
from emhass.optimization import Optimization
from emhass.forecast import Forecast
from emhass.utils import get_root, get_yaml_parse, get_days_list, get_logger

# the root folder
Expand All @@ -28,14 +28,14 @@

def get_forecast_optim_objects(retrieve_hass_conf, optim_conf, plant_conf,
params, get_data_from_file):
fcst = forecast(retrieve_hass_conf, optim_conf, plant_conf,
fcst = Forecast(retrieve_hass_conf, optim_conf, plant_conf,
params, root, logger, get_data_from_file=get_data_from_file)
df_weather = fcst.get_weather_forecast(method='solar.forecast')
P_PV_forecast = fcst.get_power_from_weather(df_weather)
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
df_input_data_dayahead = pd.concat([P_PV_forecast, P_load_forecast], axis=1)
df_input_data_dayahead.columns = ['P_PV_forecast', 'P_load_forecast']
opt = optimization(retrieve_hass_conf, optim_conf, plant_conf,
opt = Optimization(retrieve_hass_conf, optim_conf, plant_conf,
fcst.var_load_cost, fcst.var_prod_price,
'profit', root, logger)
return fcst, P_PV_forecast, P_load_forecast, df_input_data_dayahead, opt
Expand All @@ -45,9 +45,9 @@ def get_forecast_optim_objects(retrieve_hass_conf, optim_conf, plant_conf,
params = None
save_figures = False
retrieve_hass_conf, optim_conf, plant_conf = get_yaml_parse(pathlib.Path(root+'/config_emhass.yaml'), use_secrets=True)
rh = retrieve_hass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
rh = RetrieveHass(retrieve_hass_conf['hass_url'], retrieve_hass_conf['long_lived_token'],
retrieve_hass_conf['freq'], retrieve_hass_conf['time_zone'],
params, root, logger)
days_list = get_days_list(retrieve_hass_conf['days_to_retrieve'])
var_list = [retrieve_hass_conf['var_load'], retrieve_hass_conf['var_PV']]
rh.get_data(days_list, var_list,
Expand Down
10 changes: 7 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name='emhass', # Required
version='0.6.2', # Required
version='0.7.0', # 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 All @@ -31,7 +31,7 @@
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
"Operating System :: OS Independent",
],
keywords='energy, management, optimization, hass', # Optional
Expand All @@ -43,15 +43,19 @@
'numpy<=1.26',
'scipy<=1.11.3',
'pandas<=2.0.3',
'pvlib>=0.10.1',
'pvlib>=0.10.2',
'protobuf>=3.0.0',
'pytz>=2021.1',
'requests>=2.25.1',
'beautifulsoup4>=4.9.3',
'h5py==3.10.0',
'pulp>=2.4',
'pyyaml>=5.4.1',
'tables<=3.9.1',
'skforecast==0.11.0',
'flask>=2.0.3',
'waitress>=2.1.1',
'plotly>=5.6.0'
], # Optional
entry_points={ # Optional
'console_scripts': [
Expand Down
Loading

0 comments on commit d9f6bfb

Please sign in to comment.