How fl4p/batmon-ha works
BatMON discovers and polls configured battery-management systems, normalizes readings, derives pack and energy metrics, then publishes them to Home Assistant over MQTT or to InfluxDB; it also exposes live state through a GUI. The README documents broad BLE and experimental serial support, battery groups, charge algorithms, and control operations. Sampled code confirms the runtime entry point, BLE handling, selected protocol decoding, proxy setup, and GUI serialization; some subsystem links are therefore shown only where documented or directly supported.
Main entry points: sampling.py Sample scheduling · main.py Runtime coordinator · bt.py Bluetooth transport · mqtt_util.py MQTT publishing
Components 21
Device acquisition
- Bluetooth discovery
bmslib/scan.py - Bluetooth transport
bmslib/bt.py - ESPHome proxy
bmslib/esphome_proxy/bootstrap.py - BLE device drivers
bmslib/models/BLE_BMS_wrap.py - JK protocol driver
bmslib/models/jikong.py - Serial transport
bmslib/wired/transport.py - Serial BMS drivers
bmslib/models/jikong_uart.py
Battery processing
- Sample scheduling
bmslib/sampling.py - Battery groups
bmslib/group.py - Charge algorithms
bmslib/algorithm.py - Energy meters
bmslib/tracker.py - Ambient temperature
bmslib/pack_temp_publisher.py
State delivery
- MQTT publishing
bmslib/mqtt_util.py - InfluxDB sink
bmslib/sinks.py - GUI server
bmslib/gui/server.py - GUI state format
bmslib/wire/model.py
Control and operations
- Runtime coordinator
main.py
Other components
- Operator configures
- Battery systems
- Home Assistant
- InfluxDB service
Connections 24
- Operator configures → Runtime coordinator: configures
- Runtime coordinator → Bluetooth discovery: starts discovery
- Runtime coordinator → ESPHome proxy: starts proxies
- Runtime coordinator → Sample scheduling: starts sampling
- Bluetooth discovery → Bluetooth transport: scans devices
- Sample scheduling → BLE device drivers: polls BLE
- Sample scheduling → Serial BMS drivers: polls serial
- BLE device drivers → Bluetooth transport: uses transport
- JK protocol driver → Bluetooth transport: uses transport
- Serial BMS drivers → Serial transport: uses transport
- Battery systems → Bluetooth transport: BLE data
- Battery systems → Serial transport: serial data
- Sample scheduling → Battery groups: aggregates batteries
- Sample scheduling → Charge algorithms: evaluates control
- Sample scheduling → Energy meters: integrates energy
- Sample scheduling → MQTT publishing: publishes readings
- Sample scheduling → InfluxDB sink: writes readings
- MQTT publishing → Home Assistant: sends MQTT
- InfluxDB sink → InfluxDB service: writes points
- Sample scheduling → GUI server: updates state
- GUI server → GUI state format: serializes state
- Home Assistant → GUI server: views live state
- Runtime coordinator → Ambient temperature: configures estimator
- Ambient temperature → MQTT publishing: registers topics