Skip to content

Commit 4332911

Browse files
authored
Versie 2025.12.0 / 2025.12.0.rc8 (#493)
* added /data/prediction to .gitignore * added /data/prediction/models/*.pkl to .gitignore * added /data/prediction/models/*.pkl to .gitignore * Opschonen code * Fix error implementation "reduced hours" for "15min" interval (reported by @CrazyHenk44) * Reduce number of blocks with low "min_run_length" * New logging in logging with planned start and end-time of charging ev (feature request @Diamanten) * Versie 2025.12.0/2025.12.0.rc8
1 parent 2a5a100 commit 4332911

File tree

7 files changed

+64
-17
lines changed

7 files changed

+64
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ dao/data/log/dashboard*
55
dao/data/secrets.json
66
dao/data/options.json
77
dao/data/baseload/*.json
8+
dao/data/prediction/models/*.pkl
89
dao/data/*.db
910
dao/data/tst_options
1011
dao/prog/tst_py

dao/CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Changelog 刀 DAO
22
# Day Ahead Optimizer
3+
# 2025.12.0
4+
- Fixed several issues heatpump and boiler
5+
- Implemented min_run_length heatpump voor power-adjustment
6+
- Configured energytaxes for 2026 in options_start.json and options_example.json
7+
- Fixed potential index-error boiler-module
8+
- Prevent scheduling extra consumption boiler after heating boiler
9+
- Made boiler setting "heating allowed below" flex setting
10+
- When boiler_act_temp is below lower limit (=setpoint - hysterese) direct heating will be activated.
11+
- Log warning when degreeday - factor is less than 0.1 kWh/K.day (reported bij @DaBit)
12+
- Fixed error when heat-demand is less than lowest day-production (reported bij @DaBit)
13+
- Fixed error when heat-demand is 0 kWh-th
14+
- Log warning when calculated power from Home Assistant is more than 50 kW-e (reported by @lievering)
15+
- Reduce number of blocks with low "min_run_length"
16+
- Fix error implementation "reduced hours" for "15min" interval (reported by @CrazyHenk44)
17+
- New line in logging with planned start- and end-time of charging ev (feature request @diamanten)
18+
- Fixed issue with heatpump when no heat is required (reported by @sailor_dg)
19+
320
# 2025.11.1
421
- upgrade python numpy-module
522
- upgrade debian-base<br>

dao/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: 刀 Day Ahead Optimizer
3-
version: 2025.11.1
3+
version: 2025.12.0
44
slug: day_ahead_opt
55
description: Home Assistant Community Add-ons for day ahead optimizations
66
url: https://github.com/corneel27/day-ahead

dao/data/prediction/models/.keep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

dao/prog/day_ahead.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def calc_optimum(
135135
self.notify(
136136
"Er ontbreken voor een aantal uur gegevens; er kan niet worden gerekend"
137137
)
138-
return
138+
return None
139139
if u_data <= 8 or u_prices <= 8:
140140
logging.warning(
141141
f"Er ontbreken voor een aantal uur meteogegevens "
@@ -409,7 +409,8 @@ def calc_optimum(
409409
hour = int(key)
410410
power = value / 1000
411411
for u in range(U):
412-
if uur[u] == hour:
412+
int_uur = uur[u] if self.interval == "1hour" else int(uur[u][0:2])
413+
if int_uur == hour:
413414
red_power[u] = power
414415
reduced_power.append(red_power)
415416
if reduced:
@@ -797,7 +798,7 @@ def calc_optimum(
797798
f"'min soc end opt' ({min_soc_end_opt}); "
798799
f"het programma kan nu geen optimale oplossing berekenem"
799800
)
800-
return
801+
return None
801802

802803
model += soc[b][U] >= max(opt_low_level[b] / 2, min_soc_end_opt)
803804
model += soc[b][U] <= max_soc_end_opt
@@ -1204,7 +1205,8 @@ def calc_optimum(
12041205
for j in range(U)[max(0, u - est_needed_intv[u]+1): u + 1]:
12051206
# print(f"len(est_needed_elec_st[j]): {len(est_needed_elec_st[j])}")
12061207
if est_needed_intv[u]>0 and u - j < len(est_needed_elec_st[j]):
1207-
print(f"j: {j}, est_needed_elec_st[j][u - j]: {est_needed_elec_st[j][u - j]}")
1208+
print(f"j: {j}, est_needed_elec_st[j][u - j]: "
1209+
f"{est_needed_elec_st[j][u - j]}")
12081210
"""
12091211
model += boiler_on[u] == xsum(
12101212
boiler_st[j]
@@ -1548,7 +1550,7 @@ def calc_optimum(
15481550
model.add_var(var_type=CONTINUOUS, lb=0) # , ub=max_power[e])
15491551
for _ in range(U)
15501552
]
1551-
for e in range(EV)
1553+
for _ in range(EV)
15521554
] # consumption vermogen
15531555
ev_accu_in = [
15541556
[
@@ -2154,7 +2156,8 @@ def calc_optimum(
21542156
if self.hp_adjustment == "on/off":
21552157
blocks_num = math.ceil(hp_hours / min_run_length)
21562158
else:
2157-
blocks_num = math.ceil(max(hours_avail / 4, hp_hours / min_run_length))
2159+
blocks_num = math.ceil(min(hours_avail / (3 + min_run_length), hp_hours / min_run_length))
2160+
# blocks_num = math.ceil(max(hours_avail / 4, hp_hours / min_run_length))
21582161
# if self.hp_adjustment!="on/off":
21592162
if blocks_num == 0:
21602163
logging.info(f'Omdat de wp meer dan 75% van de uren draait wordt de wp zonder '
@@ -2202,7 +2205,7 @@ def calc_optimum(
22022205
# eerste blok
22032206
block_len.append(int(first_block_len * 3600/self.interval_s))
22042207
# tussenliggende blokken
2205-
for j in range(blocks_num)[1:-1]:
2208+
for _ in range(blocks_num)[1:-1]:
22062209
block_len.append(int(min_run_length * 3600/self.interval_s))
22072210
# laatste
22082211
block_len.append(int(last_block_len * 3600/self.interval_s))
@@ -2785,15 +2788,15 @@ def calc_optimum(
27852788
logging.info(f"Rekentijd: {end_calc - start_calc:<5.2f} sec")
27862789
if model.num_solutions == 0:
27872790
logging.warning(f"Geen oplossing voor: {self.strategy}")
2788-
return
2791+
return None
27892792
elif self.strategy == "minimize consumption":
27902793
strategie = "minimale levering"
27912794
logging.info(f"Strategie: {strategie}")
27922795
model.objective = minimize(delivery)
27932796
model.optimize()
27942797
if model.num_solutions == 0:
27952798
logging.warning(f"Geen oplossing voor: {self.strategy}")
2796-
return
2799+
return None
27972800
min_delivery = max(0.0, delivery.x)
27982801
logging.info("Eerste berekening")
27992802
logging.info(f"Kosten (euro): {cost.x:<6.2f}")
@@ -2808,14 +2811,14 @@ def calc_optimum(
28082811
logging.warning(
28092812
f"Geen oplossing in na herberekening voor: {self.strategy}"
28102813
)
2811-
return
2814+
return None
28122815
logging.info("Herberekening")
28132816
logging.info(f"Kosten (euro): {cost.x:<6.2f}")
28142817
logging.info(f"Levering (kWh): {delivery.x:<6.2f}")
28152818
else:
28162819
logging.error("Kies een strategie in options")
28172820
# strategie = 'niet gekozen'
2818-
return
2821+
return None
28192822

28202823
# Suppress FutureWarning messages
28212824
import warnings
@@ -2826,7 +2829,7 @@ def calc_optimum(
28262829
logging.error(
28272830
f"Er is helaas geen oplossing gevonden, kijk naar je instellingen."
28282831
)
2829-
return
2832+
return None
28302833

28312834
# er is een oplossing
28322835
# afdrukken van de resultaten
@@ -3218,12 +3221,13 @@ def calc_optimum(
32183221

32193222
logging.info(
32203223
"\nCalculation profit after optimize in €\n"
3221-
f"Cost before optimize {old_cost_da: 7.2f}\n"
3224+
f"Cost before optimize {old_cost_da: 7.2f}\n"
32223225
f"Cost consumption {cost_consumption: 7.2f}\n"
32233226
f"Cycle cost {total_cycle_cost: 7.2f}\n"
32243227
f"Penalty cost {total_penalty_cost: 7.2f}\n"
32253228
f"Battery storage {battery_storage: 7.2f}\n"
32263229
f"Boiler storage {boiler_storage: 7.2f}\n"
3230+
f"Profit production {profit_production: 7.2f}\n"
32273231
f"Total {total_cost: 7.2f}\n"
32283232
f"Cost after optimize {cost.x: 7.2f}\n"
32293233
f"Profit: {old_cost_da - cost.x: 7.2f}"
@@ -3252,7 +3256,8 @@ def calc_optimum(
32523256
logging.debug("nr uur st on cons temp")
32533257
for u in range(U):
32543258
logging.debug(
3255-
f"{u:.0f} {uur[u]} {boiler_st[u].x:.0f} {boiler_on[u].x:.0f} {c_b[u].x:.2f} {boiler_temp[u].x:.2f}"
3259+
f"{u:.0f} {uur[u]} {boiler_st[u].x:.0f} {boiler_on[u].x:.0f} {c_b[u].x:.2f} "
3260+
f"{boiler_temp[u].x:.2f}"
32563261
)
32573262
logging.debug("\n")
32583263

@@ -3331,6 +3336,23 @@ def calc_optimum(
33313336
end=" ",
33323337
)
33333338
print(f" {c_ev[e][u].x:.3f} {p_ev[e][u].x:.3f}")
3339+
3340+
start_ev_laden = stop_ev_laden = None
3341+
for u in range(U):
3342+
if c_ev[e][u].x > 0:
3343+
if start_ev_laden is None:
3344+
start_ev_laden = tijd[u]
3345+
else:
3346+
if start_ev_laden is not None and c_ev[e][u-1].x > 0:
3347+
stop_ev_laden = tijd[u]
3348+
if start_ev_laden is not None:
3349+
if stop_ev_laden is None:
3350+
stop_ev_laden = tijd[U-1]+ dt.timedelta(seconds=self.interval_s)
3351+
logging.info(f"{self.ev_options[e]['name']} wordt geladen tussen "
3352+
f"{start_ev_laden} en {stop_ev_laden}")
3353+
else:
3354+
logging.info(f"Laden van {self.ev_options[e]['name']} is niet ingepland")
3355+
33343356
entity_charge_switch = self.ev_options[e]["charge switch"]
33353357
entity_charging_ampere = self.ev_options[e][
33363358
"entity set charging ampere"
@@ -3487,7 +3509,7 @@ def calc_optimum(
34873509
battery_state_on_value = self.config.get(
34883510
["entity set operating mode on"], self.battery_options[b], "Aan"
34893511
)
3490-
battery_state_off_value = entity_pv_switch = self.config.get(
3512+
battery_state_off_value = self.config.get(
34913513
["entity set operating mode off"], self.battery_options[b], "Uit"
34923514
)
34933515
bat_name = self.battery_options[b]["name"]
@@ -4380,6 +4402,7 @@ def calc_optimum(
43804402
plt.show()
43814403
plt.close("all")
43824404
self.notify("DAO calc afgerond", self.notification_berekening)
4405+
return None
43834406

43844407
def calc_optimum_debug(self):
43854408
self.debug = True

release-testing/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog 刀 DAO
22
# Day Ahead Optimizer
3+
4+
# 2025.12.0.rc8
5+
- Reduce number of blocks with low "min_run_length"
6+
- Fix error implementation "reduced hours" for "15min" interval (reported by @CrazyHenk44)
7+
- New line in logging with planned start- and end-time of charging ev (feature request @diamanten)
38
# 2025.12.0.rc7
49
- Fixed too much run-hours heatpump for on/off adjustment (reported by @sailor_dg)
510

release-testing/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: 刀 Day Ahead Optimizer (TESTING)
3-
version: 2025.12.0.rc7
3+
version: 2025.12.0.rc8
44
stage: experimental
55
slug: day_ahead_opt-testing
66
description: Beta version of DAO. Use only for testing!

0 commit comments

Comments
 (0)