feat: live telemetry on gun cards — SoC battery gauge, kW, V, A, delivered kWh
- backend keeps the latest meter sample per active transaction in memory and ships it as active_transactions[tx].telemetry on /api/status (Transaction.Begin snapshots skipped: taken before the BMS is read) - Battery component: fill + color sweep red (empty) -> blue (half) -> green (full) per the owner's spec; aria meter semantics - charging bays show the gauge, a prominent kW readout, and delivered kWh / voltage / current rows; hint while awaiting the first sample - smoke: 60 checks (telemetry rides /api/status)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { api, scopeAllowed } from "../api";
|
||||
import Battery from "../components/Battery";
|
||||
import { Lamp, statusTone } from "../components/Lamp";
|
||||
import { useAction, useLiveRelays, useStatus } from "../queries";
|
||||
import { useApp } from "../store";
|
||||
@@ -127,20 +128,60 @@ function GunBay({ gun, scopes }: { gun: Gun; scopes: string[] }) {
|
||||
</div>
|
||||
|
||||
{gun.tx && (
|
||||
<dl className="bay__telemetry">
|
||||
<div>
|
||||
<dt>By</dt>
|
||||
<dd>{gun.tx.who || gun.tx.id_tag}</dd>
|
||||
<>
|
||||
<div className="bay__charge">
|
||||
<Battery soc={gun.tx.telemetry?.soc} />
|
||||
<div className="bay__kw">
|
||||
<span className="bay__kw-num mono">
|
||||
{gun.tx.telemetry?.power_w != null
|
||||
? (gun.tx.telemetry.power_w / 1000).toFixed(1)
|
||||
: "—"}
|
||||
</span>
|
||||
<span className="bay__kw-unit">kW</span>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Via</dt>
|
||||
<dd>{gun.tx.method === "app" ? "In-app" : gun.tx.method === "card" ? "Card" : gun.tx.method}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Running</dt>
|
||||
<dd>{fmtSince(gun.tx.started)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<dl className="bay__telemetry">
|
||||
<div>
|
||||
<dt>By</dt>
|
||||
<dd>{gun.tx.who || gun.tx.id_tag}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Via</dt>
|
||||
<dd>{gun.tx.method === "app" ? "In-app" : gun.tx.method === "card" ? "Card" : gun.tx.method}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Running</dt>
|
||||
<dd>{fmtSince(gun.tx.started)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Delivered</dt>
|
||||
<dd className="mono">
|
||||
{gun.tx.telemetry?.energy_wh != null
|
||||
? `${((gun.tx.telemetry.energy_wh - gun.tx.meter_start) / 1000).toFixed(2)} kWh`
|
||||
: "—"}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Voltage</dt>
|
||||
<dd className="mono">
|
||||
{gun.tx.telemetry?.voltage_v != null
|
||||
? `${gun.tx.telemetry.voltage_v.toFixed(0)} V`
|
||||
: "—"}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Current</dt>
|
||||
<dd className="mono">
|
||||
{gun.tx.telemetry?.current_a != null
|
||||
? `${gun.tx.telemetry.current_a.toFixed(1)} A`
|
||||
: "—"}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
{!gun.tx.telemetry && (
|
||||
<span className="bay__hint">first meter reading arrives within a minute…</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<footer className="bay__actions">
|
||||
|
||||
Reference in New Issue
Block a user