-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
Average fuel consumption issue #105565
Comments
Hey there @G-Two, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) subaru documentation |
It looks like it is probably a rounding error during the conversion from the native units (liters per 100km) to miles per gallon. In the past, the subaru API did not provide MPG, so the calculation had to be done. Looking at the most recent data, it looks like they now provide MPG so we should be able to avoid the rounding error in a future release. |
I am not sure that is the problem. The average was going down. Started at 26.7. It ignored 26.6, it ignored 26.5 and today it finally dropped to 26.4 from 26.7. |
It's not ignoring it, that's just the result of the lossy conversion from l/100km to mi/gal. The Subaru API reports Python 3.11.6 (main, Oct 28 2023, 15:08:23) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from homeassistant.util.unit_conversion import DistanceConverter, VolumeConverter
>>> from homeassistant.const import UnitOfLength, UnitOfVolume
>>>
>>> L_PER_GAL = VolumeConverter.convert(1, UnitOfVolume.GALLONS, UnitOfVolume.LITERS)
>>> KM_PER_MI = DistanceConverter.convert(1, UnitOfLength.MILES, UnitOfLength.KILOMETERS)
>>>
>>> L_PER_GAL
3.785411784
>>> KM_PER_MI
1.6093439999999999
>>>
>>> #https://github.com/home-assistant/core/blob/5b3e1306f82b2d370154e57657250b3107ae768a/homeassistant/components/subaru/sensor.py#L239C17-L239C17
>>> #round((100.0 * L_PER_GAL) / (KM_PER_MI * avgFuelConsumptionLitersPer100Kilometers), 1)
>>>
>>> round((100.0 * L_PER_GAL) / (KM_PER_MI * 8.7), 1)
27.0
>>> round((100.0 * L_PER_GAL) / (KM_PER_MI * 8.8), 1)
26.7
>>> round((100.0 * L_PER_GAL) / (KM_PER_MI * 8.9), 1)
26.4
>>> The good news is that the Subaru API now appears to directly report Before I can implement the change, I'll need to see your HA generated device diagnostics report during a time when the HA reported fuel consumption state doesn't exactly match what your actual vehicle is showing. Please paste or attach the diagnostics info to this issue. |
I'd be happy to do this, but please tell me how. |
Here is the file. The car shows 26.3, but HA shows 26.4. |
@onlize unfortunately the diagnostics file wasn't helpful since it only shows the data after it has been processed by subarulink and home assistant (i.e. it's the same incorrect data). I just submitted a PR #114119 that will return all the raw API data from Subaru, which will help. Once that PR is added to the next HA release, you'll be able to grab a more detailed diagnostic that shows every bit of data. This will help me see where to get a more accurate fuel consumption value. |
Okay, thank you. Please let me know when you want me to send you new logs. |
@onlize the PR has been merged, please send new device diagnostics dump, and I can look into it with more detail now. |
Hi, sorry for delay. Here is the latest diagnostic. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
I have the latest version of Home Assistant installed and I still have the same issue. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
Hi, I have the latest version of HA and the issue is not fixed yet. |
The problem
Subaru Average fuel consumption sensor does not show numbers between 26.7 and 27. Every time when I have 26.7, it shows correct information. When it goes to 26.8 or 26.9, it shows 27. When the Average fuel consumption drops to 26.7, it shows 26.7. After that, if I go higher, it shows 27.
What version of Home Assistant Core has the issue?
I set it up with 2023.9.x, updated every time, and now it is 2023.12.1 with the same issue.
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Subaru
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: