fl4p / batmon-ha

Add-on for Home Assistant to connect JK, JBD, Daly, ANT, SOK and Supervolt BMS via Bluetooth
MIT License
292 stars 55 forks source link
ant-bms battery-management-system battery-monitor ble bluetooth bluetooth-low-energy daly-bms dalybms home-assistant home-automation jbd-bms jikong-bms jk-bms jkbms mqtt smart-bms smartshunt sok-bms victron xiaoxiang

Home Assistant Add-on: BatMON

Home Assistant Dashboard Screenshot

Monitor and control various Battery management systems (BMS) over Bluetooth. This add-on reads the BMS and sends sensor data through MQTT to Home Assistant. Using bluetooth on the Home Assistant host system, it does not need any additional hardware (no USB/Serial/RS485).

I created this to compare BMS readings for a detailed evaluation of BMS reliability and accuracy.

Features

Supported Devices (bluetooth low energy)

I tested the add-on on a Raspberry Pi 4 using Home Assistant Operating System.

Installation

Configuration

The add-on can read multiple BMS at the same time. Add an entry for each device, such as:

- address: CC:44:8C:F7:AD:BB
  type: jk
  alias: battery1            # MQTT topic prefix (regex [\w_.-/])
  pin: "12345"               # pairing PSK, victron only (optional)
  adapter: "hci0"            # switch the bluetooth hw adapter (optional)
  debug: true                # verbose log for this device only (optional)
  current_calibration: 1.0   # current [I] correction factor (optional)

address is the MAC address of the Bluetooth device. If you don't know the MAC address start the add-on, and you'll find a list of visible Bluetooth devices in the add-on log. Alternatively you can enter the device name here as displayed in the discovery list.

type can be jk, jbd, ant, daly, supervolt, sok, victron or dummy.

With the alias field you can set the MQTT topic prefix and the name as displayed in Home Assistant. Otherwise, the name as found in Bluetooth discovery is used.

If the device requires a PIN when pairing (currently Victron SmartShunt only) add pin: "123456" (and replace 123456 with device's PIN).

Add adapter: "hci1" to select a bluetooth adapter other than the default one.

With current_calibration you can calibrate the current sensor. The current reading is multiplied by this factor. Set it to -1 to flip the sign if you experience wrong charge/discharge meters.

For verbose logs of particular BMS add debug: true.

Energy Meters

Batmon implements energy metering by computing the integral of power values from the BMS with the trapezoidal rule. You can add theses meters to your Home Assistant Energy Dashboard or use them with the HA Helper Utility Meter, see doc/HA Energy Dashboard.md.

The accuracy depends on the accuracy of the voltage and current readings from the BMS. Consider these having an error of 2~5%. Some BMS do not detect small currents (<200mA) and can miss high frequency peaks, leading to even greater error.

Troubleshooting

TODO

Stand-alone

You can run the add-on outside of Home Assistant (e.g. on a remote RPI sending MQTT data of WiFI). All you need is an operating system supported by bleak. See doc/Standalone.md

Contribute / Donate

References