wallmonitor 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wallmonitor
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Local-only monitoring and recording UI for a Tesla Wall Connector Gen 3
5
5
  Keywords: tesla,wall-connector,ev-charging,monitoring,self-hosted,thermal-model
6
6
  Author: Fernando Gonzalez
@@ -34,6 +34,8 @@ Everything stays on your machine and your LAN: the only network traffic is
34
34
  HTTP GETs to the charger's local API, storage is a local SQLite file, and the
35
35
  web UI serves no external assets (no CDNs, fonts, or analytics).
36
36
 
37
+ ![Reviewing a real charge session: the dashed line is what the forecast predicted at each 30 s tick, converging onto the measured handle temperature — and the event log shows the automatic amp control acting on those predictions](https://raw.githubusercontent.com/zebraengine/wallmonitor/main/docs/assets/wallmonitor-demo.gif)
38
+
37
39
  ## Try it in 30 seconds
38
40
 
39
41
  No hardware needed — demo mode runs a built-in charger simulator:
@@ -44,8 +46,9 @@ uvx wallmonitor --demo
44
46
 
45
47
  Then open <http://127.0.0.1:8480>.
46
48
 
47
- Against your real Wall Connector (find its IP in your router, or use the
48
- `TeslaWallConnector_XXXXXX.local` hostname; add `--split-phase` on a North
49
+ Against your real Wall Connector (find its IP in your router's client list —
50
+ it registers a DHCP hostname like `TeslaWallConnector_XXXXXX`, which some
51
+ routers also make resolvable by name; add `--split-phase` on a North
49
52
  American split-phase install):
50
53
 
51
54
  ```bash
@@ -115,3 +118,7 @@ detection, alert lifecycle, the web API, and the thermal model end to end.
115
118
  [MIT](https://github.com/zebraengine/wallmonitor/blob/main/LICENSE). Built on the
116
119
  [`tesla-wall-connector`](https://github.com/einarhauks/tesla-wall-connector)
117
120
  library (MIT, by Einar Bragi Hauksson).
121
+
122
+ wallmonitor is an independent project, not affiliated with, endorsed by, or
123
+ sponsored by Tesla, Inc. "Tesla" and "Tesla Wall Connector" are trademarks of
124
+ Tesla, Inc., used here only to identify the hardware this software monitors.
@@ -11,6 +11,8 @@ Everything stays on your machine and your LAN: the only network traffic is
11
11
  HTTP GETs to the charger's local API, storage is a local SQLite file, and the
12
12
  web UI serves no external assets (no CDNs, fonts, or analytics).
13
13
 
14
+ ![Reviewing a real charge session: the dashed line is what the forecast predicted at each 30 s tick, converging onto the measured handle temperature — and the event log shows the automatic amp control acting on those predictions](https://raw.githubusercontent.com/zebraengine/wallmonitor/main/docs/assets/wallmonitor-demo.gif)
15
+
14
16
  ## Try it in 30 seconds
15
17
 
16
18
  No hardware needed — demo mode runs a built-in charger simulator:
@@ -21,8 +23,9 @@ uvx wallmonitor --demo
21
23
 
22
24
  Then open <http://127.0.0.1:8480>.
23
25
 
24
- Against your real Wall Connector (find its IP in your router, or use the
25
- `TeslaWallConnector_XXXXXX.local` hostname; add `--split-phase` on a North
26
+ Against your real Wall Connector (find its IP in your router's client list —
27
+ it registers a DHCP hostname like `TeslaWallConnector_XXXXXX`, which some
28
+ routers also make resolvable by name; add `--split-phase` on a North
26
29
  American split-phase install):
27
30
 
28
31
  ```bash
@@ -92,3 +95,7 @@ detection, alert lifecycle, the web API, and the thermal model end to end.
92
95
  [MIT](https://github.com/zebraengine/wallmonitor/blob/main/LICENSE). Built on the
93
96
  [`tesla-wall-connector`](https://github.com/einarhauks/tesla-wall-connector)
94
97
  library (MIT, by Einar Bragi Hauksson).
98
+
99
+ wallmonitor is an independent project, not affiliated with, endorsed by, or
100
+ sponsored by Tesla, Inc. "Tesla" and "Tesla Wall Connector" are trademarks of
101
+ Tesla, Inc., used here only to identify the hardware this software monitors.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wallmonitor"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Local-only monitoring and recording UI for a Tesla Wall Connector Gen 3"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wallmonitor"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "Local-only monitoring and recording UI for a Tesla Wall Connector Gen 3"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -40,7 +40,7 @@ async def run(argv: list[str] | None = None) -> None:
40
40
 
41
41
  sim_runner = None
42
42
  if cfg.demo:
43
- sim_runner, sim_port = await start_simulator()
43
+ sim_runner, sim_port = await start_simulator(split_phase=cfg.split_phase)
44
44
  cfg.host = f"127.0.0.1:{sim_port}"
45
45
  log.info("demo mode: simulator running at http://%s", cfg.host)
46
46
 
@@ -35,9 +35,12 @@ class SimState:
35
35
  background task to run or state to advance — every request computes the
36
36
  world as of "now", and a test can pin `start` to make it deterministic."""
37
37
 
38
- def __init__(self, speedup: float = 1.0, start: float | None = None):
38
+ def __init__(
39
+ self, speedup: float = 1.0, start: float | None = None, split_phase: bool = False
40
+ ):
39
41
  self.t0 = start if start is not None else time.time()
40
42
  self.speedup = speedup
43
+ self.split_phase = split_phase
41
44
  self.boot_ts = self.t0
42
45
  self.lifetime_energy_wh = 2_566_837.0
43
46
  self.charge_starts = 450
@@ -66,8 +69,17 @@ class SimState:
66
69
  gets exercised without waiting for real trouble."""
67
70
  name, into, cycle_n = self.phase()
68
71
  rng = self.rng
69
- grid_v = 230.0 + rng.uniform(-1.5, 1.5)
70
- grid_hz = 50.0 + rng.uniform(-0.02, 0.02)
72
+ # Grid profile: European three-phase 230 V / 50 Hz by default, or a
73
+ # North American split-phase 240 V / 60 Hz install (nominal sags a
74
+ # few volts under load, matching recorded Gen 3 telemetry).
75
+ if self.split_phase:
76
+ grid_v = 236.0 + rng.uniform(-1.5, 1.5)
77
+ grid_hz = 60.0 + rng.uniform(-0.03, 0.03)
78
+ max_amps = 48.0
79
+ else:
80
+ grid_v = 230.0 + rng.uniform(-1.5, 1.5)
81
+ grid_hz = 50.0 + rng.uniform(-0.02, 0.02)
82
+ max_amps = 16.0
71
83
  connected = name in ("connected", "charging", "complete")
72
84
  charging = name == "charging"
73
85
  # Ramp current up over the first 20s of charging, taper near the end.
@@ -75,7 +87,9 @@ class SimState:
75
87
  if charging:
76
88
  ramp = min(1.0, into / 20.0)
77
89
  taper = 1.0 - max(0.0, (into - 200.0) / 40.0) * 0.6
78
- amps = 16.0 * ramp * taper + rng.uniform(-0.2, 0.2)
90
+ amps = max_amps * ramp * taper + rng.uniform(-0.2, 0.2)
91
+ if self.split_phase:
92
+ grid_v -= 6.5 * (amps / max_amps) # voltage sag under load
79
93
  if name == "connected":
80
94
  session_s = int(into)
81
95
  elif name == "charging":
@@ -85,11 +99,12 @@ class SimState:
85
99
  else:
86
100
  session_s = 0
87
101
  # session energy: integrate the trapezoid roughly — good enough for a sim
102
+ avg_power_w = 230.0 * 43.0 if self.split_phase else 3 * 230.0 * 14.0
88
103
  session_energy = 0.0
89
104
  if name == "charging":
90
- session_energy = 3 * 230.0 * 14.0 * (into / 3600.0)
105
+ session_energy = avg_power_w * (into / 3600.0)
91
106
  elif name == "complete":
92
- session_energy = 3 * 230.0 * 14.0 * (CYCLE[2][1] / 3600.0)
107
+ session_energy = avg_power_w * (CYCLE[2][1] / 3600.0)
93
108
  alerts = []
94
109
  if cycle_n >= self.alert_after_cycles and name == "charging" and 60 < into < 120:
95
110
  # Real firmware reports numeric alert IDs (e.g. [27]).
@@ -105,13 +120,18 @@ class SimState:
105
120
  "grid_v": round(grid_v, 1),
106
121
  "grid_hz": round(grid_hz, 3),
107
122
  "vehicle_current_a": round(amps, 1),
108
- "currentA_a": round(amps if charging else 0.1, 1),
109
- "currentB_a": round(amps if charging else 0.1, 1),
110
- "currentC_a": round(amps if charging else 0.1, 1),
111
- "currentN_a": round(rng.uniform(0.0, 0.4), 1),
112
- "voltageA_v": round(grid_v + rng.uniform(-0.5, 0.5), 1),
113
- "voltageB_v": round(grid_v + rng.uniform(-0.5, 0.5), 1),
114
- "voltageC_v": round(grid_v + rng.uniform(-0.5, 0.5), 1),
123
+ # Split-phase Gen 3 telemetry is odd and reproduced from a real
124
+ # install's recording: each leg (and neutral) reads roughly half
125
+ # the vehicle current, and voltageC sits near half of grid_v.
126
+ # Summing V×I here would be wrong — that's what --split-phase's
127
+ # grid_v × vehicle_current power path exists to handle.
128
+ "currentA_a": round((amps * 0.46 if self.split_phase else amps) if charging else 0.1, 1),
129
+ "currentB_a": round((amps * 0.54 if self.split_phase else amps) if charging else 0.1, 1),
130
+ "currentC_a": round((amps * 0.53 if self.split_phase else amps) if charging else 0.1, 1),
131
+ "currentN_a": round(amps * 0.46 if self.split_phase and charging else rng.uniform(0.0, 0.4), 1),
132
+ "voltageA_v": round(grid_v + (3.5 if self.split_phase else 0.0) + rng.uniform(-0.5, 0.5), 1),
133
+ "voltageB_v": round(grid_v + (3.9 if self.split_phase else 0.0) + rng.uniform(-0.5, 0.5), 1),
134
+ "voltageC_v": round(grid_v / 2.0 if self.split_phase else grid_v + rng.uniform(-0.5, 0.5), 1),
115
135
  "relay_coil_v": 11.9,
116
136
  "pcba_temp_c": round(18.0 + (8.0 if charging else 0.0) + rng.uniform(-0.4, 0.4), 1),
117
137
  "handle_temp_c": round(handle_temp, 1),
@@ -204,10 +224,10 @@ def make_app(state: SimState | None = None) -> web.Application:
204
224
 
205
225
 
206
226
  async def start_simulator(
207
- port: int = 0, speedup: float = 1.0, start: float | None = None
227
+ port: int = 0, speedup: float = 1.0, start: float | None = None, split_phase: bool = False
208
228
  ) -> tuple[web.AppRunner, int]:
209
229
  """Start the simulator on localhost. Returns (runner, bound_port)."""
210
- runner = web.AppRunner(make_app(SimState(speedup=speedup, start=start)))
230
+ runner = web.AppRunner(make_app(SimState(speedup=speedup, start=start, split_phase=split_phase)))
211
231
  await runner.setup()
212
232
  site = web.TCPSite(runner, "127.0.0.1", port)
213
233
  await site.start()
@@ -1313,7 +1313,8 @@ async function viewSessionDetail(root, id) {
1313
1313
  const volt = chartCard("Phase voltages", "Per-phase voltage");
1314
1314
  const temp = chartCard("Temperatures",
1315
1315
  `Plug handle, charger circuit board (PCBA), and processor (MCU). At ${HANDLE_TRIP_C}°C on the handle, alert 40 raises ` +
1316
- `and current is halved (observed on this firmware); the ≈${PCBA_THROTTLE_C}°C line is the community-observed PCBA throttle point.`);
1316
+ `and current is halved (observed on this firmware); the ≈${PCBA_THROTTLE_C}°C line is the community-observed PCBA throttle point. ` +
1317
+ `The dashed line is the plateau the forecast predicted at each 30 s tick — watch it converge onto the measured curve as the fit gets data.`);
1317
1318
  const pilot = chartCard("Pilot & proximity", "J1772 handshake signals — flaky values here often precede charging errors");
1318
1319
  const relay = chartCard("Relay voltages", "Contactor coil drive");
1319
1320
  const eventsWrap = el("div", {});
@@ -1339,6 +1340,7 @@ async function viewSessionDetail(root, id) {
1339
1340
  let win = null;
1340
1341
  let fullSamples = [];
1341
1342
  let fullEvents = [];
1343
+ let fullForecasts = [];
1342
1344
  let sessionRange = [0, 1];
1343
1345
  let winSeq = 0;
1344
1346
  let winTimer = null;
@@ -1362,12 +1364,23 @@ async function viewSessionDetail(root, id) {
1362
1364
  { name: "Phase C", color: colors.s3, points: samples.map((sample) => [sample.ts, sample.vc]) },
1363
1365
  ], unit: "V", digits: 1, xFrom, xTo, height: 190,
1364
1366
  });
1367
+ // The recorded forecast history: what the model believed the handle
1368
+ // would plateau at, at each 30 s tick. Early guesses run high on thin
1369
+ // trajectory data and converge as the fit firms up — that convergence
1370
+ // is the point of drawing it against the measured curve.
1371
+ const forecastPts = fullForecasts
1372
+ .filter((row) => row.ts >= xFrom && row.ts <= xTo)
1373
+ .map((row) => [row.ts, row.steady_state_c]);
1374
+ const tempSeries = [
1375
+ { name: "Circuit board (PCBA)", color: colors.s1, points: samples.map((sample) => [sample.ts, sample.tPcba]) },
1376
+ { name: "Plug handle", color: colors.s2, points: samples.map((sample) => [sample.ts, sample.tHandle]) },
1377
+ { name: "Processor (MCU)", color: colors.s3, points: samples.map((sample) => [sample.ts, sample.tMcu]) },
1378
+ ];
1379
+ if (forecastPts.length) {
1380
+ tempSeries.push({ name: "Predicted plateau", color: colors.s5, dash: "6 4", points: forecastPts });
1381
+ }
1365
1382
  lineChart(temp.box, {
1366
- series: [
1367
- { name: "Circuit board (PCBA)", color: colors.s1, points: samples.map((sample) => [sample.ts, sample.tPcba]) },
1368
- { name: "Plug handle", color: colors.s2, points: samples.map((sample) => [sample.ts, sample.tHandle]) },
1369
- { name: "Processor (MCU)", color: colors.s3, points: samples.map((sample) => [sample.ts, sample.tMcu]) },
1370
- ], unit: "°C", digits: 1, xFrom, xTo, height: 190,
1383
+ series: tempSeries, unit: "°C", digits: 1, xFrom, xTo, height: 190,
1371
1384
  refLines: [
1372
1385
  { value: HANDLE_TRIP_C, label: `${HANDLE_TRIP_C}°C handle → alert 40 derate` },
1373
1386
  { value: PCBA_THROTTLE_C, label: `≈${PCBA_THROTTLE_C}°C PCBA throttle (approx.)` },
@@ -1458,6 +1471,7 @@ async function viewSessionDetail(root, id) {
1458
1471
 
1459
1472
  fullSamples = samples;
1460
1473
  fullEvents = data.events;
1474
+ fullForecasts = (data.forecasts || []).filter((row) => row.steady_state_c != null);
1461
1475
  sessionRange = [backdated ? firstSeen : session.start_ts, ongoing ? now : session.end_ts];
1462
1476
  renderBrush();
1463
1477
  await applyWindow();
@@ -144,7 +144,11 @@ def make_app(db: Database, bus: EventBus, poller: Poller | None) -> web.Applicat
144
144
  if sample.get("session_id") == sid or sample["ts"] >= session["start_ts"]
145
145
  ]
146
146
  events = await asyncio.to_thread(db.events_range, session["start_ts"] - 1, end + 1)
147
- return web.json_response({"session": session, "samples": samples, "events": events})
147
+ forecasts = await asyncio.to_thread(db.forecast_range, session["start_ts"] - 1, end + 1)
148
+ forecasts = [row for row in forecasts if row.get("session_id") in (sid, None)]
149
+ return web.json_response(
150
+ {"session": session, "samples": samples, "events": events, "forecasts": forecasts}
151
+ )
148
152
 
149
153
  async def api_alerts(request: web.Request) -> web.Response:
150
154
  now = time.time()