Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
69 stars 14 forks source link

Support for negative current values #135

Closed PhracturedBlue closed 2 weeks ago

PhracturedBlue commented 1 month ago

I'm building a UPS monitor using BTHome. I'm using an INA226 to measure the voltage/current into/out-of the battery. I'd like to be able to measure the current as positive (discharging) or negative (charging) with a single value, but today the current value is unsigned. I could use 2 attributes (charge current and discharge current), but that adds an additional 3 bytes to the payload which is more than I can fit in a legacy ADV packet. Is there any recommendation for how to deal with this? Add a new attribute type? abuse the current attribute, and just send it as s32_t? Use a raw type? (adds 1 byte to the payload) use the abs-value of the current, and a flag bit to specifiy positive/negative? (adds 2 bytes to the payload)

Ernst79 commented 2 weeks ago

Added in 3.11.0