emhass 0.8.1__tar.gz → 0.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {emhass-0.8.1 → emhass-0.8.2}/CHANGELOG.md +12 -0
  2. {emhass-0.8.1 → emhass-0.8.2}/PKG-INFO +30 -24
  3. {emhass-0.8.1 → emhass-0.8.2}/README.md +27 -21
  4. {emhass-0.8.1 → emhass-0.8.2}/setup.py +5 -5
  5. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/forecast.py +3 -3
  6. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/optimization.py +3 -0
  7. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/retrieve_hass.py +1 -1
  8. emhass-0.8.2/src/emhass/static/advanced.html +32 -0
  9. emhass-0.8.2/src/emhass/static/basic.html +12 -0
  10. emhass-0.8.2/src/emhass/static/img/feather-sprite.svg +1 -0
  11. emhass-0.8.2/src/emhass/static/script.js +425 -0
  12. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/static/style.css +132 -23
  13. emhass-0.8.2/src/emhass/templates/index.html +70 -0
  14. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/templates/template.html +1 -0
  15. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/web_server.py +63 -19
  16. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/PKG-INFO +30 -24
  17. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/SOURCES.txt +4 -1
  18. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/requires.txt +2 -2
  19. emhass-0.8.1/data/logger_emhass.log +0 -198
  20. emhass-0.8.1/src/emhass/templates/index.html +0 -374
  21. {emhass-0.8.1 → emhass-0.8.2}/CODE_OF_CONDUCT.md +0 -0
  22. {emhass-0.8.1 → emhass-0.8.2}/CONTRIBUTING.md +0 -0
  23. {emhass-0.8.1 → emhass-0.8.2}/LICENSE +0 -0
  24. {emhass-0.8.1 → emhass-0.8.2}/MANIFEST.in +0 -0
  25. {emhass-0.8.1 → emhass-0.8.2}/data/data_load_cost_forecast.csv +0 -0
  26. {emhass-0.8.1 → emhass-0.8.2}/data/data_load_forecast.csv +0 -0
  27. {emhass-0.8.1 → emhass-0.8.2}/data/data_prod_price_forecast.csv +0 -0
  28. {emhass-0.8.1 → emhass-0.8.2}/data/data_train_load_clustering.pkl +0 -0
  29. {emhass-0.8.1 → emhass-0.8.2}/data/data_train_load_forecast.pkl +0 -0
  30. {emhass-0.8.1 → emhass-0.8.2}/data/data_weather_forecast.csv +0 -0
  31. {emhass-0.8.1 → emhass-0.8.2}/data/opt_res_latest.csv +0 -0
  32. {emhass-0.8.1 → emhass-0.8.2}/data/opt_res_perfect_optim_cost.csv +0 -0
  33. {emhass-0.8.1 → emhass-0.8.2}/data/opt_res_perfect_optim_profit.csv +0 -0
  34. {emhass-0.8.1 → emhass-0.8.2}/data/opt_res_perfect_optim_self-consumption.csv +0 -0
  35. {emhass-0.8.1 → emhass-0.8.2}/data/test_df_final.pkl +0 -0
  36. {emhass-0.8.1 → emhass-0.8.2}/data/test_response_get_data_get_method.pbz2 +0 -0
  37. {emhass-0.8.1 → emhass-0.8.2}/data/test_response_scrapper_get_method.pbz2 +0 -0
  38. {emhass-0.8.1 → emhass-0.8.2}/data/test_response_solarforecast_get_method.pbz2 +0 -0
  39. {emhass-0.8.1 → emhass-0.8.2}/data/test_response_solcast_get_method.pbz2 +0 -0
  40. {emhass-0.8.1 → emhass-0.8.2}/pyproject.toml +0 -0
  41. {emhass-0.8.1 → emhass-0.8.2}/setup.cfg +0 -0
  42. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/__init__.py +0 -0
  43. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/command_line.py +0 -0
  44. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/machine_learning_forecaster.py +0 -0
  45. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/static/img/emhass_icon.png +0 -0
  46. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/static/img/emhass_logo_short.svg +0 -0
  47. {emhass-0.8.1 → emhass-0.8.2}/src/emhass/utils.py +0 -0
  48. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/dependency_links.txt +0 -0
  49. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/entry_points.txt +0 -0
  50. {emhass-0.8.1 → emhass-0.8.2}/src/emhass.egg-info/top_level.txt +0 -0
  51. {emhass-0.8.1 → emhass-0.8.2}/tests/test_command_line_utils.py +0 -0
  52. {emhass-0.8.1 → emhass-0.8.2}/tests/test_forecast.py +0 -0
  53. {emhass-0.8.1 → emhass-0.8.2}/tests/test_machine_learning_forecaster.py +0 -0
  54. {emhass-0.8.1 → emhass-0.8.2}/tests/test_optimization.py +0 -0
  55. {emhass-0.8.1 → emhass-0.8.2}/tests/test_retrieve_hass.py +0 -0
  56. {emhass-0.8.1 → emhass-0.8.2}/tests/test_utils.py +0 -0
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.2] - 2024-03-10
4
+ ### Improvement
5
+ - Proposed a new solution to survive DST using special option of Pandas `round` method
6
+ - Added option to `web_server` to init `data_path` as an options param
7
+ - Styling docs and html files on webui
8
+ - Advanced and basic pages improvements on webui
9
+ ### Fix
10
+ - Fixed support for ARM achitectures
11
+
3
12
  ## [0.8.1] - 2024-02-28
4
13
  ### Improvement
5
14
  - Improved documentation
@@ -587,6 +596,9 @@ Thanks to @GeoDerp for this great work!
587
596
  [0.7.6]: https://github.com/davidusb-geek/emhass/releases/tag/v0.7.6
588
597
  [0.7.7]: https://github.com/davidusb-geek/emhass/releases/tag/v0.7.7
589
598
  [0.7.8]: https://github.com/davidusb-geek/emhass/releases/tag/v0.7.8
599
+ [0.8.0]: https://github.com/davidusb-geek/emhass/releases/tag/v0.8.0
600
+ [0.8.1]: https://github.com/davidusb-geek/emhass/releases/tag/v0.8.1
601
+ [0.8.2]: https://github.com/davidusb-geek/emhass/releases/tag/v0.8.2
590
602
 
591
603
  # Notes
592
604
  All notable changes to this project will be documented in this file.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: emhass
3
- Version: 0.8.1
3
+ Version: 0.8.2
4
4
  Summary: An Energy Management System for Home Assistant
5
5
  Home-page: https://github.com/davidusb-geek/emhass
6
6
  Author: David HERNANDEZ
@@ -16,8 +16,8 @@ Requires-Python: >=3.9, <3.12
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: wheel
19
- Requires-Dist: numpy<=1.26
20
- Requires-Dist: scipy<=1.11.3
19
+ Requires-Dist: numpy==1.26.4
20
+ Requires-Dist: scipy==1.12.0
21
21
  Requires-Dist: pandas<=2.0.3
22
22
  Requires-Dist: pvlib>=0.10.2
23
23
  Requires-Dist: protobuf>=3.0.0
@@ -132,16 +132,16 @@ These architectures are supported: `amd64`, `armv7`, `armhf` and `aarch64`.
132
132
  ### Method 2) Using Docker in standalone mode
133
133
 
134
134
  You can also install EMHASS using docker. This can be in the same machine as Home Assistant (if using the supervised install method) or in a different distant machine. To install first pull the latest image from docker hub:
135
- ```
135
+ ```bash
136
136
  docker pull davidusb/emhass-docker-standalone
137
137
  ```
138
138
 
139
139
  You can also build your image locally. For this clone this repository, setup your `config_emhass.yaml` file and use the provided make file with this command:
140
- ```
140
+ ```bash
141
141
  make -f deploy_docker.mk clean_deploy
142
142
  ```
143
143
  Then load the image in the .tar file:
144
- ```
144
+ ```bash
145
145
  docker load -i <TarFileName>.tar
146
146
  ```
147
147
  Finally check your image tag with `docker images` and launch the docker itself:
@@ -159,17 +159,17 @@ docker run -it --restart always -p 5000:5000 -e "LOCAL_COSTFUN=profit" -v $(pwd)
159
159
 
160
160
  With this method it is recommended to install on a virtual environment.
161
161
  For this you will need `virtualenv`, install it using:
162
- ```
162
+ ```bash
163
163
  sudo apt install python3-virtualenv
164
164
  ```
165
165
  Then create and activate the virtual environment:
166
- ```
166
+ ```bash
167
167
  virtualenv -p /usr/bin/python3 emhassenv
168
168
  cd emhassenv
169
169
  source bin/activate
170
170
  ```
171
171
  Install using the distribution files:
172
- ```
172
+ ```bash
173
173
  python3 -m pip install emhass
174
174
  ```
175
175
  Clone this repository to obtain the example configuration files.
