EV-03 round 3: the power entity is required and reads in W or kW
checks / unit (pull_request) Successful in 27m42s
infra-pin / fresh (pull_request) Successful in 1s

A charger with no usable power entity is refused as "not set up", like a
missing setpoint, read-back or state entity, so House and the house profile
behave as with no charger. An entity that is merely unavailable at probe time
is still the unreachable path. NL: help text "met rust", chip "Laadpaalstoring".

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ev03-dev
2026-11-15 13:35:09 +01:00
co-authored by Claude
parent 678ea13895
commit 918d44ab33
8 changed files with 166 additions and 20 deletions
+108 -4
View File
@@ -981,7 +981,7 @@ def bad_power(kind):
CLOCK[0] = 1000.0 + 8
asyncio.run(rin(c_, 1008.0)) # 1 s after the good one
res["fresh"] = c_.car.fresh(CLOCK[0])
res["avail"] = c_.car.reading.available and c_.car.reading.power_w is None
res["avail"] = c_.car.reading.power_w is None
res["term"] = c_.car_term()
res["now"] = c_.status_payload()["now"]
res["card"] = c_.status_payload()["car"]
@@ -995,8 +995,8 @@ def bad_power(kind):
for kind in ("unavailable", "wrong unit"):
r_ = bad_power(kind)
check(f"{kind}: the reading is available with no power, and still inside "
f"stale_s (the case that raised)", r_["err"] is None
check(f"{kind}: the reading carries no power and is still inside stale_s "
f"(the case that raised)", r_["err"] is None
and r_.get("fresh") is True and r_.get("avail") is True)
check(f"{kind}: car_term, /status, the trade cycle and the MQTT values do "
f"not raise ({r_['err']})", r_["err"] is None)
@@ -1033,13 +1033,117 @@ check("fault card (EN): chip, big line, Why, amber",
and pf["car"]["why"] == "The charger reports a fault. Check it at the "
"charger itself.")
pfn = c_f.status_payload(lang="nl")
check("fault card (NL)", pfn["car"]["chip"] == "Laadpaal storing"
check("fault card (NL)", pfn["car"]["chip"] == "Laadpaalstoring"
and pfn["car"]["big"] == "De laadpaal meldt een storing."
and pfn["car"]["why"] == "De laadpaal meldt een storing. Controleer ze "
"aan de laadpaal zelf.")
check("the MQTT state says it too", c_f.car_values()["car_state"]
== "Charger fault")
# --------------------------------------------------------------------------- #
print("\n11. ROUND 3: THE POWER ENTITY IS REQUIRED, AND READS IN W OR kW")
# --------------------------------------------------------------------------- #
PW = "sensor.wallbox_active_power_total_socket_1"
rows_all = {eid: {"entity_id": eid, "state": s["state"],
"unit": s["attributes"].get("unit_of_measurement")}
for eid, s in SimCharger().states().items()}
no_power = {k: v for k, v in rows_all.items() if k != PW}
look = validate.charger_probe_for(SET, no_power)
check("the probe refuses a charger with no power entity",
not look["ok"] and ["power", PW] in look["missing"])
look = validate.charger_probe_for(SET, dict(rows_all, **{PW: dict(
rows_all[PW], unit="V")}))
check("...and one whose power reads in a wrong unit (V)",
not look["ok"] and look["power_unit"] == "V")
check("...and one with no unit at all",
validate.charger_probe_for(SET, dict(rows_all, **{PW: dict(
rows_all[PW], unit=None)}))["power_unit"] == "none")
check("kW is accepted (converted), W too",
validate.charger_probe_for(SET, dict(rows_all, **{PW: dict(
rows_all[PW], unit="kW")}))["ok"]
and validate.charger_probe_for(SET, rows_all)["ok"])
look = validate.charger_probe_for(SET, dict(rows_all, **{PW: dict(
rows_all[PW], state="unavailable", unit=None)}))
check("a power entity that is UNAVAILABLE at probe time is not a refusal (it "
"is the unreachable path)", look["ok"] and not look["missing"])
nts = validate.config_notes(CAR, entities=no_power)
check("the settings note for the missing power entity says the charger is not "
"used (a warning, not info)",
any(n.tier == "warn" and PW in n.text and "not used" in n.text
for n in nts))
nts = validate.config_notes(CAR, entities=dict(rows_all, **{PW: dict(
rows_all[PW], unit="V")}))
check("...and so does a wrong unit",
any(n.tier == "warn" and "W or kW" in n.text for n in nts))
class Hide(Site):
"""The site, with some of the charger's entities hidden or changed."""
def __init__(self, charger, hide=(), unit=None, **kw):
super().__init__(charger, **kw)
self.hide, self.unit = set(hide), unit
def _all(self):
out = {k: v for k, v in super()._all().items() if k not in self.hide}
if self.unit and PW in out:
out[PW] = dict(out[PW], attributes={"unit_of_measurement":
self.unit})
return out
def world(site_factory, opts, n=10):
"""(controller, the Home now block, the last profile sample)."""
del samples[:]
sim_ = SimCharger()
sim_.plug_in()
sim_.set_phases(3)
sim_.set_current(10)
site_ = site_factory(sim_)
c_ = build(dict(opts, pv_forecast_entity="sensor.fc",
battery_modes_enabled=True), site_)
c_.house_profile = _HP()
asyncio.run(run_cycles(c_, site_, n=n, sim=sim_))
return c_, c_.status_payload(), samples[-1] if samples else "none"
c_none, p_none, s_none = world(lambda s_: Site(s_, grid=7500.0, pv=500.0),
BASE)
for why, factory, want in (
("no power entity", lambda s_: Hide(s_, hide={PW}, grid=7500.0,
pv=500.0), "not_found"),
("a power entity in V", lambda s_: Hide(s_, unit="V", grid=7500.0,
pv=500.0), "unit")):
c_x, p_x, s_x = world(factory, CAR)
check(f"{why}: the charger is refused as 'not set up' ({c_x.charger_refused})",
c_x.charger_refused == want and not c_x.charger.configured()
and p_x["car"]["state"] == "setup"
and p_x["car"]["chip"] == "Charger not set up")
check(f"{why}: House and the house profile are as with no charger at all "
f"(House {p_x['now']['house_w']}, sample {s_x})",
p_x["now"] == p_none["now"] and s_x == s_none
and p_x["now"]["house_w"] is not None and s_x is not None)
check(f"{why}: the add-on still runs (the inverter is written) and one "
f"amber row says so", any(e == "number.sp" for e, _v in
c_x.hass.sets)
and [x["id"] for x in c_x.checks() if x["id"].startswith("charger")]
== ["charger_setup"])
check("the unit refusal's Why is plain and in both languages",
"does not read in W or kW" in p_x["car"]["why"]
and "niet in W of kW" in c_x.status_payload(lang="nl")["car"]["why"])
# unavailable at start: NOT refused, the unreachable path
c_u, p_u, _s = world(lambda s_: Hide(s_, grid=7500.0, pv=500.0), CAR, n=3)
sim_u = SimCharger()
sim_u.plug_in()
sim_u.go_unavailable()
site_u = Site(sim_u)
c_u2 = build(CAR, site_u)
asyncio.run(run_cycles(c_u2, site_u, n=40, sim=sim_u))
check("a charger that is unavailable from the first read is not refused; it "
"is the unreachable path", c_u2.charger_refused is None
and c_u2.charger.configured()
and c_u2.status_payload()["car"]["state"] == "unreach")
print()
if fails:
print(f"{len(fails)} FAILED")