keshavdv / victron-ble

A Python API to parse Victron Instant Readout BLE advertisements
The Unlicense
103 stars 34 forks source link

Add initial support for smart lithium batteries #47

Closed orymate closed 1 month ago

orymate commented 8 months ago

Summary :memo:

Add initial support for smart lithium batteries

Details

I've implemented the parsing based on the pdf and tested on a bunch of 160Ah batteries. @stefanor worked together with Victron to fix the byte order, and the data gathered with this code seems to match what the VictronConnect app says.

Checks

stefanor commented 8 months ago

Hi, just bought some of these too. And yeah, I agree the data doesn't seem to match the spec. I asked for help from Victron.

stefanor commented 8 months ago

With Victron's help, figured it out. The issue is that integers are packed in little-endian order across the bytes. So I reversed the entire struct to make it tranctable: https://github.com/orymate/victron-ble/compare/add-smart-lithium...stefanor:victron-ble:add-smart-lithium

orymate commented 8 months ago

@stefanor Great, thanks a lot! I've tested it with my batteries and all the values look good.

{
  "name": "B4",
  "address": "F6:86:A7:02:89:5B",
  "rssi": -53,
  "payload": {
    "balancer_status": 3,
    "battery_temperature": 15,
    "battery_voltage": 13.36,
    "bms_flags": 6,
    "cell_voltages": [
      3.34,
      3.34,
      3.34,
      3.34,
      null,
      null,
      null,
      null
    ],
    "error_flags": 0,
    "model_name": "<Unknown device: 41196>"
  }
}
stefanor commented 8 months ago
"model_name": "<Unknown device: 41196>"

I guess you should add that model to the database too

stefanor commented 8 months ago

Ah, you did.

orymate commented 8 months ago

Thanks @rajlaud, it works nice:

{
  "name": "B3",
  "address": "D6:F3:AA:C2:82:6D",
  "rssi": -67,
  "payload": {
    "balancer_status": "balanced",
    "battery_temperature": 16,
    "battery_voltage": 13.36,
    "bms_flags": 6,
    "cell_voltages": [
      3.34,
      3.34,
      3.34,
      3.34,
      null,
      null,
      null,
      null
    ],
    "error_flags": 0,
    "model_name": "SmartLithium Battery 12V/160Ah"
  }
}
orymate commented 2 months ago

@keshavdv is there anything I can do to get this merged?