@@ -180,7 +180,7 @@ We will suppose that this repository is cloned to:
180
180
  This will be the root path containing the yaml configuration files (`config_emhass.yaml` and `secrets_emhass.yaml`) and the different needed folders (a `data` folder to store the optimizations results and a `scripts` folder containing the bash scripts described further below).
181
181
 
182
182
  To upgrade the installation in the future just use:
183
- ```
183
+ ```bash
184
184
  python3 -m pip install --upgrade emhass
185
185
  ```
186
186
 
@@ -216,7 +216,7 @@ The available arguments are:
216
216
  - `--version`: Show the current version of EMHASS.
217
217
 
218
218
  For example, the following line command can be used to perform a day-ahead optimization task:
219
- ```
219
+ ```bash
220
220
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml' --costfun 'profit'
221
221
  ```
222
222
  Before running any valuable command you need to modify the `config_emhass.yaml` and `secrets_emhass.yaml` files. These files should contain the information adapted to your own system. To do this take a look at the special section for this in the [documentation](https://emhass.readthedocs.io/en/latest/config.html).
@@ -230,7 +230,7 @@ Then additional optimization strategies were developed, that can be used in comb
230
230
  ### Dayahead Optimization - Method 1) Add-on and docker standalone
231
231
 
232
232
  In `configuration.yaml`:
233
- ```
233
+ ```yaml
234
234
  shell_command:
235
235
  dayahead_optim: "curl -i -H \"Content-Type:application/json\" -X POST -d '{}' http://localhost:5000/action/dayahead-optim"
236
236
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{}' http://localhost:5000/action/publish-data"
@@ -238,25 +238,25 @@ shell_command:
238
238
  ### Dayahead Optimization - Method 2) Legacy method using a Python virtual environment
239
239
 
240
240
  In `configuration.yaml`:
241
- ```
241
+ ```yaml
242
242
  shell_command:
243
243
  dayahead_optim: /home/user/emhass/scripts/dayahead_optim.sh
244
244
  publish_data: /home/user/emhass/scripts/publish_data.sh
245
245
  ```
246
246
  Create the file `dayahead_optim.sh` with the following content:
247
- ```
247
+ ```bash
248
248
  #!/bin/bash
249
249
  . /home/user/emhassenv/bin/activate
250
250
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml'
251
251
  ```
252
252
  And the file `publish_data.sh` with the following content:
253
- ```
253
+ ```bash
254
254
  #!/bin/bash
255
255
  . /home/user/emhassenv/bin/activate
256
256
  emhass --action 'publish-data' --config '/home/user/emhass/config_emhass.yaml'
257
257
  ```
258
258
  Then specify user rights and make the files executables:
259
- ```
259
+ ```bash
260
260
  sudo chmod -R 755 /home/user/emhass/scripts/dayahead_optim.sh
261
261
  sudo chmod -R 755 /home/user/emhass/scripts/publish_data.sh
262
262
  sudo chmod +x /home/user/emhass/scripts/dayahead_optim.sh
@@ -265,7 +265,7 @@ sudo chmod +x /home/user/emhass/scripts/publish_data.sh
265
265
  ### Common for any installation method
266
266
 
267
267
  In `automations.yaml`:
268
- ```
268
+ ```yaml
269
269
  - alias: EMHASS day-ahead optimization
270
270
  trigger:
271
271
  platform: time
@@ -282,7 +282,7 @@ In `automations.yaml`:
282
282
  In these automations the day-ahead optimization is performed everyday at 5:30am and the data is published every 5 minutes.
283
283
 
284
284
  The final action will be to link a sensor value in Home Assistant to control the switch of a desired controllable load. For example imagine that I want to control my water heater and that the `publish-data` action is publishing the optimized value of a deferrable load that I want to be linked to my water heater desired behavior. In this case we could use an automation like this one below to control the desired real switch:
285
- ```
285
+ ```yaml
286
286
  automation:
287
287
  - alias: Water Heater Optimized ON
288
288
  trigger:
@@ -297,7 +297,7 @@ automation:
297
297
  entity_id: switch.water_heater_switch
298
298
  ```
299
299
  A second automation should be used to turn off the switch:
300
- ```
300
+ ```yaml
301
301
  automation:
302
302
  - alias: Water Heater Optimized OFF
303
303
  trigger:
@@ -319,7 +319,7 @@ The `publish-data` command will push to Home Assistant the optimization results
319
319
  The `publish-data` command will also publish PV and load forecast data on sensors `p_pv_forecast` and `p_load_forecast`. If using a battery, then the battery optimized power and the SOC will be published on sensors `p_batt_forecast` and `soc_batt_forecast`. On these sensors the future values are passed as nested attributes.
320
320
 
321
321
  It is possible to provide custm sensor names for all the data exported by the `publish-data` command. For this, when using the `publish-data` endpoint just add some runtime parameters as dictionaries like this:
322
- ```
322
+ ```yaml
323
323
  shell_command:
324
324
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{\"custom_load_forecast_id\": {\"entity_id\": \"sensor.p_load_forecast\", \"unit_of_measurement\": \"W\", \"friendly_name\": \"Load Power Forecast\"}}' http://localhost:5000/action/publish-data"
325
325
  ```
@@ -327,7 +327,7 @@ shell_command:
327
327
  These keys are available to modify: `custom_pv_forecast_id`, `custom_load_forecast_id`, `custom_batt_forecast_id`, `custom_batt_soc_forecast_id`, `custom_grid_forecast_id`, `custom_cost_fun_id`, `custom_deferrable_forecast_id`, `custom_unit_load_cost_id` and `custom_unit_prod_price_id`.
328
328
 
329
329
  If you provide the `custom_deferrable_forecast_id` then the passed data should be a list of dictionaries, like this:
330
- ```
330
+ ```yaml
331
331
  shell_command:
332
332
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{\"custom_deferrable_forecast_id\": [{\"entity_id\": \"sensor.p_deferrable0\",\"unit_of_measurement\": \"W\", \"friendly_name\": \"Deferrable Load 0\"},{\"entity_id\": \"sensor.p_deferrable1\",\"unit_of_measurement\": \"W\", \"friendly_name\": \"Deferrable Load 1\"}]}' http://localhost:5000/action/publish-data"
333
333
  ```
@@ -377,11 +377,11 @@ The valid values to pass for both forecast data and MPC related data are explain
377
377
  It is possible to provide EMHASS with your own forecast data. For this just add the data as list of values to a data dictionary during the call to `emhass` using the `runtimeparams` option.
378
378
 
379
379
  For example if using the add-on or the standalone docker installation you can pass this data as list of values to the data dictionary during the `curl` POST:
380
- ```
380
+ ```bash
381
381
  curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93, 1164.33, 1046.68, 1559.1, 2091.26, 1556.76, 1166.73, 1516.63, 1391.13, 1720.13, 820.75, 804.41, 251.63, 79.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}' http://localhost:5000/action/dayahead-optim
382
382
  ```
383
383
  Or if using the legacy method using a Python virtual environment:
384
- ```
384
+ ```bash
385
385
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml' --runtimeparams '{"pv_power_forecast":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93, 1164.33, 1046.68, 1559.1, 2091.26, 1556.76, 1166.73, 1516.63, 1391.13, 1720.13, 820.75, 804.41, 251.63, 79.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}'
386
386
  ```
387
387
 
@@ -454,10 +454,16 @@ When applying this controller, the following `runtimeparams` should be defined:
454
454
 
455
455
  A correct call for a MPC optimization should look like:
456
456
 
457
+ ```bash
458
+ curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6}' http://192.168.3.159:5000/action/naive-mpc-optim
457
459
  ```
458
- curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6,"def_total_hours":[1,3],"def_start_timestep":[0,3],"def_end_timestep":[0,6],}' http://localhost:5000/action/naive-mpc-optim
460
+ *Example with :`def_total_hours`, `def_start_timestep`, `def_end_timestep`.*
461
+ ```bash
462
+ curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6,"def_total_hours":[1,3],"def_start_timestep":[0,3],"def_end_timestep":[0,6]}' http://localhost:5000/action/naive-mpc-optim
459
463
  ```
