fix(planner): EV tolerance 'dost dobré' — konec honění posledních % do 100 %

needed_wh=0 když live_soc >= least(target,99) - charge_done_tolerance_pct (V107,
default 3 p.b.). Effective target zastropovaný na 99 (clamp) → bez věčného
mini-dobíjení a cyklování nabíječky. Ověřeno živě: session #6 needed_wh 1329→0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-14 22:23:38 +02:00
parent f70111f44b
commit a9a6a88a88
4 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,10 @@
-- EV: tolerance „dost dobré" pro deadline charging — nehonit posledních pár % do
-- targetu (taper region u plného auta). Řeší věčné mini-dobíjení odhalené live-SoC
-- fixem (live_soc clamp 99 vs target 100 → needed nikdy neklesne na 0 → cyklování
-- nabíječky, Tesla notifikace). needed_wh = 0 když live_soc >= least(target,99) tolerance.
alter table ems.asset_vehicle
add column if not exists charge_done_tolerance_pct numeric(4, 2) not null default 3.0;
comment on column ems.asset_vehicle.charge_done_tolerance_pct is
'Tolerance „dost dobré" pro deadline charging (procentní body). needed_wh=0 když live_soc >= least(target,99) tato tolerance — nehonit poslední taper k 100 % (zbytečné start/stop nabíječky a Tesla notifikace). 0 = tvrdě na target. Default 3 p.b.';

View File

@@ -75,6 +75,7 @@ as $fn$
v.battery_capacity_kwh,
v.default_target_soc_pct,
v.opportunistic_value_czk_kwh as v_opp,
coalesce(v.charge_done_tolerance_pct, 3.0) as charge_done_tolerance_pct,
ems.fn_ev_session_delivered_wh(es.charger_id, es.session_start) as live_delivered_wh
from ems.ev_session es
join ems.asset_ev_charger ch on ch.id = es.charger_id
@@ -103,12 +104,20 @@ as $fn$
when coalesce(c.target_soc_pct, c.default_target_soc_pct) is null then null
else c.target_deadline
end,
-- effective target zastropovaný na 99 (clamp live_soc) → bez věčného
-- mini-dobíjení u plného auta. „Dost dobré" tolerance: needed=0 když je
-- live_soc ve vzdálenosti tolerance od targetu (nehonit poslední taper →
-- žádné zbytečné start/stop nabíječky). 0 = tvrdě na target.
'energy_needed_wh', case
when c.target_deadline is null then 0::numeric
when coalesce(c.target_soc_pct, c.default_target_soc_pct) is null then 0::numeric
when c.live_soc_pct >=
least(coalesce(c.target_soc_pct, c.default_target_soc_pct)::numeric, 99)
- c.charge_done_tolerance_pct
then 0::numeric
else greatest(
0,
(coalesce(c.target_soc_pct, c.default_target_soc_pct)::numeric
(least(coalesce(c.target_soc_pct, c.default_target_soc_pct)::numeric, 99)
- c.live_soc_pct) / 100.0
* (c.battery_capacity_kwh * 1000)
)