DurgNomis-drol / ha_toyota

Toyota Connected Services integration for Home Assistant.
MIT License
148 stars 29 forks source link

"Use metric units" toggle has no effect #217

Closed ccristal closed 7 months ago

ccristal commented 8 months ago

Describe the bug Even though I switch off the "Use metric units" toggle during the first configuration, sensor values are still expressed in metric units.

To Reproduce Steps to reproduce the behavior:

  1. Settings -> Devices & Services
  2. Add Integration
  3. Select "Toyota Connected Services"
  4. Enter MyT email and password
  5. Switch off the "Use metric units" toggle
  6. Click "Submit":
  7. Click "Finish"
  8. On the Toyota Connected Service tile, click on "1 device"
  9. Observe that all the numeric values for the Sensors are expressed in Km:

Expected behavior The sensor values should be expressed in miles.

Screenshots image image

Additional context Add any other context about the problem here.

CM000n commented 8 months ago

That is strange. I'll have a look at it. Thank you for reporting it.

CM000n commented 8 months ago

That's really really strange. When I activate the logging and look at the state for metric_values, it is actually propagated correctly until the sensor entities are created. But Home Assistant just seems to completely ignore the conditions somehow 😿 .

CM000n commented 8 months ago

Hi @ccristal. This seems to be a issue of the category "It's not a bug, it's a Feature!" 😆

I have looked at our code and could not find any errors. The switch does exactly what it is supposed to do. Depending on the selection, the mytoyota python lib returns either metric or no metric values.

The "problem" lies with Home Assistant itself. Depending on the settings for Home Assistant, the units are converted automatically! However, this can also be overwritten later in the settings of the respective sensors: Screenshot 2024-01-11 162827

I think I have also found a setting option that allows us to specify the units with which a sensor should initially be displayed. This should be included in the next release 😊 In the meantime, you can simply set your sensors to the desired display format yourself 😉

ccristal commented 8 months ago

Thank you for looking into this... :-)