You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-50Lines changed: 48 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ WattWise is an AppDaemon application for [Home Assistant](https://www.home-assis
36
36
37
37
## Features
38
38
39
-
-**Hourly Optimization** : Executes the optimization process every hour to ensure decisions are based on the latest data.
39
+
-**Quarter-Hourly Optimization** : Executes the optimization process every 15 minutes to ensure decisions are based on the latest data.
40
40
41
41
-**Dynamic Forecasting** : Utilizes historical consumption data, solar production forecasts, and real-time energy prices.
42
42
@@ -53,14 +53,14 @@ WattWise is an AppDaemon application for [Home Assistant](https://www.home-assis
53
53
WattWise leverages linear programming to optimize the charging and discharging schedule of your home battery system. Here's a detailed explanation of the process:
54
54
55
55
1.**Data Collection** :
56
-
-**Consumption Forecast** : Calculates average consumption for each hour based on historical data from the past seven days.
56
+
-**Consumption Forecast** : Calculates average consumption every 15 minutes intervall based on historical data from the past days (number of days individually adjustable).
57
57
58
-
-**Solar Production Forecast** : Retrieves solar production forecasts for todayand tomorrow from Home Assistant sensors.
58
+
-**Solar Production Forecast** : Retrieves solar production forecasts for today, tomorrow and the day after tomorrowfrom Home Assistant sensors.
59
59
60
-
-**Energy Price Forecast** : Obtains current and future energy prices, considering both today'sand tomorrow's rates.
60
+
-**Energy Price Forecast** : Obtains current and future energy prices, considering both today's, tomorrow's and day-after-tomorrow's rates.
61
61
62
62
2.**Optimization Algorithm** :
63
-
-**Objective** : Minimizes the total energy cost over a 24-hour horizon by determining the optimal times to charge (from solar or grid) and discharge the battery.
63
+
-**Objective** : Minimizes the total energy cost over a 48-hour horizon by determining the optimal times to charge (from solar or grid) and discharge the battery.
64
64
65
65
-**Constraints** :
66
66
-**Battery Capacity** : Ensures the battery state of charge (SoC) stays within physical limits.
@@ -93,11 +93,8 @@ WattWise leverages linear programming to optimize the charging and discharging s
93
93
94
94
-**HA Solcast PV Solar Forecast Integration** : Installed via HACS and configured, so that you get an accurate PV production forecast. The script expects the forecast information in the format provided by [Solcast](https://github.com/BJReplay/ha-solcast-solar) .
95
95
96
-
-**Tibber API Token** : You need an API Token from Tibber to fetch your energy price forecast. You can get your token from [Tibber's Dev Portal](https://developer.tibber.com/settings/access-token). Place your token in ``config/secrets.yaml`` like this:
96
+
-**HA EPEX SPOT Integration n** : You'll to choose an API for fetching price data. Use of Energyforecast.de API is highly recommended as it provides 24h data directely from EPEX Spot and a 48h-forecast for future prices. The script expects the forecast data from the sensor.epex_spot_data_total_price provided by [EPEX SPOT](https://github.com/mampfes/ha_epex_spot) .
- Place `wattwise.py` (the WattWise script) in your AppDaemon apps directory (e.g., `/config/appdaemon/apps/`). You can do this via SSH or via the Visual Studio Code AddOns.
120
117
121
-
- Configure the app in `apps.yaml` in the same folder. Define your user-specific settings here.
- Upload and configure the app in `apps.yaml` in the same folder. Define your user-specific settings here.
148
119
149
120
-**Explanation** :
150
121
-**`module`** and ****`module`** and `class`** : Point to your WattWise app module and class.
@@ -153,7 +124,7 @@ wattwise:
153
124
154
125
-**User-specific settings** : All the constants specific to your solar/electric system are defined here. Adjust them according to your setup.
155
126
156
-
- **Home Assistant Entity IDs** : Replace the entity IDs with your own Home Assistant sensors and switches.
127
+
-**Home Assistant Entity IDs** : Replace the entity IDs with your own Home Assistant sensors and switches (details see below "Customizing WattWise)
157
128
158
129
1.**Configure Home Assistant Sensors**
159
130
- Place `wattwise.yaml` in your `/config/packages/` folder. If the folder does not exist, create it.
@@ -177,42 +148,69 @@ Proper configuration is essential for WattWise to function correctly. Below are
177
148
### Customizing WattWise
178
149
You can adjust various parameters within the `apps.yaml` configuration file to match your specific setup. Below is a list of configuration parameters that you can set in your `apps.yaml` file under the `wattwise` app:
179
150
- **Battery Parameters** :
180
-
- **`battery_capacity`** (float): Total capacity of your battery in kWh. Example: `11.2`
181
-
151
+
182
152
- **`battery_efficiency`** (float): Efficiency factor of your battery (0 < efficiency ≤ 1). Example: `0.9`
183
153
184
-
- **`charge_rate_max`** (float): Maximum charging rate of your battery in kW. Example: `6`
154
+
- **`charge_rate_max`** (float): Maximum charging rate of your battery in kW. Example: `3.6`
185
155
186
-
- **`discharge_rate_max`** (float): Maximum discharging rate of your battery in kW. Example: `6`
187
-
188
-
- **`lower_battery_limit`** (float): The algorithm will leave this amount of kWh in the battery to allow some buffer in case real-world consumption exceeds the forecasted consumption. Set this to `0` if you want to use the full battery capacity. Example: `1.0`
156
+
- **`discharge_rate_max`** (float): Maximum discharging rate of your battery in kW. Example: `3.6`
189
157
190
158
- **Time Horizon** :
191
159
- **`time_horizon`** (int): Number of hours to look ahead in the optimization (default is 48 hours). Note that the time horizon will be truncated in each run to the highest seen forecast horizon for solar production or prices. Example: `48`
192
160
193
-
- **`consumption_history_days`** (int): Number of days in the past to calculate the average consumption (default is 7 days). Example: `7`
161
+
194
162
195
163
- **Tariffs and Prices** :
196
164
- **`feed_in_tariff`** (float): Price for feeding energy back to the grid in ct/kWh. Only static feed-in tariffs are supported currently. Example: `7`
197
165
198
166
- **Entity IDs** :
199
-
- **`consumption_sensor`** (string): Entity ID for your house's energy consumption sensor. Example: `"sensor.your_house_consumption"`
167
+
- **`consumption_sensor`** (string): Entity ID for your house's energy consumption sensor. Values should be in kW.
168
+
Please note: This sensor must provide your ACTUAL consumption. Maybe you'll have to build a template sensor which shows the ACTUAL consumption. If your energy meter is balancing incomming solarpower or batteryinput with your household consumption (as for example the a Shelly PRO 3EM does) it will provide lower (or even negative) values than your actual consumption. The senor must provide a string value
169
+
Example for template sensors:
170
+
1. Build a template sensor which shows the ACTUAL consumption
2. Build a second sensor from the first sensor, but it must be a string sensor (no float)
182
+
```
183
+
- sensor:
184
+
- name: "Consumption Wattwise"
185
+
unique_id: consuption_wattwise
186
+
state: >
187
+
{{ states('sensor.consumption_actual_kw') }}
188
+
```
200
189
201
190
- **`solar_forecast_sensor_today`** (string): Entity ID for today's solar production forecast. Must be in the format provided by Solcast. Example: `"sensor.solcast_pv_forecast_today"`
202
191
203
192
- **`solar_forecast_sensor_tomorrow`** (string): Entity ID for tomorrow's solar production forecast. Example: `"sensor.solcast_pv_forecast_tomorrow"`
204
193
205
-
- **`price_forecast_sensor`** (string): Entity ID for energy price forecast data. Must be in the format provided by Tibber. Example: `"sensor.tibber_prices"`
194
+
- - **`solar_forecast_sensor_day-after-tomorrow`** (string): Entity ID for tomorrow's solar production forecast. Example: `"sensor.solcast_pv_forecast_day_3"`
195
+
196
+
- **`price_forecast_sensor`** (string): Entity ID for energy price forecast data, which is a template stored in the wattwise.yaml. The source sensor must be the sensor.epex_spot_data_total_price provided by EPEX SPOT. (no need to change if EPEX Spot is used and configures accordingly)
206
197
207
-
- **`battery_soc_sensor`** (string): Entity ID for the battery state of charge sensor. Example: `"sensor.your_battery_soc"`
198
+
- **`battery_soc_sensor`** (string): Entity ID for the battery state of charge sensor. Example: `"sensor.your_battery_soc"` ; expected unit of measurement: %
208
199
209
-
- **Battery Charger/Discharger Switches** :
200
+
- **`battery_capacity_sensor`** (string): Entity ID for the battery capacity sensor. Example: `"sensor.your_battery_capacity_sensor"` ; expected unit of measurement: kWh
201
+
202
+
- **`battery_buffer_sensor`**: Entity ID for the battery capacity sensor. It makes sense to create/use a input sensor for this to be able to adjust the buffer. Example: `"sensor.your_battery_buffer_sensor"` ; expected unit of measurement: kWh
203
+
204
+
- **`consumption_history_days_sensor`**: Entity ID for number of days in the past to calculate the average consumption. It makes sense to create/use a input sensor for this to be able to adjust the number of days (e.g. when on holiday or returning from holiday). Example: `"sensor.your_input_number.wattwise_consumption_history_days"`
205
+
206
+
- **Battery Charger/Discharger Switches** :
210
207
- **`battery_charging_switch`** (string): Entity ID for the switch that controls battery charging from the grid. Default: `"input_boolean.wattwise_battery_charging_from_grid"`
211
208
212
209
- **`battery_discharging_switch`** (string): Entity ID for the switch that controls battery discharging to the house. Default: `"input_boolean.wattwise_battery_discharging_enabled"`
213
210
211
+
214
212
#### After Configuration
215
-
After making changes to the `apps.yaml` file, restart AppDaemon to apply the updates.
213
+
After making changes to the `apps.yaml` file, restart AppDaemon to apply the updates. Check the log of AppDaemon to see if the script is running correctely.
216
214
## Usage
217
215
218
216
Once installed and configured, WattWise automatically runs the optimization process every hour and on Home Assistant restart. It analyzes consumption patterns, solar production forecasts, and energy prices to determine the most cost-effective charging and discharging schedule for your battery system.
@@ -269,4 +267,4 @@ This project is licensed under the [AGPL-3.0 license](https://www.gnu.org/licens
0 commit comments