460
464
 
465
+
466
+
461
467
  ## A machine learning forecaster
462
468
 
463
469
  Starting in v0.4.0 a new machine learning forecaster class was introduced.
@@ -97,16 +97,16 @@ These architectures are supported: `amd64`, `armv7`, `armhf` and `aarch64`.
97
97
  ### Method 2) Using Docker in standalone mode
98
98
 
99
99
  You can also install EMHASS using docker. This can be in the same machine as Home Assistant (if using the supervised install method) or in a different distant machine. To install first pull the latest image from docker hub:
100
- ```
100
+ ```bash
101
101
  docker pull davidusb/emhass-docker-standalone
102
102
  ```
103
103
 
104
104
  You can also build your image locally. For this clone this repository, setup your `config_emhass.yaml` file and use the provided make file with this command:
105
- ```
105
+ ```bash
106
106
  make -f deploy_docker.mk clean_deploy
107
107
  ```
108
108
  Then load the image in the .tar file:
109
- ```
109
+ ```bash
110
110
  docker load -i <TarFileName>.tar
111
111
  ```
112
112
  Finally check your image tag with `docker images` and launch the docker itself:
@@ -124,17 +124,17 @@ docker run -it --restart always -p 5000:5000 -e "LOCAL_COSTFUN=profit" -v $(pwd)
124
124
 
125
125
  With this method it is recommended to install on a virtual environment.
126
126
  For this you will need `virtualenv`, install it using:
127
- ```
127
+ ```bash
128
128
  sudo apt install python3-virtualenv
129
129
  ```
