EV-13 review: compare phase currents per phase; test a late read-back
A phase that drops out or comes back shifted the compressed current_a tuple and read as life, so a frozen charger never armed. ChargerReading.phase_a keeps L1/L2/L3 with None for a missing phase and the life test uses it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -166,6 +166,7 @@ class ChargerReading:
|
||||
# EV-13: when the sample was TAKEN, on the tracker's clock. None: the
|
||||
# caller's `now` (in the cycle that is the read's start, `now_mono`).
|
||||
taken_at: float | None = None
|
||||
phase_a: tuple = () # EV-13: L1, L2, L3 each, None if not read
|
||||
|
||||
|
||||
def _state_obj(obj):
|
||||
@@ -285,6 +286,7 @@ def reading_from_states(states: dict) -> ChargerReading:
|
||||
available=True, state=letter, connected=connected, charging=charging,
|
||||
power_w=power, energy_kwh=_kwh(states.get("energy")),
|
||||
current_a=currents, setpoint_a=_amps(states.get("current")),
|
||||
phase_a=tuple(_amps(states.get(k)) for k in ("l1", "l2", "l3")),
|
||||
allowed_a=_amps(states.get("readback")),
|
||||
phases_allowed=_phases(states.get("phases_read")),
|
||||
station_a=_first(_amps(states.get("station_active")),
|
||||
@@ -544,11 +546,10 @@ class AlfenHaDriver(ChargerDriver):
|
||||
"""EV-13: keep what this wait saw of energy, power and phase currents
|
||||
(never raises: a write does not depend on it)."""
|
||||
try:
|
||||
cur = tuple(a for a in (_amps(st.get(k)) for k in ("l1", "l2", "l3"))
|
||||
if a is not None)
|
||||
self.polls.append((self._clock(), ChargerReading(
|
||||
available=True, power_w=_watts(st.get("power")),
|
||||
energy_kwh=_kwh(st.get("energy")), current_a=cur)))
|
||||
energy_kwh=_kwh(st.get("energy")),
|
||||
phase_a=tuple(_amps(st.get(k)) for k in ("l1", "l2", "l3")))))
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
|
||||
@@ -656,8 +657,13 @@ CHARGING, WAITING, NONE_, FULL, UNREACH, SETUP, FAULT = (
|
||||
def _life_vals(r) -> tuple:
|
||||
"""EV-13: what shows a charger is alive: energy, power, three phase
|
||||
currents. None is "not read"."""
|
||||
cur = tuple(r.current_a or ())[:3]
|
||||
return (r.energy_kwh, r.power_w) + cur + (None,) * (3 - len(cur))
|
||||
cur = tuple(r.phase_a or ())
|
||||
if len(cur) != 3:
|
||||
# Only `current_a`, which leaves out a phase that is not read: which
|
||||
# phase is which is then known only when all three are there.
|
||||
cur = tuple(r.current_a or ())
|
||||
cur = cur if len(cur) == 3 else (None,) * 3
|
||||
return (r.energy_kwh, r.power_w) + cur
|
||||
|
||||
|
||||
def _alive(vals: tuple, pre: list) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user