Tesla charge_limit_soc = strop, ne cíl session
Patch po příjezdu přepisoval target_soc_pct limitem auta (LFP 100 %) a zahazoval kaskádu fn_ev_session_defaults (default vozidla 30 %) — auto by se v noci tlačilo do plna ze sítě proti vůli majitele (session #2 dnes). Nově se target snižuje jen pokud je limit auta POD ním; fn_tesla_arrival_context vrací i target_soc_pct session. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -216,8 +216,13 @@ async def _patch_session_from_tesla(
|
||||
)
|
||||
|
||||
patch: dict = {"soc_at_connect_pct": state["battery_level"]}
|
||||
if state.get("charge_limit_soc"):
|
||||
patch["target_soc_pct"] = state["charge_limit_soc"]
|
||||
# Tesla charge_limit_soc je STROP (nad něj auto nenabije), NE cíl —
|
||||
# cíl drží kaskáda fn_ev_session_defaults (weekly/forecast/default
|
||||
# vozidla, např. 30 %). Snižovat target jen když limit auta je POD ním.
|
||||
limit = state.get("charge_limit_soc")
|
||||
current_target = ctx.get("target_soc_pct")
|
||||
if limit and current_target is not None and float(current_target) > float(limit):
|
||||
patch["target_soc_pct"] = limit
|
||||
import json as _json
|
||||
await fetch_json(
|
||||
conn,
|
||||
|
||||
@@ -49,13 +49,14 @@ as $fn$
|
||||
'vin', v.vin,
|
||||
'battery_capacity_kwh', v.battery_capacity_kwh,
|
||||
'session_id', s.id,
|
||||
'soc_at_connect_pct', s.soc_at_connect_pct
|
||||
'soc_at_connect_pct', s.soc_at_connect_pct,
|
||||
'target_soc_pct', s.target_soc_pct
|
||||
), '{}'::jsonb)
|
||||
from ems.asset_ev_charger c
|
||||
join ems.asset_vehicle v
|
||||
on v.site_id = c.site_id and v.default_charger_id = c.id and v.active
|
||||
left join lateral (
|
||||
select es.id, es.soc_at_connect_pct
|
||||
select es.id, es.soc_at_connect_pct, es.target_soc_pct
|
||||
from ems.ev_session es
|
||||
where es.charger_id = c.id and es.session_end is null
|
||||
order by es.id desc
|
||||
|
||||
Reference in New Issue
Block a user