Skip to content
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

Fuel unit is shown in L instead of G for en_US #276

Open
derhally opened this issue Nov 24, 2024 · 4 comments
Open

Fuel unit is shown in L instead of G for en_US #276

derhally opened this issue Nov 24, 2024 · 4 comments

Comments

@derhally
Copy link

Describe the bug

I just installed this addon or a XC90 T8 2025 PHEV and it works well. The only issue so far is that it shows liters instead of gallons even though the locale is set to en_US

Expected behavior:

Units fuel for US should be in gallons.

Screenshots:

image

Version info:

v1.10.5

@billraff
Copy link

You could create a sensor to covert this:

template:

  • sensor:
    • name: "Fuel Level in Gallons"
      unit_of_measurement: "gal"
      state: >
      {{ states('sensor.car_fuel_level') | float * 0.264172 }}

@derhally
Copy link
Author

Thanks. that's what I ended up doing.

Copy link

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@photogeek134
Copy link

Thanks. that's what I ended up doing.

I also encountered this "bug" and couldn't stand seeing the mismatched units, so I did the same. In case you didn't catch it, you'll also need to convert the Average Fuel Consumption (reported as L/100km) and the Average Energy Consumption (reported as kWh/100km). After making the below updates my custom dashboard matches what's in the Volvo Cars app.

Here's what I have in my template.yaml:

- sensor:
    - name: "Lars - 2025 XC90 T8 Fuel Level Gallons"
      unique_id: "volvo_[VIN]_fuel_level_gallons"
      unit_of_measurement: "gal"
      state: "{{ (states('sensor.volvo_[VIN]_fuel_level') | float * 0.264172) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_[VIN]_fuel_level')) }}"
      device_class: "volume_storage"

    - name: "Lars - 2025 XC90 T8 Average Fuel Consumption Gallons"
      unique_id: "volvo_[VIN]_average_fuel_consumption_gallons"
      unit_of_measurement: "mi/gal"
      state: "{{ (235.2145 / states('sensor.volvo_[VIN]_average_fuel_consumption') | float) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_[VIN]_average_fuel_consumption')) }}"
      device_class: "volume"

    - name: "Lars - 2025 XC90 T8 Average Energy Consumption Miles"
      unique_id: "volvo_[VIN]_average_energy_consumption_miles"
      unit_of_measurement: "kWh/100mi"
      state: "{{ (states('sensor.volvo_[VIN]_average_energy_consumption') | float * 1.609344) | round(2) }}"
      availability: "{{ is_number(states('sensor.volvo_[VIN]_average_energy_consumption')) }}"
      device_class: "energy"

Is this a Volvo issue or an MQTT issue or a combination of the two? I suspect the actual measurements for these sensors are all done natively with metric values and then converted to US units. I just find it strange that most of the values are properly converted, but these 3 are still unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants