bimmerconnected / ha_custom_component

Home Assistant Custom Component of BMW Connected Drive
34 stars 13 forks source link

Fuel volume rounded to integer gallons - not very useful on i3 REX with tiny tank #23

Closed transplier closed 2 years ago

transplier commented 2 years ago

Hi, thanks for this fantastic add on. I just installed it and am already using it to get universal charge status notifications that actually work consistently and aren't tied to a charge network. I'll also use it to manage my car's interaction with my future photovoltaic system, allowing more efficient use of surplus power. So cool.

One small issue using it with my i3 REX, which has a tiny fuel tank (even softmodded to allow using the entire thing). It appears this component rounds the fuel volume to the nearest whole gallon, which means my car either shows 2 gallons, 1 gallon, or empty. It would be great if folks using gallons could get one or two digits after the decimal. I see the underlying API provides decimal liters. Since a liter is about a quarter gallon, that's about four times the available resolution.

It appears the code in question is https://github.com/bimmerconnected/ha_custom_component/blob/9f17a77dad5dbad6f279439d90df1b15efddbd0a/custom_components/bmw_connected_drive/sensor.py#L110-L112

rikroe commented 2 years ago

Very good catch - that sound like an easy fix. Can you update line 111 in sensor.py and just add , 2 (no other brackets etc. to the end?)

If that works for you, I'll create a PR to HA to have it included directly, without the need for a custom component.

By the way, you should not neet this custom component. It is just used for testing new features etc. Please use the default integration within Home Assistant.

transplier commented 2 years ago

Ah, I think I'm confused. I thought this was the place where development happened on the default integration. I'm not actually using the custom component. Let me set up a testing instance of HA and I'll give it a shot with the custom component.

transplier commented 2 years ago

image It works! 1.85 gal!

rikroe commented 2 years ago

No worries! I'll think about adding a issue template, as it is actually confusing deciding between the Home Assistant repo for the default component, the bimmer connected repo for the background library and this.

Glad it worked, I've also created a PR with Home Assistant.

rikroe commented 2 years ago

Closing this as the code was merged with HA core and will be included in HA 2022.2.