EV-03 round 4: a power entity that cannot be believed is unreachable
- every HA power unit is accepted and converted (mW, W, kW, MW), in the probe and in the reading - a power entity that answers in another unit, with no unit, or not as a number makes the reading unavailable: after 30 s it is "Charger not reachable" (amber row, WARNING, notification after 5 min), with a Why that names the cause (EN and NL) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -82,12 +82,12 @@ ROLES = {
|
||||
#: a missing one of these refuses the charger (not the add-on). `power` is one
|
||||
#: of them: without it the car's power is unknown for good, House would show no
|
||||
#: reading for ever and the house profile would drop every sample.
|
||||
#: The power entity must also read in W or kW (`POWER_UNITS`).
|
||||
#: The power entity must also read in a Home Assistant power unit (`POWER_UNITS`).
|
||||
REQUIRED = ("current", "readback", "state", "power")
|
||||
_SETPOINT_RE = re.compile(r"^number\.(?P<x>.+)_" + SETPOINT_SUFFIX + "$")
|
||||
|
||||
_ROLE_ORDER = tuple(ROLES)
|
||||
POWER_UNITS = ("W", "kW")
|
||||
POWER_UNITS = ("mW", "W", "kW", "MW") # every HA power unit, converted
|
||||
|
||||
|
||||
def census_key(entity) -> str:
|
||||
@@ -155,7 +155,7 @@ def _amps(obj):
|
||||
return None
|
||||
|
||||
|
||||
_W_PER = {"W": 1.0, "kW": 1000.0}
|
||||
_W_PER = {"mW": 0.001, "W": 1.0, "kW": 1000.0, "MW": 1000000.0}
|
||||
|
||||
|
||||
def _watts(obj):
|
||||
@@ -224,6 +224,12 @@ def reading_from_states(states: dict) -> ChargerReading:
|
||||
why = ("login off" if not gone else
|
||||
"no answer from " + ", ".join(gone))
|
||||
return ChargerReading(available=False, why=why)
|
||||
# A power entity that answers but cannot be believed (a unit the add-on
|
||||
# cannot convert, no unit, not a number) makes the reading UNAVAILABLE, so
|
||||
# it goes down the visible "Charger not reachable" path instead of leaving
|
||||
# the car's power unknown for good with nothing said.
|
||||
if _watts(states.get("power")) is None:
|
||||
return ChargerReading(available=False, why="power unit")
|
||||
letter = mode3_letter(txt("state"))
|
||||
disp = txt("display")
|
||||
cls = display_class(disp)
|
||||
|
||||
@@ -161,7 +161,7 @@ class InputsMixin:
|
||||
and not pr.required_missing:
|
||||
why = "unit"
|
||||
_LOG.warning("The car charger is not set up, because its power "
|
||||
"does not read in W or kW: CHARGER_POWER_UNIT.")
|
||||
"has no power unit: CHARGER_POWER_UNIT.")
|
||||
_LOG.debug("The charger power entity reads in %r.", pr.power_unit)
|
||||
elif not pr.ok:
|
||||
why = "not_found"
|
||||
|
||||
@@ -1261,6 +1261,9 @@ def _car_big(key, c, r, good):
|
||||
def _car_why(key, c, good):
|
||||
brand = (getattr(c.charger, "brand", "") or "Alfen")
|
||||
if key == "unreach":
|
||||
r = c.car.reading
|
||||
if r is not None and r.why == "power unit":
|
||||
return _t("car.why.unreach_unit")
|
||||
a = None if good is None else good.setpoint_a
|
||||
if a is None and good is not None:
|
||||
a = good.allowed_a
|
||||
|
||||
@@ -312,9 +312,10 @@
|
||||
"none": "No car is connected.",
|
||||
"full": "The car stopped charging by itself.",
|
||||
"unreach_a": "The charger keeps its last setting, {a} A. Check the {brand} integration in Home Assistant.",
|
||||
"unreach_unit": "The charger's power is in a unit the add-on cannot use. Check it in Home Assistant.",
|
||||
"unreach": "The add-on cannot read the charger. Check the {brand} integration in Home Assistant.",
|
||||
"not_found": "The add-on cannot find the charger. Check the current setting entity in Settings.",
|
||||
"unit": "The charger power does not read in W or kW. Check the charger in Settings.",
|
||||
"unit": "The charger power has no power unit. Check the charger in Settings.",
|
||||
"limit": "The charger limit is above what the charger allows. Lower it in Settings.",
|
||||
"name": "The current setting entity does not fit the charger. Check it in Settings.",
|
||||
"fault": "The charger reports a fault. Check it at the charger itself.",
|
||||
|
||||
@@ -266,9 +266,10 @@
|
||||
"none": "Er is geen auto aangesloten.",
|
||||
"full": "De auto is zelf gestopt met laden.",
|
||||
"unreach_a": "De laadpaal houdt haar laatste instelling, {a} A. Controleer de {brand}-integratie in Home Assistant.",
|
||||
"unreach_unit": "De laadpaal meldt vermogen in een onbruikbare eenheid. Controleer de eenheid in Home Assistant.",
|
||||
"unreach": "De add-on kan de laadpaal niet lezen. Controleer de {brand}-integratie in Home Assistant.",
|
||||
"not_found": "De add-on vindt de laadpaal niet. Controleer de entiteit van de laadstroom bij Instellingen.",
|
||||
"unit": "Het vermogen van de laadpaal is niet in W of kW. Controleer de laadpaal bij Instellingen.",
|
||||
"unit": "Het vermogen van de laadpaal heeft geen vermogenseenheid. Controleer de laadpaal bij Instellingen.",
|
||||
"limit": "De laadpaalgrens is hoger dan de laadpaal toestaat. Verlaag ze bij Instellingen.",
|
||||
"name": "De entiteit van de laadstroom past niet bij de laadpaal. Controleer ze bij Instellingen.",
|
||||
"fault": "De laadpaal meldt een storing. Controleer ze aan de laadpaal zelf.",
|
||||
|
||||
@@ -2049,10 +2049,10 @@ def _charger_notes(notes, opts: dict, entities: dict) -> None:
|
||||
"ook kan gebruiken.")
|
||||
if look.get("power_unit") is not None:
|
||||
_advise(notes, "warn", key,
|
||||
"The charger's power does not read in W or kW, so the "
|
||||
"The charger's power does not read in a power unit, so the "
|
||||
"charger is not used.",
|
||||
nl="Het vermogen van de laadpaal is niet in W of kW, dus ze "
|
||||
"wordt niet gebruikt.")
|
||||
nl="Het vermogen van de laadpaal heeft geen vermogenseenheid, dus "
|
||||
"ze wordt niet gebruikt.")
|
||||
lim = look["limit_a"]
|
||||
if look["ok"]:
|
||||
have = {r for r, _e in look["found"]}
|
||||
|
||||
Reference in New Issue
Block a user