UX-09: Details link for current HA, "would" in shadow mode, plain terms
checks / unit (pull_request) Successful in 8m50s
infra-pin / fresh (pull_request) Successful in 2s

- Details link: /config/app/<slug>/documentation on HA 2026.2+ (the old
  /hassio/addon path is a 404 from 2026.5), /hassio/addon on 2026.1 and
  older. Slug from GET /addons/self/info, version from GET /info, hostname
  as fallback.
- Shadow mode: the over-rating alarm and row say what would have been sent,
  the peak alarm no longer says the battery is giving all it can.
- "controller" -> "the add-on" / "control". Settings named by their labels;
  four labels changed to match (Peak reserve, Battery level entity, Solar
  production ..., Reversed-sign solar entities).
- Shadow banner and inverter link notes moved to messages.py and checked.
- DOCS Notifications and Status page rewritten for home owners, with a
  "For installers" part each. Allowlist 168 -> 167.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LyR88rXETvwhTgx6yHE39p
This commit is contained in:
2026-09-27 04:10:39 +02:00
co-authored by Claude Opus 5.5
parent d57767fe38
commit 00e3ee9de8
16 changed files with 666 additions and 264 deletions
+12 -9
View File
@@ -123,6 +123,7 @@ from datetime import datetime
from .clamp import ClampResult
from .delivery import DeliveryConfig, DeliveryWatchdog
from . import messages
# SAFETY-37. The freshness policy, and the ONE place its bounds are written.
# freshness.py imports nothing from this package, so the direction is one-way.
from .freshness import BOUNDS, Freshness
@@ -410,18 +411,20 @@ class Inverter:
return self.batt_fresh.note(self.name)
def link_note(self, now: datetime) -> str:
"""One line for the status page. Empty when there is nothing to say."""
"""One line for the status page. Empty when there is nothing to say.
The words are `app/messages.py`'s (UX-09). main.py colours the row red
exactly when `is_live()` is False.
"""
if not self.has_writer():
return (f"{self.name}: NO SETPOINT ENTITY - this controller cannot "
f"command it, and the site refuses rather than running at "
f"part strength")
live, why = self.is_live(now)
return messages.row_no_setpoint(self.name)
live, _why = self.is_live(now)
held = (0.0 if self.rejected_since is None
else (now - self.rejected_since).total_seconds())
if not live:
return f"{self.name}: NOT COMMANDABLE - {why}"
return messages.row_not_controllable(self.name, held, LINK_STALE_S)
if self.rejected_since is not None:
held = (now - self.rejected_since).total_seconds()
return (f"{self.name}: writes rejected for {held:.0f} s - still "
f"commandable until {LINK_STALE_S:.0f} s")
return messages.row_commands_refused(self.name, held, LINK_STALE_S)
return ""
def __repr__(self) -> str:
+44 -7
View File
@@ -3796,7 +3796,8 @@ class Controller:
# UX-08: the words are messages.output_clamp()'s; the numbers are the
# ones `reason` was written from (ClampWatchdog.facts), asked first.
await self.hass.call("persistent_notification", "create",
messages.output_clamp(self.clamp_wd.facts).data())
messages.output_clamp(self.clamp_wd.facts,
shadow=self.shadow).data())
async def check_peak_saturated(self) -> None:
"""SAFETY-07. Alarm ONLY when the guard has run out of inverter.
@@ -3839,7 +3840,8 @@ class Controller:
# here - check_meter_frozen() gives the reasoning. A saturated peak guard
# is not a frozen meter and is not an out-of-range setpoint.
await self.hass.call("persistent_notification", "create",
messages.peak_saturated(g.ceiling_w).data())
messages.peak_saturated(
g.ceiling_w, shadow=self.shadow).data())
async def check_peak_floor_limited(self) -> None:
"""SAFETY-24. Alarm when the EMS SoC floor stops the guard shaving.
@@ -4797,9 +4799,14 @@ class Controller:
# `live_units()` has stopped listing has had its share handed to its
# siblings, or - at a roster of one - has taken the site to 0 W. A
# dropped link that shows nothing on the page reads as a healthy site.
for note in self.liveness_notes():
out.append({"ok": False, "warn": "NOT COMMANDABLE" not in note,
"text": note})
# Red only for a unit that is no longer live; the rest are amber.
# The same notes, in the same order, as `liveness_notes()`.
_now = datetime.now(timezone.utc)
for inv in self.inverters:
for note, red in ((inv.link_note(_now), not inv.is_live(_now)[0]),
(inv.stale_note(), False)):
if note:
out.append({"ok": False, "warn": not red, "text": note})
# SAFETY-03. Red while an over-rating clamp is engaged (amber for the
# integrator bound, SAFETY-40), and the engagement COUNT is shown even
@@ -4814,8 +4821,8 @@ class Controller:
if _cw.active and _cw.bug:
out.append({"ok": False, "warn": False, "id": "power_too_high",
"banner": messages.banner_power_too_high(),
"text": messages.row_power_too_high(_cw.facts,
_cw.over_rating)})
"text": messages.row_power_too_high(
_cw.facts, _cw.over_rating, shadow=self.shadow)})
elif _cw.active:
# SAFETY-40: the integrator bound alone is amber, not red.
out.append({"ok": False, "warn": True, "id": "not_keeping_up",
@@ -5363,6 +5370,30 @@ def control_task_done(task: asyncio.Task, *, controller, stop: asyncio.Event,
stop.set()
async def docs_link_facts(session, token: str) -> dict:
"""`{slug, ha_version}` from the Supervisor, each None when unreadable.
`GET /addons/self/info` and `GET /info` are on the Supervisor's bypass
list for an add-on's own token, so they need no role (see selfconfig.py).
"""
out = {"slug": None, "ha_version": None}
for key, url, field in (("slug", "http://supervisor/addons/self/info",
"slug"),
("ha_version", "http://supervisor/info",
"homeassistant")):
try:
async with session.get(url, timeout=10, headers={
"Authorization": f"Bearer {token}"}) as r:
body = await r.json(content_type=None)
data = body.get("data", body) if isinstance(body, dict) else {}
out[key] = data.get(field) if isinstance(data, dict) else None
except Exception as err: # noqa: BLE001 - a link, never a stop
_LOG.info("docs link: %s unreadable (%s)", url, err)
_LOG.info("docs link: slug %s, Home Assistant %s", out["slug"],
out["ha_version"])
return out
async def amain() -> None:
opts = load_options()
logging.basicConfig(
@@ -5394,6 +5425,12 @@ async def amain() -> None:
except Exception as _e: # noqa: BLE001
_LOG.error("core api probe failed: %s", _e)
# UX-09: the Details link in every notification needs this add-on's
# slug and Home Assistant's version (see messages.docs_url()). Both
# are best effort: without them the link falls back to the hostname,
# or to naming the section only.
messages.set_site(**await docs_link_facts(session, _tok))
# ⚠️ THE STARTUP GATE (CFG-01). Nothing below this line may run on a
# configuration validate.py rejects - specs §1.5: a config the system
# cannot honour is refused at startup, not survived at runtime.
+196 -72
View File
@@ -37,25 +37,60 @@ def names(items) -> str:
return ", ".join(items[:-1]) + " and " + items[-1]
def addon_slug() -> str | None:
"""This add-on's Supervisor slug, from the container hostname.
# The Details link (UX-09). Home Assistant 2026.2 added the built-in `app`
# panel (core #157554, frontend #28245), whose add-on pages are
# /config/app/<slug>/<tab>. 2026.5 dropped the old `hassio` panel, so
# /hassio/addon/<slug>/<tab> is a 404 there; 2026.1 and older have only that
# one. No path reaches the Documentation tab on both, so the link follows the
# Home Assistant version, and an unknown version gets the current path.
DOCS_PATH = "/config/app/{slug}/documentation"
DOCS_PATH_OLD = "/hassio/addon/{slug}/documentation"
APP_PANEL_SINCE = (2026, 2)
_SLUG = re.compile(r"[a-z0-9]+_goodwe_controller")
_site = {"slug": None, "ha": None}
The Supervisor names an add-on's host after its slug with `_` spelled `-`
(`local_goodwe_controller` -> `local-goodwe-controller`). Anything else,
e.g. a test run, gets no link rather than a wrong one.
def set_site(slug=None, ha_version=None) -> None:
"""What main.py read from the Supervisor at start: our slug, HA's version."""
_site["slug"] = slug if isinstance(slug, str) and _SLUG.fullmatch(slug) \
else None
_site["ha"] = ha_version if isinstance(ha_version, str) else None
def ha_release(version) -> tuple | None:
"""`"2026.9.1"` -> `(2026, 9)`; None when it cannot be read."""
m = re.match(r"(\d{4})\.(\d{1,2})\b", str(version or ""))
return (int(m.group(1)), int(m.group(2))) if m else None
def addon_slug() -> str | None:
"""This add-on's Supervisor slug, or None outside an add-on.
The Supervisor's own answer (`GET /addons/self/info`) first. Failing that,
the container hostname, which the Supervisor names after the slug with `_`
spelled `-` (`local-goodwe-controller`). Anything else gets no link rather
than a wrong one.
"""
if _site["slug"]:
return _site["slug"]
host = os.environ.get("HOSTNAME", "")
if re.fullmatch(r"[a-z0-9]+-goodwe-controller", host):
return host.replace("-", "_")
return None
def docs_url(slug: str, ha_version=None) -> str:
release = ha_release(ha_version)
old = release is not None and release < APP_PANEL_SINCE
return (DOCS_PATH_OLD if old else DOCS_PATH).format(slug=slug)
def details(title: str) -> str:
where = f"section “{title}” under {DOCS_SECTION}"
slug = addon_slug()
if slug is None:
return f"Details: add-on documentation, {where}."
return (f"Details: [add-on documentation](/hassio/addon/{slug}/documentation),"
return (f"Details: [add-on documentation]({docs_url(slug, _site['ha'])}),"
f" {where}.")
@@ -98,19 +133,22 @@ ID_NOT_DELIVERING = "goodwe_not_delivering_{slug}"
ID_METER_FROZEN = "goodwe_meter_frozen"
# Which limit cut a command (clamp.ClampResult.bound, plus the loop's own).
# The setting is named by its label, "Inverter rating (W)".
RATING = "the “Inverter rating” setting"
LIMIT_WORDS = {
"max_w": "the configured inverter rating",
"max_w": RATING,
"device": "the inverter's own limit",
"max_w+device": "the configured inverter rating and the inverter's own limit",
"rating": "the inverter rating",
"max_w+device": f"{RATING} and the inverter's own limit",
"rating": RATING,
}
def loop_bound() -> Notice:
"""SAFETY-40: the integrator bound. Normal in short bursts; not a fault."""
return Notice(ID_LOOP_BOUND, WARNING, T_LOOP_BOUND,
"The battery cannot give what the controller asks, which is "
"normal for a moment but needs a check if it keeps happening.")
"The battery does less than asked, which is normal briefly, "
"but if this keeps happening, check that it is on and not "
"empty or full.")
@dataclass(frozen=True)
@@ -122,77 +160,98 @@ class Clamp:
limit: str # a key of LIMIT_WORDS
def output_clamp(clamps) -> Notice:
def output_clamp(clamps, *, shadow: bool = False) -> Notice:
"""SAFETY-03: a computed command above the limit. A software fault.
Asked comes before sent, always - reading them the other way round turns
the alarm backwards (test_clamp.py part 6).
the alarm backwards (test_clamp.py part 6). In shadow mode the cut command
never reached the inverter, so the text says "would have" (UX-09).
"""
fault = "This is a software fault, so please report it to your installer."
if not clamps:
cut = ("would have been cut back" if shadow else "was cut back")
state = ("Shadow mode is on, so every inverter stays at 0 W." if shadow
else "Control is still running.")
return Notice(ID_OUTPUT_CLAMP, ALARM, T_OUTPUT_CLAMP,
"The controller asked for more power than the inverter "
"rating and was cut back. Control is still running. This "
"is a software fault, so please report it to your "
"installer.")
f"The add-on asked for more power than {RATING} allows "
f"and {cut}. {state} {fault}")
c = clamps[0]
who = f"For {c.unit}, the" if c.unit else "The"
others = [x.unit for x in clamps[1:] if x.unit]
running = (f"{names(others)} {'was' if len(others) == 1 else 'were'} cut "
f"too, and control is still running." if others
else "Control is still running.")
sent = "would have sent" if shadow else "sent"
if others:
verb = "was" if len(others) == 1 else "were"
state = (f"{names(others)} would have been cut too, and shadow mode "
f"keeps every inverter at 0 W." if shadow else
f"{names(others)} {verb} cut too, and control is still "
f"running.")
else:
state = ("Shadow mode is on, so the inverter stays at 0 W." if shadow
else "Control is still running.")
return Notice(ID_OUTPUT_CLAMP, ALARM, T_OUTPUT_CLAMP,
f"{who} controller asked for {watts(c.asked_w)}, above "
f"{LIMIT_WORDS.get(c.limit, LIMIT_WORDS['rating'])}, and sent "
f"{watts(c.sent_w)} instead. {running} "
f"This is a software fault, so please report it to your "
f"installer.")
f"{who} add-on asked for {watts(c.asked_w)}, above "
f"{LIMIT_WORDS.get(c.limit, RATING)}, and {sent} "
f"{watts(c.sent_w)} instead. {state} {fault}")
def peak_saturated(ceiling_w) -> Notice:
"""SAFETY-07: the battery gives all it can and the peak still goes up."""
def peak_saturated(ceiling_w, *, shadow: bool = False) -> Notice:
"""SAFETY-07: the battery gives all it can and the peak still goes up.
In shadow mode the battery gives nothing, so the text says what the add-on
would ask and that the peak may rise (UX-09).
"""
act = "Switch off large loads in the next few minutes."
if shadow:
return Notice(ID_PEAK_SATURATED, ALARM, T_PEAK_SATURATED,
f"The add-on would ask the battery for all it can give, "
f"and this 15-minute period is heading over your "
f"{watts(ceiling_w)} peak limit. Shadow mode is on, so "
f"the battery gives nothing and this month's peak may "
f"rise. {act}")
return Notice(ID_PEAK_SATURATED, ALARM, T_PEAK_SATURATED,
f"The battery is giving all it can, but this 15-minute period "
f"will still go over your {watts(ceiling_w)} peak limit and "
f"raise this month's peak. Switch off large loads in the next "
f"few minutes. This is not a fault: the load is bigger than "
f"the inverter.")
f"raise this month's peak. {act} This is not a fault: the "
f"load is more than the battery can supply.")
def peak_reserve(ceiling_w, *, soc_unread: bool, floor_unknown: bool,
packs=()) -> Notice:
"""SAFETY-24/25/32: the peak guard may not discharge any further.
"""SAFETY-24/25/32: the peak guard may not draw the battery any lower.
The last sentence is SAFETY-25 and must stay: the reserve binds the peak
guard only, and normal home use goes on discharging below it.
guard only, and normal home use goes on drawing the battery below it.
`packs` names the batteries at their limit, only on a site with several.
`floor_unknown`: the floor the guard grades against is None, which at a
roster means some inverter's cut-out level is missing (the peak reserve
itself always has a value) - so the action names the cut-out level.
Both are named by their setting labels, "Peak reserve (%)" and "Battery
cut-out level (%)".
"""
if soc_unread:
why = "The battery level cannot be read"
act = "Switch off large loads, and check the battery level sensor."
act = ("Switch off large loads, and check the “Battery level entity” "
"setting.")
elif floor_unknown:
why = "The cut-out level of a battery is not known"
act = ("Switch off large loads, and set each battery's cut-out level "
"in the settings.")
why = "A battery cut-out level is not known"
act = ("Switch off large loads, and set “Battery cut-out level” for "
"each inverter.")
else:
why = (f"The battery of {names(packs)} is at its peak reserve" if packs
else "The battery is at its peak reserve")
act = ("Switch off large loads, or lower the peak reserve if the "
"battery allows it.")
act = "Switch off large loads, or lower the peak reserve."
return Notice(ID_PEAK_RESERVE, ALARM, T_PEAK_RESERVE,
f"{why}, so this 15-minute period will go over your "
f"{watts(ceiling_w)} peak limit and raise this month's peak. "
f"{act} The reserve only applies to keeping the peak down: normal home use "
f"can still discharge the battery below it, down to its "
f"cut-out level.")
f"{act} The reserve only applies to keeping the peak down: "
f"normal home use can still draw the battery below it, down "
f"to the battery cut-out level.")
def circulating(discharging=(), charging=()) -> Notice:
"""SAFETY-31: the inverters push power round each other. Control stopped."""
if discharging and charging:
what = (f"{names(discharging)} was discharging while "
what = (f"{names(discharging)} was giving power while "
f"{names(charging)} was charging, and your meter cannot see "
f"this.")
else:
@@ -222,7 +281,7 @@ def meter_frozen(unchanged_s) -> Notice:
"""SAFETY-18: the meter answers but its value does not move."""
return Notice(ID_METER_FROZEN, ALARM, T_METER_FROZEN,
f"The meter has shown the same value for "
f"{duration(unchanged_s)} while the controller asks the "
f"{duration(unchanged_s)} while the add-on asks the "
f"battery for full power. Control is still running and still "
f"follows this reading. Check the meter, and if it is stuck, "
f"stop control on the add-on page.")
@@ -291,17 +350,31 @@ def banner_not_delivering(units) -> str:
return f"{names(units)} {verb} not delivering. Control keeps running."
# Rows: the controller and the meter.
def banner_shadow(latched: bool) -> str:
"""SAFETY-10: first in the cascade, never displaced by another banner.
With a safety stop standing it goes red and says the stop outlasts shadow
mode. Each stop has its own red row below, which names it and says how it
clears.
"""
if latched:
return ("Shadow mode, battery not controlled. A safety stop stays on, "
"see below.")
return "Shadow mode: the battery is not controlled. Inverters stay at 0 W."
# Rows: control and the meter. "Control" is what the add-on does, as in
# "start control" (STYLE.md section 4).
def row_controller_starting() -> str:
return "Controller: starting"
return "Control: starting"
def row_controller_ran(age_s) -> str:
return f"Controller: last ran {seconds(age_s)} ago"
return f"Control: last ran {seconds(age_s)} ago"
def row_controller_stalled(age_s, veto_s) -> str:
return (f"Controller has not run for {seconds(age_s)}. The control board "
return (f"Control has not run for {seconds(age_s)}. The control board "
f"sets the inverter to 0 W after {seconds(veto_s)}.")
@@ -322,9 +395,12 @@ def row_meter_frozen() -> str:
f"and stop control if it is stuck.")
# Settings are named by their labels in translations/en.yaml.
METER_SOURCE = "“Where the meter reading comes from”"
FREEZE_OFF = {
"source": "it only works with the HomeWizard local meter source",
"rating": "the inverter rating is not set",
"source": f"it needs {METER_SOURCE} set to HomeWizard local",
"rating": "“Inverter rating” is not set",
"range": "the inverter reports no usable power range",
}
@@ -357,13 +433,12 @@ def row_peak_reserve(ceiling_w, *, soc_unread: bool, floor_unknown: bool,
why = (f"{names(packs)} battery at its peak reserve" if packs
else "Battery at its peak reserve")
return (f"{why}, so the {watts(ceiling_w)} peak limit will be passed. Home "
f"use still discharges below the reserve, down to the cut-out level.")
f"use still draws the battery below it, down to the cut-out level.")
def row_peak_guard_off() -> str:
"""No meter source: the 15-minute average cannot be measured."""
return ("Peak guard: off, it needs a meter source instead of the grid "
"power sensor")
"""`meter_source` is off: the 15-minute average cannot be measured."""
return f"Peak guard: off, set {METER_SOURCE} to anything but off"
def banner_peak_reserve() -> str:
@@ -383,24 +458,49 @@ def row_sensor(label, value, unit=None) -> str:
def row_sensor_unset(label, unit=None) -> str:
return f"{label}{for_unit(unit)}: no sensor set in the settings"
"""The setting is "<label> entity" (e.g. "Grid power entity (W)")."""
return f"{label}{for_unit(unit)}: “{label} entity” is not set"
def row_sensor_unusable(label, unit=None) -> str:
"""SAFETY-56: it may be missing OR held back as stale; say both."""
return (f"{label}{for_unit(unit)}: no usable reading. The sensor may be "
return (f"{label}{for_unit(unit)}: no usable reading. The entity may be "
f"missing, or its reading is held back as too old. Check it in "
f"Developer Tools before replacing it.")
def setpoint_label(unit=None) -> str:
"""The label: "Setpoint entity" in the inverter list, else its long form."""
return "“Setpoint entity”" if unit else "“Inverter setpoint entity”"
def row_control_unset(unit=None) -> str:
return f"Inverter control{for_unit(unit)}: not set in the settings"
return f"Inverter control{for_unit(unit)}: {setpoint_label(unit)} is not set"
def row_control_missing(unit=None) -> str:
return f"Inverter control{for_unit(unit)}: not found in Home Assistant"
# Rows: whether each inverter can still be controlled (DEV-02). `name` is
# always given: these rows came with the inverter list.
def row_no_setpoint(name) -> str:
"""Amber. The site refuses to run at part strength, so all stay at 0 W."""
return f"{name}: “Setpoint entity” is not set, so every inverter stays at 0 W"
def row_not_controllable(name, held_s, limit_s) -> str:
"""Red. The inverter is dropped and the others carry its share."""
return (f"{name} cannot be controlled. Every command was refused for "
f"{seconds(held_s)}, limit {seconds(limit_s)}.")
def row_commands_refused(name, held_s, limit_s) -> str:
"""Amber. Refused, but not for long enough to be dropped yet."""
return (f"{name}: commands refused for {seconds(held_s)}, left out of "
f"control after {seconds(limit_s)}")
def row_control(lo_w, hi_w, unit=None) -> str:
def w(v):
return "?" if v is None else signed_watts(v)
@@ -409,12 +509,15 @@ def row_control(lo_w, hi_w, unit=None) -> str:
# Rows: the two loop alarms. The names are the notification titles, so the
# row and the card always call the same thing by the same name (UX-07 item 1).
def row_power_too_high(clamps, count) -> str:
def row_power_too_high(clamps, count, *, shadow: bool = False) -> str:
"""In shadow mode nothing was sent, so it says "would send" (UX-09)."""
c = clamps[0] if clamps else None
what = (f"asked {watts(c.asked_w)}{for_unit(c.unit)}, sent "
f"{watts(c.sent_w)}. Cut back" if c else "cut back")
return (f"{T_OUTPUT_CLAMP}: {what} {times(count)} since start. This is a "
f"software fault, so please report it.")
head = f"{T_OUTPUT_CLAMP}{' in shadow mode' if shadow else ''}"
what = (f"asked {watts(c.asked_w)}{for_unit(c.unit)}, "
f"{'would send' if shadow else 'sent'} {watts(c.sent_w)}. Cut back"
if c else "cut back")
return (f"{head}: {what} {times(count)} since start. Software fault, "
f"please report it.")
def banner_power_too_high() -> str:
@@ -513,24 +616,29 @@ def row_no_estop() -> str:
# Rows: solar production (TEL-11/12/14). Sources are numbered in the order of
# the solar sensor list in the settings.
# "Solar production entities, per inverter". The settings are named by their
# labels in translations/en.yaml.
PV_ONE = "“Solar production entity”"
PV_REVERSED = "“Reversed-sign solar entities”"
def source(n, of) -> str:
return "the sensor" if of == 1 else f"source {n}"
return "the entity" if of == 1 else f"source {n}"
def pv_problem(why: str) -> str:
"""`pv.watts()`'s reason, in plain words."""
w = str(why)
if w.startswith("no state"):
return "the sensor is missing"
return "the entity is missing"
if w.startswith("entity is"):
return "the sensor is unavailable"
return "the entity is unavailable"
if w.endswith("is not numeric"):
return "the reading is not a number"
if w.startswith("no unit"):
return "the sensor has no unit"
return "the entity has no unit"
if w.startswith("unit "):
return "the sensor's unit is not a power unit"
return "the entity's unit is not a power unit"
return "the reading is not usable"
@@ -553,20 +661,19 @@ def row_pv_partial(missing, count) -> str:
def row_pv_single_ignored() -> str:
return ("Solar production: clear the single sensor setting, the list "
"replaces it")
return f"Solar production: clear {PV_ONE}, the per-inverter list replaces it"
def row_pv_negative(n, count, value_w, flipped: bool) -> str:
fix = ("remove it from" if flipped else "add it to")
who = source(n, count)
return (f"Solar production: {who} reads {signed_watts(value_w)}, "
f"so {fix} the reversed-sign list")
f"{fix} {PV_REVERSED}")
def row_pv_stray(n) -> str:
return (f"Solar production: entry {n} of the reversed-sign list is not a "
f"solar sensor in use")
return (f"Solar production: entry {n} of {PV_REVERSED} is not a solar "
f"entity in use")
RED, AMBER, GREEN = "bad", "warn", "ok"
@@ -591,6 +698,8 @@ def status_samples() -> list:
("banner_not_delivering", None, banner_not_delivering(["inverter-b"])),
("banner_peak_reserve", None, banner_peak_reserve()),
("banner_power_too_high", None, banner_power_too_high()),
("banner_shadow", None, banner_shadow(False)),
("banner_shadow", None, banner_shadow(True)),
("row_controller_starting", GREEN, row_controller_starting()),
("row_controller_ran", GREEN, row_controller_ran(2)),
("row_controller_stalled", RED, row_controller_stalled(45, 30)),
@@ -615,10 +724,19 @@ def status_samples() -> list:
("row_control_unset", RED, row_control_unset("inverter-b")),
("row_control_missing", RED, row_control_missing("inverter-b")),
("row_control", GREEN, row_control(-5000, 5000, "inverter-b")),
("row_control_unset", RED, row_control_unset()),
("row_no_setpoint", AMBER, row_no_setpoint("inverter-b")),
("row_not_controllable", RED, row_not_controllable("inverter-b", 45,
30)),
("row_commands_refused", AMBER, row_commands_refused("inverter-b", 12,
30)),
("row_power_too_high", RED, row_power_too_high(clamp, 3)),
("row_power_too_high", RED, row_power_too_high(
[Clamp("inverter-b", 6000, 4600, "max_w+device")], 12)),
("row_power_too_high", RED, row_power_too_high((), 1)),
("row_power_too_high", RED, row_power_too_high(
[Clamp("inverter-b", 6000, 4600, "max_w+device")], 12,
shadow=True)),
("row_not_keeping_up", AMBER, row_not_keeping_up(48)),
("row_before", AMBER, row_before(T_OUTPUT_CLAMP, 2)),
("row_before", AMBER, row_before(T_LOOP_BOUND, 1)),
@@ -662,7 +780,13 @@ def samples() -> list:
output_clamp(()),
output_clamp([Clamp("inverter-a", -3000, -2500, "device"),
Clamp("inverter-b", 6000, 4600, "max_w+device")]),
output_clamp([Clamp(None, 7412, 5000, "rating")], shadow=True),
output_clamp((), shadow=True),
output_clamp([Clamp("inverter-a", -3000, -2500, "device"),
Clamp("inverter-b", 6000, 4600, "max_w+device")],
shadow=True),
peak_saturated(5000),
peak_saturated(5000, shadow=True),
peak_reserve(5000, soc_unread=False, floor_unknown=False),
peak_reserve(5000, soc_unread=False, floor_unknown=False,
packs=["inverter-b"]),
+10 -16
View File
@@ -279,6 +279,8 @@ that write is issued rather than skipped as unchanged.
"""
from __future__ import annotations
from . import messages
# ⚠️ CFG-03's mirror. `test_defaults_pin.py` part 2 discovers every
# module-level name ending in OPTION_DEFAULTS and asserts each value
# reproduces config.yaml EXACTLY, so this table cannot drift from the shipped
@@ -471,25 +473,17 @@ def log_line(*, would_w: float, reason: str, sized_from_meter: bool) -> str:
def banner(opts: dict, *, control_started: bool, latched: tuple = ()) -> tuple:
"""`(level, text)` for the top of the status page, or `None` when live.
⚠️ IT NAMES A STANDING LATCH AND GOES RED FOR ONE. The shadow banner sits
ABOVE every other branch of the cascade, because "the battery is not being
controlled" is the one sentence that may never be displaced - but a
failsafe latch that is up while the controller is inert is up when it
stops being inert, and an operator who turns shadow mode off without
clearing it gets a battery that will not move and a green page that
never mentioned why. So the latch is carried INTO the shadow banner
rather than losing its own.
⚠️ IT GOES RED FOR A STANDING LATCH. The shadow banner sits ABOVE every
other branch of the cascade, because "the battery is not controlled" is
the one sentence that may never be displaced - but a failsafe latch that
is up while the controller is inert is up when it stops being inert. So the
banner says a safety stop outlasts shadow mode, and each latch keeps its
own red row below, which names it and says how it clears. The words are
`messages.banner_shadow()`'s (UX-09); `latched` names them for callers.
"""
if not engaged(opts, control_started=control_started):
return None
text = ("SHADOW MODE - the battery is NOT being controlled. Every "
f"inverter is held at {WIRE_W:.0f} W and nothing this add-on "
"decides reaches the inverter.")
if latched:
return ("bad", text + " ⚠️ A FAILSAFE LATCH IS STILL UP ("
+ ", ".join(latched) + ") and it will still be up when shadow "
"mode is turned off.")
return ("warn", text)
return ("bad" if latched else "warn", messages.banner_shadow(bool(latched)))
def problems(opts: dict) -> list: