syssi / esphome-daly-bms

ESPHome component to monitor a DALY Battery Management System (DALY-BMS) via BLE
Apache License 2.0
2 stars 1 forks source link

Add Balancing switch request #25

Open leodesigner opened 21 hours ago

leodesigner commented 21 hours ago

Hi,

Thank you for your work @syssi ! Just got this project working with Daly Balancer. (not BMS) The only missing feature is Balancer turn on/off switch. I cannot find it in the modbus registers unfortunately :(

Any suggestions where to look? Snoop BLE HCI communication ?

syssi commented 21 hours ago

Could you prepare a btsnoop capture using the Android app?

syssi commented 19 hours ago

Do you know which of the Windows applications does work with your device?

https://www.dalybms.com/download-pc-software/

leodesigner commented 7 hours ago

https://www.dalybms.com/download-pc-software/

The link to the balancer used: https://www.dalybms.com/active-balancer-lifepo4-16s-daly-3-to-24s-1a-smart-active-balancer-product/

Looks like these are responsible:

Balancer BT logs

Value: d20600cf0000aa56 Value: d20600cf00016b96

00cf register

I will test today.

syssi commented 7 hours ago

Could you provide the complete btsnoop capture? It can be easily anonymized. I would like to add it to the project.

leodesigner commented 7 hours ago

Not sure how to anonymise it. There is a lot of other devices and I was specifically targeting balancer on/off switch. The other datapoints (cell voltages, temperature) are captured perfectly, except delta cell voltage needs correction. It shows 0.0007 V instead of 0.007 V.

syssi commented 6 hours ago
  1. Open the btsnoop capture in wireshark
  2. We are interested in the communication with the BMS only. Apply the filter bluetooth.addr == 3c:a5:51:89:40:ff (the MAC address must be updated!)
  3. Select all frames
  4. Click "File -> Export specified packets"
  5. Check the radio box "Selected packets only"
  6. Specify a new filename and press save

Close the complete capture and open the new one. You should see the values remote() and localhost() now instead of MAC addresses etc.

syssi commented 6 hours ago

I've added the new switch entity. Please give it a try by changing the external_components_source to the feature branch @add-balancer-switch:

substitutions:
  name: daly-bms-ble
  device_description: "Monitor a DALY Battery Management System via BLE"
  external_components_source: github://syssi/esphome-daly-bms@add-balancer-switch
leodesigner commented 6 hours ago

That was quick, thank you (I have a local version with the additional switch already)

Here is the log: balancer_snoop.log

leodesigner commented 6 hours ago

Would be great to read the switch status too. At this moment it shows as OFF (at least in my quick implementation)

syssi commented 6 hours ago

Just for completeness: In best case we retrieve the state of the switch/register priodically so the state of the switch get updated if the balancer is changed by 3rd parties (Android app f.e.). At the momnent it's open-loop because 0xCF isn't retrieved periodically atm.

leodesigner commented 6 hours ago

Yeah, this is downside, we could read it at the startup after reset. Not the best option, but could at least provide some initial state.

syssi commented 6 hours ago

On the long run we should read all or some selected settings registers periodically. The initial state of the charging and discharging switch isn't populated properly at the moment too because of the same reason.

leodesigner commented 4 hours ago

Update on my end: it works!

The green led on the balancer stops and starts blinking accordingly.

There are several additional non important sensors could be added in the future as well:

syssi commented 4 hours ago

Could you create one issue per feature and provide as much details (registers, example data etc.) as possible? I'm happy about every contributed feature too. Please keep in mind we aren't allowed to break the BMS compatibility. We should introduce a second YAML example soon for the balancer and introduce a device_type option if we retrieve different registers per device.