Skip to content

Commit

Permalink
Fix - Fixed some bugs with logging and missing module
Browse files Browse the repository at this point in the history
  • Loading branch information
davidusb-geek committed Mar 8, 2023
1 parent deaf9be commit da6559d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.4.3] - 2023-03-09
### Fix
- Fixed logging.
- Fixed missing module on docker standalone mode.

## [0.4.2] - 2023-03-07
### Fix
- Fixed handling of default passed params.
Expand Down Expand Up @@ -362,6 +367,8 @@
[0.3.36]: https://github.com/davidusb-geek/emhass/releases/tag/v0.3.36
[0.4.0]: https://github.com/davidusb-geek/emhass/releases/tag/v0.4.0
[0.4.1]: https://github.com/davidusb-geek/emhass/releases/tag/v0.4.1
[0.4.2]: https://github.com/davidusb-geek/emhass/releases/tag/v0.4.2
[0.4.3]: https://github.com/davidusb-geek/emhass/releases/tag/v0.4.3

# Notes
All notable changes to this project will be documented in this file.
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN pip3 install --no-cache-dir -r requirements_webserver.txt
COPY src/emhass/__init__.py /app/src/emhass/__init__.py
COPY src/emhass/command_line.py /app/src/emhass/command_line.py
COPY src/emhass/forecast.py /app/src/emhass/forecast.py
COPY src/emhass/machine_learning_forecaster.py /app/src/emhass/machine_learning_forecaster.py
COPY src/emhass/optimization.py /app/src/emhass/optimization.py
COPY src/emhass/retrieve_hass.py /app/src/emhass/retrieve_hass.py
COPY src/emhass/utils.py /app/src/emhass/utils.py
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,28 @@ automation:
- service: homeassistant.turn_off
entity_id: switch.water_heater_switch
```

## The publish-data specificities

The `publish-data` command will push to Home Assistant the optimization results for each deferrable load defined in the configuration. For example if you have defined two deferrable loads, then the command will publish `sensor.p_deferrable0` and `sensor.p_deferrable1` to Home Assistant. When the `dayahead-optim` is launched, after the optimization, a csv file will be saved on disk. The `publish-data` command will load the latest csv file and look for the closest timestamp that match the current time using the `datetime.now()` method in Python. This means that if EMHASS is configured for 30min time step optimizations, the csv will be saved with timestamps 00:00, 00:30, 01:00, 01:30, ... and so on. If the current time is 00:05, then the closest timestamp of the optimization results that will be published is 00:00. If the current time is 00:25, then the closest timestamp of the optimization results that will be published is 00:30.

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.

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:
```
shell_command:
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"
```

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`.

If you provide the `custom_deferrable_forecast_id` then the passed data should be a list of dictionaries, like this:
```
shell_command:
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"
```
And you should be careful that the list of dictionaries has the correct length, which is the number of defined deferrable loads.

## Passing your own data

In EMHASS we have basically 4 forecasts to deal with:
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.4.2'
release = '0.4.3'

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

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.4.2', # Required
version='0.4.3', # 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
4 changes: 2 additions & 2 deletions src/emhass/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@


# Define the Flask instance
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
app = Flask(__name__)
app.logger.setLevel(logging.INFO)
app.logger.propagate = False


def get_injection_dict(df, plot_size = 1366):
# Create plots
Expand Down

0 comments on commit da6559d

Please sign in to comment.