Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial support for smart lithium batteries #47

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

orymate
Copy link

@orymate orymate commented Mar 9, 2024

Summary 📝

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

  • Tested Changes
  • Stakeholder Approval

@stefanor
Copy link
Contributor

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
Copy link
Contributor

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: orymate/victron-ble@add-smart-lithium...stefanor:victron-ble:add-smart-lithium

@orymate
Copy link
Author

orymate commented Mar 22, 2024

@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>"
  }
}

@orymate orymate marked this pull request as ready for review March 22, 2024 07:33
@stefanor
Copy link
Contributor

"model_name": "<Unknown device: 41196>"

I guess you should add that model to the database too

@stefanor
Copy link
Contributor

Ah, you did.

Copy link
Contributor

@rajlaud rajlaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this! I was playing around with it too, and have a few suggestions based on that work.

victron_ble/devices/smart_lithium.py Show resolved Hide resolved
victron_ble/devices/smart_lithium.py Outdated Show resolved Hide resolved
victron_ble/devices/smart_lithium.py Outdated Show resolved Hide resolved
victron_ble/devices/base.py Show resolved Hide resolved
@orymate
Copy link
Author

orymate commented Mar 23, 2024

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"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants