as I’m using apex charts (as presented by @markpurcell ) to show EMHASS data in Home Assistant:
Is there a way to get unit_load_cost and unit_prod_price as sensors in Home Assistant? Currently I have the standard sensors like those for defferable nodes.
As I’m generating the array of prices in Node-Red, creating a sensor with attributes via Node-Red might result in different formats how they (or timestamps) are saved compared to getting them from EMHASS which would be very convenient.
A brand new load forecast module and more… The new forecast module can actually be used to forecast any Home Assistant variable. The API provides fit, predict and tune methods. By the default it provides a more efficient way to forecast the power load consumption. It is based on the skforecast module that uses scikit-learn regression models considering auto-regression lags as features. The hyperparameter optimization is proposed using bayesian optimization from the optuna module.
A new documentation section covering the new forecast module.
Improved the documentation and the in-code docstrings.
Added the possibility to save the optimized model after a tuning routine.
Added the possibility to publish predict results to a Home Assistant sensor.
Added the possibility to provide custom entity_id, unit_of_measurement and friendly_name for each published data.
Fix
Fixed Solar.Forecast issues with lists of parameters.
Fixed latex equations rendering on documentation, dropped Mathjax.
Refactored images in documentation, now using only SVG for plotly figures.
Bumped requirements to latest non-conflicting versions.
Exception on /action/publish-data [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 154, in action_call
_ = publish_data(input_data_dict, app.logger)
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 464, in publish_data
custom_pv_forecast_id = input_data_dict['params']['passed_data']['custom_pv_forecast_id']
TypeError: string indices must be integers
Trying to start a second docker outside home assistant to test out the new machine learning and get this:
ModuleNotFoundError: No module named 'emhass.machine_learning_forecaster'
Traceback (most recent call last):
File "src/emhass/web_server.py", line 14, in <module>
from emhass.command_line import set_input_data_dict
File "<frozen zipimport>", line 259, in load_module
File "/usr/local/lib/python3.8/site-packages/emhass-0.4.2-py3.8.egg/emhass/command_line.py", line 20, in <module>
from emhass.forecast import forecast
File "<frozen zipimport>", line 259, in load_module
File "/usr/local/lib/python3.8/site-packages/emhass-0.4.2-py3.8.egg/emhass/forecast.py", line 23, in <module>
from emhass.machine_learning_forecaster import mlforecaster
Are trying to use the docker standalone installation method?
If yes, what commands are you using?
No, no support for GPU/TPU. I’m guessing that most users won’t have that (but I may be wrong) and in any case I’m just using scikit-learn regressors which don’t support GPU. The goal was to keep it as simple as possible. The modules that support GPU will result in complicated installs not generalized for all systems architectures and very big docker container images (>1 Gb). I’m a big supporter of scientific GPU computation but for this project its just not the way to go IMHO. But I’m open to change and I may reconsider it in the future.
David, I am getting closer to having a battery installed and have been running emhass for about 3-4 months without issue.
In some recent upgrade though I have lost something. It is likely quite simple but i get an error referencing a df_day component. Here is an error log from trying to run an optimization. I have made no real changes to my HA apart from regulalry installing latest updates. My system is on an intel NUC.
Home Assistant 2023.3.1
Supervisor 2023.03.1
Operating System 9.5
Frontend 20230302.0 - latest
error from log below
The retrieved JSON is empty, check that correct day or variable names are passed
Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)
Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 150, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 91, in set_input_data_dict
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
File "/usr/local/lib/python3.9/dist-packages/emhass/forecast.py", line 585, in get_load_forecast
rh.get_data(days_list, var_list)
File "/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py", line 147, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable 'df_day' referenced before assignment ```
Patrick
Hi, yes there are some new unexpected bugs with the latest release. I’m working on it. I don’t if your issue is related but I’m investigating. Sorry about this
Hopefully solved most of the issues now. The images are being built.
There were some bugs that needed to be fixed but I think that there was also an issue with the Home Assistant core API. In any case I updated to the latest Home Assistant core and retested both the add-on and the docker standalone and they are working fine.
I tested it yesterday and it works just fine.
Although I tested it with the make command and compiling the docker image locally. I didn’t use docker pull davidusb/emhass-docker-standalone. I can test that tonight
In the mean time you can try to build locally.
Clone the emhass repo and do:
make -f deploy_docker.mk clean_deploy
Then load the image in the .tar file:
docker load -i <TarFileName>.tar
Then run the docker run command with the needed arguments
David,
Have the latest build but still an error in log?
web_server WARNING The data container dictionary is empty... Please launch an optimization task
web_server INFO Setting up needed data
web_server INFO Retrieving weather forecast data using method = scrapper
web_server INFO Retrieving data from hass for load forecast using method = naive
web_server INFO Retrieve hass get data method initiated...
web_server ERROR The retrieved JSON is empty, check that correct day or variable names are passed
web_server ERROR Either the names of the passed variables are not correct or days_to_retrieve is larger than the recorded history of your sensor (check your recorder settings)
web_server ERROR Exception on /action/dayahead-optim [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/usr/local/lib/python3.9/dist-packages/emhass/web_server.py", line 150, in action_call
input_data_dict = set_input_data_dict(config_path, str(data_path), costfun,
File "/usr/local/lib/python3.9/dist-packages/emhass/command_line.py", line 91, in set_input_data_dict
P_load_forecast = fcst.get_load_forecast(method=optim_conf['load_forecast_method'])
File "/usr/local/lib/python3.9/dist-packages/emhass/forecast.py", line 585, in get_load_forecast
rh.get_data(days_list, var_list)
File "/usr/local/lib/python3.9/dist-packages/emhass/retrieve_hass.py", line 147, in get_data
self.df_final = pd.concat([self.df_final, df_day], axis=0)
UnboundLocalError: local variable 'df_day' referenced before assignment```
Pat