EV-03: car charger seam, Alfen HA driver, read-only Car card
checks / unit (pull_request) Failing after 37m42s
infra-pin / fresh (pull_request) Successful in 2s

Read-only: nothing in this change writes to the charger.
- app/chargers.py: ChargerDriver, AlfenHaDriver, UnavailableCharger, ChargerReading, CarTracker
- options ev_charger/ev_current_entity/ev_max_a/ev_phases (default off), Settings group, validator, census
- Car card on Home, unreachable row and notification, two-writer info row, MQTT sensors
- car out of the House tile and the house profile
- tools/chargersim.py charger model, test_ev03.py

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ev03-dev
2026-11-15 09:52:15 +01:00
co-authored by Claude
parent 6bf37597f8
commit 89a2eb0b74
30 changed files with 2656 additions and 23 deletions
+44 -1
View File
@@ -15,7 +15,8 @@ from .freeze import rail_unreachable, rail_w
from .hass import OUTAGE
from .maintenance import IDLE
from .mqtt import (
announced_units, optional_keys, parse_command, unit_slugs, unit_state_key,
PAYLOAD_NONE, announced_units, optional_keys, parse_command, unit_slugs,
unit_state_key,
)
from . import peakguard
from . import pv as pv_read
@@ -135,6 +136,10 @@ class StatusMixin:
if "pv" in optional_keys(self.o):
values["pv"] = (None if self.pv_w is None
else round(self.pv_w, 1))
# EV-03: the car, only with a charger switched on (the same predicate
# that announces the three sensors). Absence is `None`, never 0.
if "car_state" in optional_keys(self.o):
values.update(self.car_values())
# ⚠️ ONLY when P1 ingestion is running: the ESP32's stale-input
# watchdog subscribes to sensor.goodwe_p1_sample_age and forces layer-1
# failsafe at max_age_s, so with meter_source off a published age would
@@ -161,6 +166,41 @@ class StatusMixin:
values.update(self.mode_values())
self.mqtt.publish(values)
# -- EV-03: the car charger ------------------------------------------------
def car_rows(self) -> list:
"""The charger's status rows: amber when it is not set up or does not
answer, grey while something else changes it."""
if not self.charger.configured():
return [{"ok": False, "warn": True, "id": "charger_setup",
"text": messages.row_charger_setup()}]
out = []
if self.car.unreachable(self.car_now()):
out.append({"ok": False, "warn": True, "id": "charger",
"text": messages.row_charger_unreach(
f"{brussels(self.car.bad_since_utc):%H:%M}")})
if self.car.other_writer(datetime.now(timezone.utc)):
out.append({"ok": True, "warn": True, "id": "charger_writer",
"text": messages.row_charger_writer()})
return out
def car_values(self) -> dict:
"""The MQTT values for the three car sensors."""
now = self.car_now()
state = self.car.status(now, self.charger.configured())
r = self.car.reading
down = state in (None, "unreach", "setup")
with homeview.in_lang("en"):
word = homeview.car_state_word(state)
return {
"car_state": word,
# `ABSENT_AS_UNKNOWN` stays the one PV key (test_pv.py): an absent
# car figure is HA's own "no value" payload, sent by name.
"car_power": (PAYLOAD_NONE if down or r is None
or r.power_w is None else round(r.power_w, 1)),
"car_today_kwh": (PAYLOAD_NONE if self.car.today_kwh is None
else round(self.car.today_kwh, 3)),
}
# -- UI ------------------------------------------------------------------
def checks(self, when: datetime | None = None) -> list:
"""The status rows. `when` is the reference time for anything billed by
@@ -613,6 +653,9 @@ class StatusMixin:
out.append({"ok": False, "warn": True, "id": "pv",
"text": messages.row_pv_stray(
_inv_list.index(ent) + 1)})
# EV-03: the car charger's rows, only with a charger switched on.
if self.car_enabled:
out.extend(self.car_rows())
return out
def status_payload(self, lang: str = "en") -> dict: