Giter Site home page Giter Site logo

batmon-ha's Introduction

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

  • Uses Bluetooth Low-Energy (BLE) for wireless communication through bleak
  • Records SoC, Current, Power, individual cell voltages and temperatures
  • Monitor multiple devices at the same time
  • Energy consumption meters (using trapezoidal power integrators)
  • Integrates with Home Assistant Energy dashboard
  • Control BMS charging and discharging switches
  • Home Assistant MQTT Discovery

Supported Devices (bluetooth)

  • JK BMS (jikong) (JK02 protocol)
  • Daly BMS
  • JBD / Xiaoxiang / Overkill Solar BMS
  • Victron SmartShunt (make sure to update to latest firmware and enable GATT in the VictronConnect app)

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

Installation

  • Go to your Home Assistant Add-on store and add this repository: https://github.com/fl4p/home-assistant-addons Open your Home Assistant instance and show the dashboard of a Supervisor add-on.
  • Install Batmon add-on
  • Install, configure and start Mosquito MQTT broker (don't forget to configure the MQTT integration)

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

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, daly, victron or dummy.

With the alias field you can set 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 add pin: "123456" (and replace 123456 with device's PIN) Add adapter: "hci1" to select a bluetooth adapter other than the default one.

For verbose logs of particular BMS add debug: true.

  • Set MQTT user and password. MQTT broker is usually core-mosquitto.
  • concurrent_sampling tries to read all BMSs at the same time (instead of a serial read one after another). This can increase sampling rate for more timely-accurate data. Might cause Bluetooth connection issues if keep_alive is disabled.
  • keep_alive will never close the bluetooth connection. Use for higher sampling rate. You will not be able to connect to the BMS from your phone anymore while the add-on is running.
  • sample_period is the time in seconds to wait between BMS reads. Small periods generate more data points per time.
  • Set publish_period to a higher value than sample_period to throttle MQTT data, while sampling BMS for accurate energy meters.
  • invert_current changes the sign of the current. Normally it is positive during discharge, inverted its negative.
  • expire_values_after time span in seconds when sensor values become "Unavailable"
  • watchdog stops the program on too many errors (make sure to enable the Home Assistant watchdog to restart the add-on after it exists)

Energy Meters

Batmon implements energy metering using the power values the BMS provides. You can add theses meters to your Home Assistant Energy Dashboard. 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.

  • Total Energy Discharge Meter: total Energy out of the battery (increasing only, use this for the Energy Dashboard)
  • Total Energy Charge: total Energy into the battery (increasing only, use this for the Energy Dashboard)
  • Total Energy: The total energy flow into and out of the battery (decreasing and increasing). This equals to (Total Energy Charge) - (Total Energy Discharge).
  • Total Cycles: Total full cycles of the battery. One complete discharge and charge is a full cycle: SoC 100%-0%-100%. This is not a value provided by the BMS, but Batmon computes this by differentiating the SoC.

Troubleshooting

  • When experiencing connection issues enable keep_alive
  • Enable verbose_log and check the logs. If that is too noisy set debug: true in the BMS configuration as described above
  • Power cycle the BMS Bluetooth dongle (or BMS)
  • Try another Bluetooth hardware
  • Try to find the BMS with a BLE scan linux

Known Issues

  • After a long-lasting bluetooth connection is lost both Daly and JBD dongles occasionally refuse to accept new connections and disappear from bluetooth discovery. Remove wires from the dongle and reconnect for a restart.
  • Raspberry PI's bluetooth can be buggy. If you experience errors and timeouts try to install an external Bluetooth dongle.

TODO

Stand-alone

You can run the add-on outside of Home Assistant (e.g. on a remote RPI sending MQTT data of WiFI). See doc/Standalone.md

References

batmon-ha's People

Contributors

fl4p avatar fl4p-old avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.