Branch 3: charge-slot-budget v R__063 + odstranit v58 pro BA81/KV1 + fixed evening push
Some checks failed
CI and deploy / migration-check (push) Failing after 25s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-06-06 22:32:48 +02:00
parent 09bca0a903
commit a7879f1141
7 changed files with 252 additions and 162 deletions

View File

@@ -337,22 +337,32 @@ def _select_charge_slots(
elif purchase_pricing_mode == "fixed" and any(
float(s.sell_price) > float(s.buy_price) + degrad for s in slots
):
min_sell_pos = min(
float(s.sell_price) for s in slots if float(s.sell_price) >= 0.0
)
am_candidates = [
(t, getattr(slots[t], "is_predicted_price", False))
(
t,
getattr(slots[t], "is_predicted_price", False),
float(slots[t].sell_price),
)
for t in range(len(slots))
if _prague_hour(slots[t]) < 12
and float(slots[t].sell_price) >= 0.0
and float(slots[t].sell_price) <= min_sell_pos + degrad + 0.05
]
am_candidates.sort(
key=lambda x: (
_grid_sort_key(x[0], x[1], 0.0)[0],
_grid_sort_key(x[0], x[1], 0.0)[1],
_grid_sort_key(x[0], x[1], 0.0)[2],
_grid_sort_key(x[0], x[1], x[2])[0],
_grid_sort_key(x[0], x[1], x[2])[1],
_grid_sort_key(x[0], x[1], x[2])[2],
x[2],
x[0],
)
)
cum = 0.0
grid_am = 0
for t, _pred in am_candidates:
for t, _pred, _sell in am_candidates:
if cum >= chg_am or per_slot_full_wh <= 0 or grid_am >= cap_am:
break
selected.add(t)
@@ -369,21 +379,28 @@ def _select_charge_slots(
),
)
pm_candidates = [
(t, getattr(slots[t], "is_predicted_price", False))
(
t,
getattr(slots[t], "is_predicted_price", False),
float(slots[t].sell_price),
)
for t in range(len(slots))
if _prague_hour(slots[t]) >= 12
and float(slots[t].sell_price) >= 0.0
and float(slots[t].sell_price) <= min_sell_pos + degrad + 0.05
]
pm_candidates.sort(
key=lambda x: (
_grid_sort_key(x[0], x[1], 0.0)[0],
_grid_sort_key(x[0], x[1], 0.0)[1],
_grid_sort_key(x[0], x[1], 0.0)[2],
_grid_sort_key(x[0], x[1], x[2])[0],
_grid_sort_key(x[0], x[1], x[2])[1],
_grid_sort_key(x[0], x[1], x[2])[2],
x[2],
x[0],
)
)
cum = 0.0
grid_pm = 0
for t, _pred in pm_candidates:
for t, _pred, _sell in pm_candidates:
if cum >= chg_pm or per_slot_full_wh <= 0 or grid_pm >= cap_pm:
break
selected.add(t)
@@ -398,15 +415,22 @@ def _select_charge_slots(
fso = _future_sell(slots, t)
if (
pv_surplus_w > 0
and float(s.sell_price) >= float(s.buy_price) - degrad
and (
float(s.sell_price) < 0
purchase_pricing_mode == "fixed"
or float(s.sell_price) >= float(s.buy_price) - degrad
)
and (
purchase_pricing_mode == "fixed"
or float(s.sell_price) < 0
or float(s.sell_price) >= fso - degrad
)
):
pv_candidates.append((t, _store_score(slots, t), float(pv_surplus_w)))
pv_candidates.sort(key=lambda x: (-x[1], x[0]))
if purchase_pricing_mode == "fixed":
pv_candidates.sort(key=lambda x: (float(slots[x[0]].sell_price), x[0]))
else:
pv_candidates.sort(key=lambda x: (-x[1], x[0]))
cum = 0.0
for t, _score, pv_surplus_w in pv_candidates:
if cum >= pv_layer_cap: