EV-20 rig round 1: stuck check armed on the reading before the send; no amp ping-pong; ha_signed meter age
The stuck check's baseline is the signature of the latest reading taken before the send (kept at begin_write), never one that arrived while the write waited; a refused write's first post-send sample is its baseline (EV-36). After a step down, a step back up needs UP_HYST_W past the boundary. Solar's 15 s meter-age gate applies only where the age measures arrival; on ha_signed it is the source's meter_max_age_s. Rows in test_ev20_rig.py; harness modes for the rig's interleave and an on-change meter. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
@@ -141,13 +141,18 @@ def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
margin=100, opts=None, plug=True, setpoint=0, phases=1, mode="solar",
|
||||
first="batteries", events=None, sim=None, store=None, race=False,
|
||||
on_cycle=None, car_phases=3, t0=0.0, caps=None, finale=None,
|
||||
rows=False, plant_cls=None):
|
||||
rows=False, plant_cls=None, beside=False, meter_change=False):
|
||||
"""Run it. Returns a dict: plant, controller, charger, notifications with
|
||||
their second, and a per-second trace. `caps` ({unit: kWh}) lets each
|
||||
battery's level move with what it charges or gives; without it the
|
||||
levels stand still. `finale(plant, c)` (a coroutine) runs after the last
|
||||
cycle, on the model clock (a shutdown, for instance); `rows=True` keeps
|
||||
the ids of the amber and red rows of every cycle in the trace."""
|
||||
the ids of the amber and red rows of every cycle in the trace.
|
||||
`beside=True` plays the production interleave the rig showed (EV-20 rig
|
||||
round 1): a write that waits for its read-back is still waiting when the
|
||||
next cycle reads the charger; it resumes after that read.
|
||||
`meter_change=True` publishes the meter as Home Assistant does on
|
||||
`ha_signed`: only when the whole-watt value changes."""
|
||||
ratings = ratings or {"a": 5000.0, "b": 4600.0}
|
||||
socs = socs or {u: 50.0 for u in ratings}
|
||||
sim = sim or SimCharger(setpoint_a=setpoint)
|
||||
@@ -205,6 +210,19 @@ def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
plant.t = clock[0]
|
||||
c.charger._sleep = sleep
|
||||
c.charger._clock = lambda: clock[0]
|
||||
if beside:
|
||||
gate = asyncio.Event()
|
||||
|
||||
async def bsleep(_s):
|
||||
gate.clear()
|
||||
await gate.wait()
|
||||
|
||||
async def settle():
|
||||
gate.set()
|
||||
for _ in range(8):
|
||||
await asyncio.sleep(0)
|
||||
c.charger._sleep = bsleep
|
||||
c.car_settle = settle
|
||||
real_dt = main_files.live.datetime
|
||||
|
||||
class _DT(real_dt):
|
||||
@@ -224,7 +242,10 @@ def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
await r
|
||||
sim.tick(1.0)
|
||||
ts = t - SAMPLE_LEAD_S
|
||||
if plant.meter_on and not plant.ha_down:
|
||||
if plant.meter_on and not plant.ha_down and not (
|
||||
meter_change
|
||||
and round(plant.grid(ts)) == round(plant.meter)
|
||||
and t > t0):
|
||||
plant.meter = plant.grid(ts)
|
||||
imp, exp = split_signed(plant.meter)
|
||||
c.p1.submit(make_sample(
|
||||
|
||||
Reference in New Issue
Block a user