UX-08 2c: short refusals, error texts and option texts

Validator refusals name the setting by its label and key, say what is
wrong and what to change, and keep the rejected value and limit. Option
names and descriptions are short in en and nl; citations moved to DOCS
"For installers" and the test_translations citation check now pins the
instruction on the tab and the record in DOCS. No rule, key, schema,
default or exit code changed. Allowlist 167 -> 43 (log lines only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LyR88rXETvwhTgx6yHE39p
This commit is contained in:
glenn schrooyen
2026-09-27 05:55:37 +02:00
co-authored by Claude Opus 5.5
parent 1455aa6110
commit 277e368c69
23 changed files with 336 additions and 590 deletions
+26 -26
View File
@@ -578,8 +578,9 @@ def S(key: str, where: str = "") -> str:
def _labels(keys, joiner: str = "and") -> str:
"""`“Current price entity” and “Average price entity”`."""
return f" {joiner} ".join(f"“{messages.LABELS[k]}”" for k in keys)
"""Several settings, each with its key: the config panel files a refusal
under every key it names (`configui.problems_by_field()`)."""
return f" {joiner} ".join(S(k) for k in keys)
def _roster_problems(opts: dict) -> list[str]:
@@ -701,9 +702,9 @@ def _roster_problems(opts: dict) -> list[str]:
flat_sp = str(opts.get("setpoint_entity") or "").strip()
if entries and flat_sp:
problems.append(
f"{S('setpoint_entity')} is set to {flat_sp}, but the “Inverter "
f"list” has {len(entries)} entries. Move that inverter into the "
"list and clear this setting.")
f"{S('setpoint_entity')} is set to {flat_sp}, but the "
f"{S('inverters')} has {len(entries)} entries. Move that inverter "
"into the list and clear this setting.")
return problems
@@ -923,8 +924,8 @@ def validate_startup_config(opts: dict, dev_min=None, dev_max=None) -> list[str]
where = _unit_label(opts, min(caps_ix, key=lambda p: p[1])[0])
problems.append(
f"{S('sign_disagree_w')} is {sign_w:.0f} W, but the "
f"{S('max_w', where)} is {weakest:.0f} W, so this safety check can "
"never trip. Set it back to 300 W.")
f"{S('max_w', where)} is {weakest:.0f} W, so this check can never "
f"trip. Lower it below {weakest:.0f} W, or raise the rating.")
# ⚠️ AND THE SAME RULE FOR SAFETY-30's PER-UNIT THRESHOLD, WHICH IS A
# SEPARATE COMPARISON AND THEREFORE A SEPARATE WAY TO DISARM. It grades a
@@ -977,9 +978,9 @@ def validate_startup_config(opts: dict, dev_min=None, dev_max=None) -> list[str]
elif weakest is not None and weakest > 0 and unit_sign_w >= weakest:
problems.append(
f"{S('unit_sign_disagree_w')} is {unit_sign_w:.0f} W, but the "
f"{S('max_w', unit_where)} is {weakest:.0f} W, so this safety check "
"can never trip. Set it back to "
f"{SIGN_OPTION_DEFAULTS['unit_sign_disagree_w']:.0f} W.")
f"{S('max_w', unit_where)} is {weakest:.0f} W, so this check can "
f"never trip. Lower it below {weakest:.0f} W, or raise the "
"rating.")
# --- 6. a maintenance charge the ceiling can actually accommodate --------
# ⚠️ Strictly `>`, matching the arbiter exactly. The shaping is
@@ -1057,8 +1058,8 @@ def validate_startup_config(opts: dict, dev_min=None, dev_max=None) -> list[str]
"it in watts.")
elif maint_cap is not None and maint_cap > 0 and charge_w > maint_cap:
problems.append(
f"{S('maintenance_charge_w')} is {charge_w:.0f} W, above the "
f"{S('max_w', maint_where)} of {maint_cap:.0f} W, so the monthly "
f"{S('maintenance_charge_w')} is {charge_w:.0f} W, but the "
f"{S('max_w', maint_where)} is {maint_cap:.0f} W, so the monthly "
f"recharge cannot run. Lower it to {maint_cap:.0f} W or less.")
# --- 10. a slew rate the plant can actually follow -----------------------
@@ -1100,8 +1101,7 @@ def validate_startup_config(opts: dict, dev_min=None, dev_max=None) -> list[str]
if slew_w > bound + 1.0:
problems.append(
f"{S('slew_w')} is {slew_w:.0f} W, too fast for a {rail:.0f} W "
f"site to settle. Set it to 0, which means {bound:.0f} W here, "
f"or to {bound:.0f} W or less.")
f"site. Set it to 0 or to at most {bound:.0f} W.")
# --- 7. two price sources on one site ------------------------------------
problems.extend(_price_problems(opts))
@@ -1233,7 +1233,7 @@ def _price_problems(opts: dict) -> list[str]:
# fall back to, the site has had no tariff at all - a worse state, and
# one this message must not paper over.
been_running = (
f"the “{messages.LABELS['static_profile']}”"
f"the {S('static_profile')}"
if str(opts.get("static_profile", "") or "").strip()
else "no tariff at all")
problems.append(
@@ -1290,9 +1290,9 @@ def _price_problems(opts: dict) -> list[str]:
if pid != "off" and ha_price:
problems.append(
f"{S('price_provider')} is {pid!r}, but {_labels(ha_price)} "
f"{'is' if len(ha_price) == 1 else 'are'} also set. Clear "
f"{'it' if len(ha_price) == 1 else 'them'} to use {pid!r}, or set "
"the price source to 'off'.")
f"{'is' if len(ha_price) == 1 else 'are'} also set and would win. "
f"Clear {'it' if len(ha_price) == 1 else 'them'}, or set the price "
"source to 'off'.")
# ⚠️ THE SAME RULE FOR THE SOURCE TARIFF-03 ADDED, AND THIS ONE IS A LIVE
# CONFLICT RATHER THAN A LATENT ONE. main.py's read_inputs() takes `cheap`
@@ -1302,7 +1302,8 @@ def _price_problems(opts: dict) -> list[str]:
if ha_price and str(opts.get("static_profile", "") or "").strip():
problems.append(
f"{S('static_profile')} and {_labels(ha_price)} are both set, and "
"only the price entities would count. Clear one of the two.")
"only the Home Assistant price entities would count. Clear one of "
"the two.")
# ⚠️ THE PROFILE ITSELF, PARSED AT STARTUP RATHER THAN AT 02:00. A profile
# that does not tile the day has hours with no price, and the only ways to
@@ -1315,7 +1316,7 @@ def _price_problems(opts: dict) -> list[str]:
profile = parse_static_profile(raw_profile)
except ProfileInvalid as e:
profile = None
problems.append(f"{S('static_profile')} cannot be used: {e}")
problems.append(f"“{messages.LABELS['static_profile']}” cannot be used. {e}")
if profile is not None and profile.product is not None \
and len(set(profile.prices)) == 1:
_LOG.info(
@@ -1340,7 +1341,7 @@ def _price_problems(opts: dict) -> list[str]:
try:
taxes_table = parse_taxes_profile(raw_taxes_profile)
except ProfileInvalid as e:
problems.append(f"{S(TAXES_PROFILE_OPTION)} cannot be used: {e}")
problems.append(f"“{messages.LABELS[TAXES_PROFILE_OPTION]}” cannot be used. {e}")
if taxes_table is not None:
# ⚠️ TWO WRITERS OF ONE QUANTITY, ONE OF WHICH SILENTLY LOSES - the
@@ -1450,7 +1451,7 @@ def _price_problems(opts: dict) -> list[str]:
spec = parse_price_formula(raw_formula)
except FormulaInvalid as e:
spec = None
problems.append(f"{S('price_formula')} cannot be used: {e}")
problems.append(f"“{messages.LABELS['price_formula']}” cannot be used. {e}")
if spec is not None and pid != "custom_formula":
# ⚠️ A WARNING AND NOT A REFUSAL. This is not two price sources
# fighting over one flag - it is one that is simply not wired to
@@ -1504,7 +1505,7 @@ def _price_problems(opts: dict) -> list[str]:
xspec = parse_export_formula(raw_export)
except FormulaInvalid as e:
xspec = None
problems.append(f"{S(EXPORT_FORMULA_OPTION)} cannot be used: {e}")
problems.append(f"“{messages.LABELS[EXPORT_FORMULA_OPTION]}” cannot be used. {e}")
if xspec is not None:
# ⚠️ THE 6% ASYMMETRY, PRINTED RATHER THAN ASSUMED. The two legs
# carry INDEPENDENT `vat_pct` values and a Belgian site's are 6 and
@@ -1609,9 +1610,8 @@ def _price_problems(opts: dict) -> list[str]:
"or turn trading off.")
if not is_enabled(opts):
problems.append(
f"{S('arbitrage_enabled')} is on, but "
f"{_labels(['meter_source'])} is 'off'. Trading needs the meter "
"to keep the peak limit. Choose a meter, or turn trading off.")
f"{S('arbitrage_enabled')} is on, but no meter is set in "
f"{S('meter_source')}. Choose a meter, or turn trading off.")
floor = _number(opts, "arbitrage_soc_floor",
PRICE_OPTION_DEFAULTS["arbitrage_soc_floor"])
ceiling = _number(opts, "arbitrage_soc_ceiling",