Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/charger-connection-in-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ftw": patch
---

Show when a car is not connected in the power flow. An attached car with no power reading shows that it is connected and power data is missing. Control feedback preserves these connection states.
29 changes: 24 additions & 5 deletions web/components/energy-flow-readings.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,25 @@ export function flowReadingsFromStatus(status, opts) {
}
}

const evW = num(d.ev_w);
if (evW !== null) {
const disconnected = d.ev_connected === false;
// An explicit disconnect takes precedence over any lingering power reading.
const evW = disconnected ? 0 : num(d.ev_w);
if (evW !== null || typeof d.ev_connected === "boolean") {
const active = !isIdle(evW, thresholdW);
const planet = {
id: `ev-${name}`, corner: "bottom-right", title: "EV CHARGER", role: "ev", name,
kw: Math.abs(evW) / 1000, toHub: false,
color: planetColor("ev", evW, thresholdW),
sub: active ? "charging" : "idle",
sub: disconnected ? "not connected" : active ? "charging" : "idle",
clickable: true,
};
if (online) {
if (online && evW === null) {
live.ev = true;
planets.push(placeholderPlanet({
id: planet.id, corner: planet.corner, title: planet.title,
role: planet.role, name, sub: "connected · no data", clickable: true,
}));
} else if (online) {
live.ev = true;
planets.push(planet);
} else {
Expand Down Expand Up @@ -225,10 +233,21 @@ export function flowReadingsFromStatus(status, opts) {
selfPoweredPctToday = Math.max(0, Math.min(100, (1 - importWh / loadWh) * 100));
}

const markedPlanets = withControlMarks(planets, status?.control_feedback, opts?.live !== false);
for (const planet of markedPlanets) {
const driver = status?.drivers?.[planet.name];
if (planet.role !== "ev" || !driverOnline(driver) || opts?.live === false) continue;
if (driver?.ev_connected === false) {
Object.assign(planet, {placeholder: false, kw: 0, sub: "not connected"});
} else if (driver?.ev_connected === true && num(driver.ev_w) === null) {
planet.sub = "connected · no data";
}
}

return {
load: loadW === null ? null : loadW / 1000,
loadEstimated: hasEstimate,
planets: withControlMarks(planets, status?.control_feedback, opts?.live !== false),
planets: markedPlanets,
selfPoweredPctToday,
};
}
Expand Down
17 changes: 15 additions & 2 deletions web/components/ftw-energy-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,10 @@ class FtwEnergyFlow extends FtwElement {
.sv-hub-label { font-size: 11px; }
.sv-hub-sub { font-size: 10px; }
}
.sv-ev-status-compact { display: none; }
@media (max-width: 600px) {
.sv-ev-status-wide { display: none; }
.sv-ev-status-compact { display: inline; }
svg { height: calc(var(--efl-h-factor, 1) * 460px); }
:host([embedded]) .ef-toggle {
bottom: 30px;
Expand Down Expand Up @@ -1596,6 +1599,14 @@ function renderCircleNode({ pos, title, nameLabel, value, sub, color, soc,
// stroke/fill in the icon SVG.
const iconSvg = ROLE_ICON[role] || ROLE_ICON.unknown;
const iconScale = r * 0.45 / 10;
const splitEVStatus = role === "ev" && sub === "connected · no data";
const compactEVStatus = splitEVStatus
? `<text x="${x}" y="${y + subY - 9}" text-anchor="middle"
fill="var(--hero-sub-text)" class="sv-node-sub sv-ev-status-compact" aria-label="${escapeXml(sub)}">
<tspan x="${x}">connected</tspan>
<tspan x="${x}" dy="1em">no data</tspan>
</text>`
: "";
return `
<g${groupAttrs} style="color:${color}">
<circle cx="${x}" cy="${y}" r="${r}"
Expand All @@ -1614,9 +1625,10 @@ function renderCircleNode({ pos, title, nameLabel, value, sub, color, soc,
${hasParts ? renderDailyParts(dailyKwhParts) : escapeXml(dailyKwh)}
</text>` : ""}
<text x="${x}" y="${y + subY}" text-anchor="middle"
fill="var(--hero-sub-text)" class="sv-node-sub">
fill="var(--hero-sub-text)" class="sv-node-sub${splitEVStatus ? " sv-ev-status-wide" : ""}">
${escapeXml(sub)}
</text>
${compactEVStatus}
${socText}
</g>`;
}
Expand Down Expand Up @@ -1703,7 +1715,8 @@ function aggregateGroups(groups) {
} else if (first.role === "pv") {
sub = idle ? "idle" : "generating";
} else if (first.role === "ev") {
sub = idle ? "idle" : "charging";
sub = group.every(p => p.sub === "not connected") ? "not connected"
: idle ? "idle" : "charging";
}
// SoC: simple mean across reporters. Real weighting needs per-
// battery capacity, which the component doesn't have here — the
Expand Down
32 changes: 32 additions & 0 deletions web/energy-flow-readings.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,35 @@ it("draws Core's estimated Home use as an estimate, not a blank", () => {
assert.equal(result.loadEstimated, true);
assert.equal(flowReadingsFromStatus({load_w: 980, load_quality: "measured"}).loadEstimated, false);
});

it("shows an unplugged charger even without power and preserves connected idle", () => {
for (const ev_w of [null, 0, 1000]) {
const r = flowReadingsFromStatus({drivers:{easee:{status:"ok",ev_connected:false,ev_w}}});
const ev = r.planets.find(p => p.id === "ev-easee");
assert.equal(ev.sub, "not connected");
assert.equal(ev.kw, 0);
}
const r = flowReadingsFromStatus({drivers:{easee:{status:"ok",ev_connected:true,ev_w:0}}});
assert.equal(r.planets.find(p => p.id === "ev-easee").sub, "idle");
});

it("keeps a known connected state when charger power is unavailable", () => {
const r = flowReadingsFromStatus({drivers:{easee:{status:"ok",ev_connected:true,ev_w:null}}});
const ev = r.planets.find(p => p.id === "ev-easee");
assert.equal(ev.sub, "connected · no data");
assert.equal(ev.placeholder, true);
});

it("keeps charger connection information when control feedback has no power", () => {
const feedback = {driver:"easee",kind:"ev",status:"waiting",severity:"info",readings_fresh:false};
const status = {drivers:{easee:{status:"ok",ev_connected:false,ev_w:null}},
control_feedback:[{...feedback,reason:"not_connected"}]};
const disconnected = flowReadingsFromStatus(status).planets.find(p => p.id === "ev-easee");
assert.equal(disconnected.sub, "not connected");
assert.equal(disconnected.placeholder, false);
status.drivers.easee.ev_connected = true;
status.control_feedback[0].reason = "telemetry_stale";
const connected = flowReadingsFromStatus(status).planets.find(p => p.id === "ev-easee");
assert.equal(connected.sub, "connected · no data");
assert.equal(connected.placeholder, true);
});
Loading