Files
goodwe-addon/goodwe_controller/test_ev20_long_car.py
T
Claude 226e5a1e8b
checks / unit (pull_request) Successful in 57m6s
infra-pin / fresh (pull_request) Successful in 3s
EV-20: Car Solar mode, spare sun to the car (charging only)
Solar as a second writer next to Manual (carmode.SolarPlan, SolarWriter on
ManualWriter's one write site, safe phase sequence and other-writer watch):
signed spare, Batteries first on the batteries' ratings, the margin, whole
amps rounded down, the 30 s / 1 A rule, start and pause dwells, auto phases,
a one-phase car. Every way out ends at 0 A, retried by EV-04's rule; at
shutdown before the inverters, three tries inside 15 s (D3); start-up and a
returning charger or HA write 0 A first (D2); never over another writer's
hold. The peak guard treats a Solar car as a Manual car (D1 wording). Solar
kWh sensor and card line; select.goodwe_car_sun_first; ev_margin_w,
ev_start_min, ev_pause_min with config, validator, translations, DOCS,
DECISIONS and CHANGELOG.

Checks: test_ev20.py, test_ev20_exits.py, test_ev20_writers.py,
test_ev20_guard.py, test_ev20_long.py, test_ev20_long_car.py,
test_ev20_fuzz.py (harness tools/ev20_sun.py, ev20_kit.py, ev20_day.py);
test_ev03/test_ev04 no longer use Solar as the refused example.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
2026-11-22 20:31:26 +01:00

53 lines
1.4 KiB
Python

"""EV-20: T53, the acceptance sim day, Car first. `python3 -B test_ev20_long_car.py`
The day and what is graded are in `tools/ev20_day.py`: the real Controller,
N=2, 08:00-18:00 of sun with 12 clouds of 1 to 8 minutes, a house of 0.4 to
2.5 kW with three +3 kW steps; `step` over the day, `step_race` over three
hours, a car-Off twin around the house steps.
Batteries first is test_ev20_long.py.
Mutating a module this file grades? Read MUTATION.md first (purge __pycache__).
"""
import logging
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(HERE, "tools"))
import ev20_day # noqa: E402
fails = []
def check(name, cond):
print(f" {'ok ' if cond else 'FAIL'} {name}")
if not cond:
fails.append(name)
class _Log(logging.Handler):
def __init__(self):
super().__init__(logging.DEBUG)
self.tb = []
def emit(self, r):
if r.exc_info:
self.tb.append(r.getMessage())
LOG = _Log()
_g = logging.getLogger("goodwe")
_g.addHandler(LOG)
_g.setLevel(logging.DEBUG)
_g.propagate = False
print("T53: THE SIM DAY, CAR FIRST")
ev20_day.run_day("car", check)
check("T53: no Traceback", LOG.tb == [])
print(f"\n{'all passed' if not fails else f'{len(fails)} FAILED'}")
for f in fails:
print(" FAIL:", f)
sys.exit(1 if fails else 0)