Loren Lisk

A Choice for Energy Idependence

DIY Powerwall

The batteries live in one of the two matching 30U racks described on the homelab page (the other still runs the lab). Watching them meant teaching a computer to read the battery management system.

Watching the pack

The pack is managed by a Batrium Watchmon 4+ BMS, which broadcasts its telemetry as little-endian binary UDP packets on port 18542.

batrium-udp2http-bridge is a Go service that turns those packets into something easier to use. It listens for the broadcasts, picks a decoder from the 16-bit message type in each packet, and keeps the latest decoded message for each type. Each type is served as JSON on a route named after its message ID (for example /0x3E32), plus a per-cell-monitor route, /0x4232/{id}. It also exports Prometheus metrics and ships as a Docker image.

Message ID What it carries
0x5732System Discovery
0x415ACell Monitor Basic Status
0x4232Cell Monitor Full Info
0x3E32 / 0x3F33 / 0x4032Telemetry Rapid / Fast / Slow
0x4732Logic Control Status
0x4932Remote Status
0x5432Daily Session
0x6131 / 0x7857 / 0x5632Communication Status / Shunt Metrics / Lifetime Metrics
0x4A35 / 0x4B35 / 0x4C33 / 0x4D33 / 0x5334Hardware setup: system, cell group, shunt, expansion, integration
0x4F33 / 0x5033 / 0x5158 / 0x5258 / 0x4E58Control-logic setup: critical, charge, discharge, thermal, remote

The source is on GitHub: github.com/liskl/batrium-udp2http-bridge.

Before the batteries: watching the meter

In Feb 2014 I wrote TED5000.sh, a shell script that cron runs every minute. It pulls the latest power reading from a TED 5000 whole-home power monitor gateway and feeds an rrdtool round-robin database: a 60-second step, a GAUGE data source, and a MAX archive of 525,949 one-minute rows (about a year of minutes). It then renders PNG graphs, which the old site served.

* * * * * TED5000.sh <gateway-ip> 0
rrdtool create <rrd-dir>/ted5000.rrd --start now --step 60 DS:watts:GAUGE:120:0:20 RRA:MAX:0.5:1:525949

The script and setup notes are on GitHub: liskl/t5k-power-monitor.

Years later, the same itch became the powerwall.

"If I had more time, I would have made this shorter."

Top Of Page