Skip to content

Commit 930da28

Browse files
committed
WIP: Document charging algorithm
1 parent bec8e06 commit 930da28

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ When the current time is a price minimum, the program wakes up and does the foll
130130
| `POWER_USAGE_FACTOR` | The amount of power used during the day vs during the night as a percentage value. E.g. if the value is set to `0.6` the program assumes you use 60 % of the daily power usage between 6 AM and 6 PM and 40 % between 6 PM and 6 AM. | `0.6` | A decimal number between `0` and `1`, typically between `0.5` and `0.8` |
131131
| `TIBBER_API_TOKEN` | The token to crawl the Tibber API. See https://developer.tibber.com/docs/guides/calling-api for more information. | - | A string, example: `my-secret-token` |
132132
| `INVERTER_HOSTNAME` | The hostname or IP of the inverter. | - | [`inverter.mydomain.com`, `192.168.5.10`, ...] |
133+
| `INVERTER_BATTERY_CAPACITY` | The capacity of the battery in watt hours without any separators. | - | A number, typically between `3000` and `15000` |
133134
| `INVERTER_TARGET_MIN_STATE_OF_CHARGE` | The state of charge the battery shall have when reaching the next minimum as a buffer. | `15` | A number between `0` and `100`, typically between `0` and `40` |
134-
| | `INVERTER_BATTERY_CAPACITY` | The capacity of the battery in watt hours without any separators. | - | A number, typically between `3000` and `15000` |
135135
| `INVERTER_TARGET_MAX_STATE_OF_CHARGE` | The maximum state of charge the inverter will charge to since the last few percent take a long time to charge. | `95` | A number between `0` and `100`, typically between `80` and `100` |
136136
| `SEMSPORTAL_USERNAME` | The username to login into the SEMSPortal. | - | A string, example: `[email protected]` |
137137
| `SEMSPORTAL_PASSWORD` | The password to login into the SEMSPortal. | - | A string, example: `my-secret-password` |
@@ -195,6 +195,45 @@ You can use the [inverter script](./inverter) to control the inverter manually o
195195
The logs of the application are stored in `<path to repository>/logs/`. They are rolled over once a logfile reaches `1 MB` in size. The current log and a maximum of `7` rolled over logfiles are saved.
196196
See also the environment variables `DIRECTORY_OF_LOGS` and `LOGLEVEL`.
197197

198+
## Charging algorithm
199+
The following describes the algorithm the program executes to determine when to charge.
200+
- Start: Now is a price minimum, check what has to be done to reach the next one.
201+
- Calculate the estimated min and max state of charge from now until the next price minimum. Is the estimated min state of charge until the next price minimum lower than the `INVERTER_TARGET_MIN_STATE_OF_CHARGE`?
202+
- `Yes`: Is it possible to reach the next price minimum by not charging or charging (= is it necessary to charge multiple times to reach the next price minimum?).
203+
- `Yes`: Continue with `No` branch of parent decision.
204+
- `No`: It is necessary to charge multiple times
205+
1. Determine the energy rates before and after the upcoming price spike. A price spike is a series of energy rates that are more expensive than the average of all upcoming energy rates.
206+
2. Charge until `INVERTER_TARGET_MAX_STATE_OF_CHARGE`
207+
3. Wait until the energy rate before the price spike.
208+
4. Is the energy rate after the price spike higher than the one after?
209+
- `Yes`: Calculate the estimated min state of charge from now until the energy rate after the price spike. Is the estimated min state of charge until the energy rate after the price spike higher than the `INVERTER_TARGET_MIN_STATE_OF_CHARGE`?
210+
- `Yes`: It is possible to reach the energy rate after the price spike without charging. Wait until the energy rate after the price spike.
211+
- `No`: It is necessary to charge to reach the energy rate after the price spike.
212+
1. Calculate the amount of energy necessary to charge to reach the energy rate after the price spike. # TODO
213+
2. Charge until `target state of charge`.
214+
3. Wait until the energy rate after the price spike.
215+
4. Calculate the estimated min state of charge from now until the next price minimum. Is the estimated min state of charge until the next price minimum higher than the `INVERTER_TARGET_MIN_STATE_OF_CHARGE`?
216+
- `Yes`: There is no need to charge, skip to end.
217+
- `No`:
218+
1. Calculate the amount of energy necessary to charge to reach the next price minimum.
219+
2. Charge until `target state of charge`.
220+
3. Skip to end.
221+
- `No`: Calculate the estimated min state of charge from now until the next price minimum. Is the estimated min state of charge until the next price minimum higher than the `INVERTER_TARGET_MIN_STATE_OF_CHARGE`? This should not be the case as we calculated this earlier. However, since some hours have passed, it is a good idea to recheck.
222+
- `Yes`: There is no need to charge, skip to end.
223+
- `No`: # TODO
224+
- `No`: Is the current energy rate higher than the one of the next price minimum?
225+
- `Yes`: Only charge as much as necessary to reach the next price minimum. Is the estimated min state of charge until the next price minimum higher than the `INVERTER_TARGET_MIN_STATE_OF_CHARGE`?
226+
- `Yes`: There is no need to charge, skip to end.
227+
- `No`: There is a need to charge.
228+
1. `target state of charge` = `current state of charge` + `INVERTER_TARGET_MIN_STATE_OF_CHARGE` - `estimated min state of charge until the next price minimum`.
229+
2. Charge until `target state of charge`.
230+
3. Skip to end.
231+
- `No`: Charge as much as possible without waisting energy from the sun.
232+
1. `target state of charge` = `current state of charge` + `INVERTER_TARGET_MAX_STATE_OF_CHARGE` - `estimated max state of charge until the next price minimum`.
233+
2. Charge until `target state of charge`.
234+
3. Skip to end.
235+
- Wait until next price minimum.
236+
198237
## InfluxDB commands
199238

200239
- Create bucket: `influx bucket create -org default -token ${INFLUXDB_TOKEN} --name default`

0 commit comments

Comments
 (0)