130
130
  Then create and activate the virtual environment:
131
- ```
131
+ ```bash
132
132
  virtualenv -p /usr/bin/python3 emhassenv
133
133
  cd emhassenv
134
134
  source bin/activate
135
135
  ```
136
136
  Install using the distribution files:
137
- ```
137
+ ```bash
138
138
  python3 -m pip install emhass
139
139
  ```
140
140
  Clone this repository to obtain the example configuration files.
@@ -145,7 +145,7 @@ We will suppose that this repository is cloned to:
145
145
  This will be the root path containing the yaml configuration files (`config_emhass.yaml` and `secrets_emhass.yaml`) and the different needed folders (a `data` folder to store the optimizations results and a `scripts` folder containing the bash scripts described further below).
146
146
 
147
147
  To upgrade the installation in the future just use:
148
- ```
148
+ ```bash
149
149
  python3 -m pip install --upgrade emhass
150
150
  ```
151
151
 
@@ -181,7 +181,7 @@ The available arguments are:
181
181
  - `--version`: Show the current version of EMHASS.
182
182
 
183
183
  For example, the following line command can be used to perform a day-ahead optimization task:
184
- ```
184
+ ```bash
185
185
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml' --costfun 'profit'
186
186
  ```
187
187
  Before running any valuable command you need to modify the `config_emhass.yaml` and `secrets_emhass.yaml` files. These files should contain the information adapted to your own system. To do this take a look at the special section for this in the [documentation](https://emhass.readthedocs.io/en/latest/config.html).
@@ -195,7 +195,7 @@ Then additional optimization strategies were developed, that can be used in comb
195
195
  ### Dayahead Optimization - Method 1) Add-on and docker standalone
196
196
 
197
197
  In `configuration.yaml`:
198
- ```
198
+ ```yaml
199
199
  shell_command:
200
200
  dayahead_optim: "curl -i -H \"Content-Type:application/json\" -X POST -d '{}' http://localhost:5000/action/dayahead-optim"
201
201
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{}' http://localhost:5000/action/publish-data"
@@ -203,25 +203,25 @@ shell_command:
203
203
  ### Dayahead Optimization - Method 2) Legacy method using a Python virtual environment
204
204
 
205
205
  In `configuration.yaml`:
206
- ```
206
+ ```yaml
207
207
  shell_command:
208
208
  dayahead_optim: /home/user/emhass/scripts/dayahead_optim.sh
209
209
  publish_data: /home/user/emhass/scripts/publish_data.sh
210
210
  ```
211
211
  Create the file `dayahead_optim.sh` with the following content:
212
- ```
212
+ ```bash
213
213
  #!/bin/bash
214
214
  . /home/user/emhassenv/bin/activate
215
215
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml'
216
216
  ```
217
217
  And the file `publish_data.sh` with the following content:
218
- ```
218
+ ```bash
219
219
  #!/bin/bash
220
220
  . /home/user/emhassenv/bin/activate
221
221
  emhass --action 'publish-data' --config '/home/user/emhass/config_emhass.yaml'
222
222
  ```
223
223
  Then specify user rights and make the files executables:
224
- ```
224
+ ```bash
225
225
  sudo chmod -R 755 /home/user/emhass/scripts/dayahead_optim.sh
226
226
  sudo chmod -R 755 /home/user/emhass/scripts/publish_data.sh
227
227
  sudo chmod +x /home/user/emhass/scripts/dayahead_optim.sh
@@ -230,7 +230,7 @@ sudo chmod +x /home/user/emhass/scripts/publish_data.sh
230
230
  ### Common for any installation method
231
231
 
232
232
  In `automations.yaml`:
233
- ```
233
+ ```yaml
234
234
  - alias: EMHASS day-ahead optimization
235
235
  trigger:
236
236
  platform: time
@@ -247,7 +247,7 @@ In `automations.yaml`:
247
247
  In these automations the day-ahead optimization is performed everyday at 5:30am and the data is published every 5 minutes.
248
248
 
249
249
  The final action will be to link a sensor value in Home Assistant to control the switch of a desired controllable load. For example imagine that I want to control my water heater and that the `publish-data` action is publishing the optimized value of a deferrable load that I want to be linked to my water heater desired behavior. In this case we could use an automation like this one below to control the desired real switch:
250
- ```
250
+ ```yaml
251
251
  automation:
252
252
  - alias: Water Heater Optimized ON
253
253
  trigger:
@@ -262,7 +262,7 @@ automation:
262
262
  entity_id: switch.water_heater_switch
263
263
  ```
264
264
  A second automation should be used to turn off the switch:
265
- ```
265
+ ```yaml
266
266
  automation:
267
267
  - alias: Water Heater Optimized OFF
268
268
  trigger:
@@ -284,7 +284,7 @@ The `publish-data` command will push to Home Assistant the optimization results
284
284
  The `publish-data` command will also publish PV and load forecast data on sensors `p_pv_forecast` and `p_load_forecast`. If using a battery, then the battery optimized power and the SOC will be published on sensors `p_batt_forecast` and `soc_batt_forecast`. On these sensors the future values are passed as nested attributes.
285
285
 
286
286
  It is possible to provide custm sensor names for all the data exported by the `publish-data` command. For this, when using the `publish-data` endpoint just add some runtime parameters as dictionaries like this:
287
- ```
287
+ ```yaml
288
288
  shell_command:
289
289
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{\"custom_load_forecast_id\": {\"entity_id\": \"sensor.p_load_forecast\", \"unit_of_measurement\": \"W\", \"friendly_name\": \"Load Power Forecast\"}}' http://localhost:5000/action/publish-data"
290
290
  ```
@@ -292,7 +292,7 @@ shell_command:
292
292
  These keys are available to modify: `custom_pv_forecast_id`, `custom_load_forecast_id`, `custom_batt_forecast_id`, `custom_batt_soc_forecast_id`, `custom_grid_forecast_id`, `custom_cost_fun_id`, `custom_deferrable_forecast_id`, `custom_unit_load_cost_id` and `custom_unit_prod_price_id`.
293
293
 
294
294
  If you provide the `custom_deferrable_forecast_id` then the passed data should be a list of dictionaries, like this:
295
- ```
295
+ ```yaml
296
296
  shell_command:
297
297
  publish_data: "curl -i -H \"Content-Type:application/json\" -X POST -d '{\"custom_deferrable_forecast_id\": [{\"entity_id\": \"sensor.p_deferrable0\",\"unit_of_measurement\": \"W\", \"friendly_name\": \"Deferrable Load 0\"},{\"entity_id\": \"sensor.p_deferrable1\",\"unit_of_measurement\": \"W\", \"friendly_name\": \"Deferrable Load 1\"}]}' http://localhost:5000/action/publish-data"
298
298
  ```
@@ -342,11 +342,11 @@ The valid values to pass for both forecast data and MPC related data are explain
342
342
  It is possible to provide EMHASS with your own forecast data. For this just add the data as list of values to a data dictionary during the call to `emhass` using the `runtimeparams` option.
343
343
 
344
344
  For example if using the add-on or the standalone docker installation you can pass this data as list of values to the data dictionary during the `curl` POST:
345
- ```
345
+ ```bash
346
346
  curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93, 1164.33, 1046.68, 1559.1, 2091.26, 1556.76, 1166.73, 1516.63, 1391.13, 1720.13, 820.75, 804.41, 251.63, 79.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}' http://localhost:5000/action/dayahead-optim
347
347
  ```
348
348
  Or if using the legacy method using a Python virtual environment:
349
- ```
349
+ ```bash
350
350
  emhass --action 'dayahead-optim' --config '/home/user/emhass/config_emhass.yaml' --runtimeparams '{"pv_power_forecast":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93, 1164.33, 1046.68, 1559.1, 2091.26, 1556.76, 1166.73, 1516.63, 1391.13, 1720.13, 820.75, 804.41, 251.63, 79.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}'
351
351
  ```
352
352
 
@@ -419,10 +419,16 @@ When applying this controller, the following `runtimeparams` should be defined:
419
419
 
420
420
  A correct call for a MPC optimization should look like:
421
421
 
422
+ ```bash
423
+ curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6}' http://192.168.3.159:5000/action/naive-mpc-optim
422
424
  ```
423
- curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6,"def_total_hours":[1,3],"def_start_timestep":[0,3],"def_end_timestep":[0,6],}' http://localhost:5000/action/naive-mpc-optim
425
+ *Example with :`def_total_hours`, `def_start_timestep`, `def_end_timestep`.*
426
+ ```bash
427
+ curl -i -H 'Content-Type:application/json' -X POST -d '{"pv_power_forecast":[0, 70, 141.22, 246.18, 513.5, 753.27, 1049.89, 1797.93, 1697.3, 3078.93], "prediction_horizon":10, "soc_init":0.5,"soc_final":0.6,"def_total_hours":[1,3],"def_start_timestep":[0,3],"def_end_timestep":[0,6]}' http://localhost:5000/action/naive-mpc-optim
424
428
  ```
