Closed JustSid closed 2 months ago
Same for me, just to add to Justin's comment, include diagnostic information, maybe you can divide by hundred when the unit of measurement is cents per liter
"data": { "station_id": "00000", "unit_of_measure": "cents_per_liter", "currency": "CAD", "latitude": XX.XXXX, "longitude": -XX.XXX, "regular_gas": { "credit": "masskazy", "price": 145.9, "last_updated": "2024-09-16T18:27:57.481Z" },
Thank you very much! I can finally afford fuel again 😄
But that's not how gas is reported at the pump, so why is this an issue?
Price at the pump is reported in cents per liter, so 149.9¢. This is equivalent to $1.499, the value that is now reported by the sensor. It is however not at all equivalent to $149.9, which was the number previously reported by the sensor.
Gotcha. While it doesn't denote with the dollar sign per se, I see what you mean in the inconsistency with how something in "CAD" should mean dollars.
I'll see about opening a separate issue or PR related to this, as the fix in #78 was a breaking change without being properly labeled as such. Messing with the value of the state rather than changing the unit_of_measurement
can completely break automations/scripts for folks running 1.0.11 or older. It also ruins the history graphs, as all historical data post-update is now an order of magnitude lower.
I think this should have instead been addressed toward the unit_of_measurement
field. By default, the state should be the unmodified (expected) value from the GasBuddy API. If the user wants the dollar value like 1.499
, that sounds like a feature for the existing Display precision
setting in the entities' configurations.
In my case, I have stations in Canada and US, so I have USD/gallons and CAD/liters values, so values ​​like 3.37 USD/gallons and 1.449 CAD/liter, in the version before the fix I had 144.9 CAD/liter. CAD represents Canadian dollars. I think our problem is that Home Assistant does not recognize the cent per liter and converts it to dollars per liter, The fix provided by Chris is perfect and fixes the problem. Because 144.9$ is a bit expensive for me.
Thanps Chris
The problem
Basically what the title says. The sensor reports the unit of measure as CAD or CAD/Liter depending on the settings, but the price gets reported in cents. So the sensor reports values like
149.9 CAD
. It should be1.499 CAD
.What version of Home Assistant?
core-2024.9.1
What version of GasBuddy?
1.0.11
Diagnostics information
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response