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)
|
||||
|
||||
Reference in New Issue
Block a user