425
429
 
430
+
431
+
426
432
  ## A machine learning forecaster
427
433
 
428
434
  Starting in v0.4.0 a new machine learning forecaster class was introduced.
@@ -19,7 +19,7 @@ long_description = (here / 'README.md').read_text(encoding='utf-8')
19
19
 
20
20
  setup(
21
21
  name='emhass', # Required
22
- version='0.8.1', # Required
22
+ version='0.8.2', # Required
23
23
  description='An Energy Management System for Home Assistant', # Optional
24
24
  long_description=long_description, # Optional
25
25
  long_description_content_type='text/markdown', # Optional (see note above)
@@ -40,8 +40,8 @@ setup(
40
40
  python_requires='>=3.9, <3.12',
41
41
  install_requires=[
42
42
  'wheel',
43
- 'numpy<=1.26',
44
- 'scipy<=1.11.3',
43
+ 'numpy==1.26.4',
44
+ 'scipy==1.12.0',
45
45
  'pandas<=2.0.3',
46
46
  'pvlib>=0.10.2',
47
47
  'protobuf>=3.0.0',
@@ -62,6 +62,6 @@ setup(
62
62
  'emhass=emhass.command_line:main',
63
63
  ],
64
64
  },
65
- package_data={'emhass': ['templates/index.html','templates/template.html',
66
- 'static/style.css','static/img/emhass_icon.png','static/img/emhass_logo_short.svg']},
65
+ package_data={'emhass': ['templates/index.html','templates/template.html','static/advanced.html','static/basic.html', 'static/script.js',
66
+ 'static/style.css','static/img/emhass_icon.png','static/img/emhass_logo_short.svg', 'static/img/feather-sprite.svg']},
67
67
  )
@@ -159,7 +159,7 @@ class Forecast(object):
159
159
  self.end_forecast = (self.start_forecast + self.optim_conf['delta_forecast']).replace(microsecond=0)
160
160
  self.forecast_dates = pd.date_range(start=self.start_forecast,
161
161
  end=self.end_forecast-self.freq,
162
- freq=self.freq).round(self.freq)
162
+ freq=self.freq).round(self.freq, ambiguous='infer', nonexistent=self.freq)
163
163
  if params is not None:
164
164
  if 'prediction_horizon' in list(self.params['passed_data'].keys()):
165
165
  if self.params['passed_data']['prediction_horizon'] is not None:
@@ -184,7 +184,7 @@ class Forecast(object):
184
184
  freq_scrap = pd.to_timedelta(60, "minutes") # The scrapping time step is 60min
185
185
  forecast_dates_scrap = pd.date_range(start=self.start_forecast,
186
186
  end=self.end_forecast-freq_scrap,
187
- freq=freq_scrap).round(freq_scrap)
187
+ freq=freq_scrap).round(freq_scrap, ambiguous='infer', nonexistent=freq_scrap)
188
188
  # Using the clearoutside webpage
189
189
  response = get("https://clearoutside.com/forecast/"+str(round(self.lat, 2))+"/"+str(round(self.lon, 2))+"?desktop=true")
190
190
  '''import bz2 # Uncomment to save a serialized data for tests
@@ -476,7 +476,7 @@ class Forecast(object):
476
476
  end_forecast_csv = (start_forecast_csv + self.optim_conf['delta_forecast']).replace(microsecond=0)
477
477
  forecast_dates_csv = pd.date_range(start=start_forecast_csv,
478
478
  end=end_forecast_csv+timedelta(days=timedelta_days)-self.freq,
479
- freq=self.freq).round(self.freq)
479
+ freq=self.freq).round(self.freq, ambiguous='infer', nonexistent=self.freq)
480
480
  if self.params is not None:
481
481
  if 'prediction_horizon' in list(self.params['passed_data'].keys()):
482
482
  if self.params['passed_data']['prediction_horizon'] is not None:
@@ -85,6 +85,9 @@ class Optimization:
85
85
  self.lp_solver_path = 'empty'
86
86
  if self.lp_solver != 'COIN_CMD' and self.lp_solver_path != 'empty':
87
87
  self.logger.error("Use COIN_CMD solver name if you want to set a path for the LP solver")
88
+ if self.lp_solver == 'COIN_CMD' and self.lp_solver_path == 'empty': #if COIN_CMD but lp_solver_path is empty
89
+ self.logger.warning("lp_solver=COIN_CMD but lp_solver_path=empty, attempting to use lp_solver_path=/usr/bin/cbc")
90
+ self.lp_solver_path = '/usr/bin/cbc'
88
91
 
89
92
  def perform_optimization(self, data_opt: pd.DataFrame, P_PV: np.array, P_load: np.array,
90
93
  unit_load_cost: np.array, unit_prod_price: np.array,
@@ -149,7 +149,7 @@ class RetrieveHass:
149
149
  from_date = pd.to_datetime(df_raw['last_changed'], format="ISO8601").min()
150
150
  to_date = pd.to_datetime(df_raw['last_changed'], format="ISO8601").max()
151
151
  ts = pd.to_datetime(pd.date_range(start=from_date, end=to_date, freq=self.freq),
152
- format='%Y-%d-%m %H:%M').round(self.freq)
152
+ format='%Y-%d-%m %H:%M').round(self.freq, ambiguous='infer', nonexistent=self.freq)
153
153
  df_day = pd.DataFrame(index = ts)
154
154
  # Caution with undefined string data: unknown, unavailable, etc.
155
155
  df_tp = df_raw.copy()[['state']].replace(
@@ -0,0 +1,32 @@
1
+ <!-- action button elements section -->
2
+ <div class="loading-div" id="advance">
3
+ <h4>Use the buttons below to manually launch different optimization tasks</h4>
4
+ <div id=loader></div> <!-- status dynamic element -->
5
+ </div>
6
+ <button type="button" id="perfect-optim" class="button button1">Perfect Optimization</button>
7
+ <button type="button" id="dayahead-optim" class="button button2">Day-ahead Optimization</button>
8
+ <button type="button" id="naive-mpc-optim" class="button button3">MPC Optimization</button>
9
+ <!--ml toggled div button -->
10
+ <h4>Use the button below to publish the optimized variables at the current timestamp</h4>
11
+ <button type="button" id="publish-data" class="button button1">Publish Optimization Results</button>
12
+ <h4>Use the buttons below to fit, predict and tune a machine learning model for testing</h4>
13
+ <button type="button" id="forecast-model-fit" class="button button1">ML forecast model fit</button>
14
+ <button type="button" id="forecast-model-predict" class="button button2">ML forecast model
15
+ predict</button>
16
+ <button type="button" id="forecast-model-tune" class="button button3">ML forecast model tune</button>
17
+ <!-- -->
18
+ <!--dynamic input elements section -->
19
+ <h4>Input Runtime Parameters</h4>
20
+ <div class="input-button-container">
21
+ <div class="input-buttons">
22
+ <button type="button" id="input-plus">+</button>
23
+ <button type="button" id="input-minus">-</button>
24
+ <select name="Select" id="input-select">
25
+ <option value="List" selected>List</option>
26
+ <option value="Box">Box</option>
27
+ </select>
28
+ <button type="button" id="input-clear">Clear</button>
29
+ </div>
30
+ </div>
31
+ <div id="input-container"> <!-- (Box/List) dynamic input elements will be added here -->
32
+ </div>
@@ -0,0 +1,12 @@
1
+ <!-- action button elements section -->
2
+ <div class="loading-div" id="basic">
3
+ <h4>Use the button below to manually launch optimization task</h4>
4
+ <div id=loader></div> <!-- status dynamic element -->
5
+ </div>
6
+ <button type="button" id="dayahead-optim-basic" class="button button1">Day-ahead Optimization</button>
7
+ <div class="info">
8
+ <p>The day-ahead optimization button will run once, based on the values entered into the configuration page.
9
+ </br>
10
+ After a few seconds, the charts and table below should be updated to reflect the optimization plan for the next 24 hours.
11
+ </p>
12
+ </div>