Add the client Energy mockup and switch site texts to English

D-022: page mockups are HTML built from real data, in maquettes/user/
(client) and maquettes/support/; Figma only on request.
maquettes/user/energy.py renders the System Summary page with a
Diagnostic section: an Energy box with the day's color, a one-line
headline, a battery scale (zones from the collector's LiFePO4 OCV
table, no percentage shown), the trend against the day before, an
"Activate energy save mode" button on orange and red days (mockup
only, sends nothing), and two collapsibles: the full history (D-021
figure) and the guide (part 1 of the manual, rendered from Markdown).

D-023: everything meant for the monitoring site is in English,
including the titles, legends, axes and hovers of the 03/04 panels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maximeandClaude Opus 5.5 committed 2026-10-12 16:23:37 +02:00
1 parent fc74fec10f
commit 8452973912
9 files changed
+366 -19

No files matched your search

+19 -19
View File
@@ -61,11 +61,11 @@ ZONES = [
# États de DAILY_BATTERY_STATE : couleurs validées par le skill dataviz (toutes paires, fond blanc).
# Le jaune contraste peu avec le fond : chaque état a aussi son symbole, sa légende et son survol.
STATE_STYLE = {
"FULL_CHARGE": ("pleine charge", "#008300", "circle"),
"PARTIAL_CHARGE": ("charge partielle (incertain)", "#eda100", "diamond"),
"BELOW_PLATEAU": ("sous le plateau", "#2a78d6", "triangle-down"),
"NO_CHARGE": ("aucune charge", "#4a3aa7", "x"),
None: ("état inconnu", "#8c8c8c", "circle-open"),
"FULL_CHARGE": ("full charge", "#008300", "circle"),
"PARTIAL_CHARGE": ("partial charge (uncertain)", "#eda100", "diamond"),
"BELOW_PLATEAU": ("below plateau", "#2a78d6", "triangle-down"),
"NO_CHARGE": ("no charge", "#4a3aa7", "x"),
None: ("unknown state", "#8c8c8c", "circle-open"),
}
@@ -76,24 +76,24 @@ def noon(day):
def daily_state_panel(fig, result, row):
"""Panneau DAILY_BATTERY_STATE : maximum et fin de nuit par jour, seuils, état en marqueurs (fiche analyse_03)."""
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analyse {result['analysis']}")
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analysis {result['analysis']}")
rule, pts = result["rule"], result["points"]
x = [noon(p["t"].date()) for p in pts]
fig.add_scatter(x=x, y=[p["facts"].get("max_v") for p in pts], name="maximum du jour", mode="lines",
fig.add_scatter(x=x, y=[p["facts"].get("max_v") for p in pts], name="daily maximum", mode="lines",
line=dict(color="#52514e", width=1.5), hoverinfo="skip", row=row, col=1, **group)
fig.add_scatter(x=x, y=[p["facts"].get("night_end_v") for p in pts], name="fin de nuit", mode="lines",
line=dict(color="#9a9893", width=1.5), hovertemplate="fin de nuit %{y:.2f} V<extra></extra>",
fig.add_scatter(x=x, y=[p["facts"].get("night_end_v") for p in pts], name="night end", mode="lines",
line=dict(color="#9a9893", width=1.5), hovertemplate="night end %{y:.2f} V<extra></extra>",
row=row, col=1, **group)
# Seuils tracés comme des courbes (un point par jour) : AUTOSCALE_Y_JS les garde visibles au zoom (D-013).
for v, name, state in ((rule["full_charge_v"], "pleine charge", "FULL_CHARGE"),
(rule["plateau_floor_v"], "bas du plateau", "BELOW_PLATEAU")):
for v, name, state in ((rule["full_charge_v"], "full charge", "FULL_CHARGE"),
(rule["plateau_floor_v"], "plateau floor", "BELOW_PLATEAU")):
fig.add_scatter(x=x, y=[v] * len(x), name=f"{name} {v} V", mode="lines", hoverinfo="skip",
line=dict(color=STATE_STYLE[state][1], dash="dash", width=1), row=row, col=1, **group)
for state, (label, color, symbol) in STATE_STYLE.items():
sel = [p for p in pts if p["facts"]["state"] == state and p["facts"].get("max_v") is not None]
if not sel:
continue
hover = [f"{p['t']:%Y-%m-%d} : {label}<br>" + "<br>".join(f"{k}={val}" for k, val in p["facts"].items())
hover = [f"{p['t']:%Y-%m-%d}: {label}<br>" + "<br>".join(f"{k}={val}" for k, val in p["facts"].items())
for p in sel]
fig.add_scatter(x=[noon(p["t"].date()) for p in sel], y=[p["facts"]["max_v"] for p in sel], name=label,
mode="markers",
@@ -104,40 +104,40 @@ def daily_state_panel(fig, result, row):
# Tendances de DAILY_BATTERY_TREND : paire divergente bleu/rouge et gris neutre du skill dataviz
# (vert/rouge refusé par son validateur : deutéranopie, ΔE 5,9). Chaque tendance a aussi sa légende et son survol.
TREND_STYLE = {"BETTER": ("mieux", "#2a78d6"), "STABLE": ("stable", "#8c8c8c"), "WORSE": ("pire", "#d03b3b")}
TREND_STYLE = {"BETTER": ("better", "#2a78d6"), "STABLE": ("stable", "#8c8c8c"), "WORSE": ("worse", "#d03b3b")}
def daily_trend_panel(fig, result, row):
"""Panneau DAILY_BATTERY_TREND : écart de fin de nuit J − J−1 en barres, couleur = tendance (fiche analyse_04)."""
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analyse {result['analysis']}")
group = dict(legendgroup=result["analysis"], legendgrouptitle_text=f"Analysis {result['analysis']}")
pts, db = result["points"], result["rule"]["night_end_deadband_v"]
x = [noon(p["t"].date()) for p in pts]
# Zone morte tracée comme une courbe (un point par jour, None entre +db et −db) : visible au zoom (D-013).
fig.add_scatter(x=x + [None] + x, y=[db] * len(x) + [None] + [-db] * len(x), name=f"zone morte ±{db} V",
fig.add_scatter(x=x + [None] + x, y=[db] * len(x) + [None] + [-db] * len(x), name=f"dead band ±{db} V",
mode="lines", hoverinfo="skip", line=dict(color="#52514e", dash="dash", width=1),
row=row, col=1, **group)
for trend, (label, color) in TREND_STYLE.items():
sel = [p for p in pts if p["facts"]["trend"] == trend and p["value"] is not None]
if not sel:
continue
hover = [f"{p['t']:%Y-%m-%d}: {label} (décidé par {p['facts']['decided_by']})<br>"
hover = [f"{p['t']:%Y-%m-%d}: {label} (decided by {p['facts']['decided_by']})<br>"
f"{p['facts']['state_prev']} → {p['facts']['state']}<br>"
+ "<br>".join(f"{k}={v}" for k, v in p["facts"].items() if k.startswith("delta")) for p in sel]
fig.add_bar(x=[noon(p["t"].date()) for p in sel], y=[p["value"] for p in sel], name=label,
marker_color=color, width=0.8 * 86_400_000, hovertext=hover, hovertemplate="%{hovertext}<extra></extra>",
row=row, col=1, **group)
fig.update_yaxes(title_text="Δ fin de nuit [V]", row=row, col=1)
fig.update_yaxes(title_text="Δ night end [V]", row=row, col=1)
def daily_figure(station, series):
"""Graphique pour le site de monitoring (D-021) : analyse 03 en haut, analyse 04 dessous, même axe du temps."""
fig = make_subplots(rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.08,
subplot_titles=[f"Analyse {bs.RULE['id']}", f"Analyse {bt.RULE['id']}"])
subplot_titles=[f"Analysis {bs.RULE['id']}", f"Analysis {bt.RULE['id']}"])
daily_state_panel(fig, bs.run(series), 1)
daily_trend_panel(fig, bt.run(series), 2)
fig.update_xaxes(showticklabels=True)
fig.update_yaxes(fixedrange=True) # zoom horizontal seulement : l'ordonnée est recalée par AUTOSCALE_Y_JS
fig.update_layout(title=f"{station} : état et tendance de la batterie", height=700, barmode="overlay",
fig.update_layout(title=f"{station}: battery state and trend", height=700, barmode="overlay",
legend=dict(groupclick="toggleitem"))
return fig