SAFETY-118: read the peak forecast in its own unit
checks / unit (pull_request) Successful in 40m20s
infra-pin / fresh (pull_request) Successful in 1s

peak_forecast_entity is read through pv.watts() by its unit_of_measurement;
the abs(raw) < 50 size rule is gone. No unit or a non-power unit means the
forecast is not used, with one warning per cause. The validator no longer
claims a kW sensor is taken as watts for this entity.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-10-16 16:00:34 +02:00
co-authored by Claude
parent 780c1f67bb
commit f0b4e68e49
11 changed files with 415 additions and 16 deletions
@@ -105,6 +105,13 @@ class _Hass:
return self.power(u)
return None
async def state(self, e):
"""SAFETY-118: the peak forecast is read as a state object; every
number this rig serves is in watts."""
v = await self.number(e)
return None if v is None else {
"state": str(v), "attributes": {"unit_of_measurement": "W"}}
async def set_number(self, e, v):
self.cmd[e[-1]] = float(v)
return True