Bluetooth-Devices / bthome-ble

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

Add a 16-bit 'tank' or 'volume' object ID #33

Closed PhracturedBlue closed 1 year ago

PhracturedBlue commented 1 year ago

It would be convenient to have a tank level (or volume, though that term can be misconstrued) object ID measuring in Gallons (or Liters for the metrically inclined). I have water and heating-oil tanks that I monitor. Today, I can use percent, distance, or count fields, but it would be nice to have a specified object-id with appropriate volume units.

Ernst79 commented 1 year ago

I will add that. I prefer to use "Volume", to make it useable in general for all kind of things (e.g. water consumption).

What kind of precision do you want. With 16 bit, you can have:

PhracturedBlue commented 1 year ago

A standard heating oil tank in the US is 270gal (1022liters) (a double is 540gal). I want to measure a 1500gal(5700 liter) water tank, but there is no standard for that and tanks could be much bigger or smaller. 55gal (208l) drums are also standard, as are 5-gal tanks. On more consideration, I think you should probably stick with metric-only units. Currently I see only 1 sensor that is imperial (0x07 - lb), and gallons are worse because there are multiple standards (the imperial gallon is 1.2 US gal).

I'm not sure a single decimal will cover all cases. For my uses 0 or 1 decimal would be fine, but for a larger tank, you'd require 0 decimals, and for a 5gal tank, you'd want at least 1 decimal. Another option would be 1 decimal with a 24bit value, which probably has sufficient range for most applications. Anything smaller than that would probably be measured in ml.

If you want my recommendation, maybe 2 sensors Volume(liters) - 24bit - 1 decimal Volume(milileters) 16bit - 0 decimal

Also, while I don't currently have much use for it, flow-rate is another sensor to consider (my guess is that liters/sec 16 bit, 1 decimal would cover most needs). But as I said, I don't have a use for such a sensor at this time.

Ernst79 commented 1 year ago

I have started with adding these to the sensor-state-data pypi package, which we use. https://github.com/Bluetooth-Devices/sensor-state-data/pull/45

For "volume flow rate", there was already a unit "m3 per hour" apparently, I will use that if that is ok with you? I guess 1 digit will be ok.

PhracturedBlue commented 1 year ago

Thanks. I will reiterate that I don't currently have a direct need for flow-rate, so I am mostly speculating as to what it is useful for. I'm thinking of things like household water usage, well pumps, or monitoring fish tank pumps. These would all do well with liters/min as a unit, and you will likely need more decimal points to use m^3/hr as a metric.

For instance, a low-flow shower head uses ~1.2gal/min which would be ~.273 m^3/hour

Also, having recently run out of space in the advertising payload, I guess 24bit values are not idea, and it is better to stick with 16bit values as much as possible.

Ernst79 commented 1 year ago

Fixed in 2.4.0.

Will be added in HA with this PR https://github.com/home-assistant/core/pull/84189