Adjust get_distance_unit in mazda integration (#80233)
* Adjust get_distance_unit in mazda integration * Use system compare with DistanceConverter * Adjust rounding * Use is not == * Reduce size of PR
This commit is contained in:
parent
3e0e845217
commit
a06bd04def
1 changed files with 3 additions and 4 deletions
|
@ -13,7 +13,6 @@ from homeassistant.components.sensor import (
|
|||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILES,
|
||||
PERCENTAGE,
|
||||
|
@ -22,7 +21,7 @@ from homeassistant.const import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.util.unit_system import UnitSystem
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, UnitSystem
|
||||
|
||||
from . import MazdaEntity
|
||||
from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
|
||||
|
@ -50,9 +49,9 @@ class MazdaSensorEntityDescription(
|
|||
unit: Callable[[UnitSystem], str | None] | None = None
|
||||
|
||||
|
||||
def _get_distance_unit(unit_system):
|
||||
def _get_distance_unit(unit_system: UnitSystem) -> str:
|
||||
"""Return the distance unit for the given unit system."""
|
||||
if unit_system.name == CONF_UNIT_SYSTEM_IMPERIAL:
|
||||
if unit_system is IMPERIAL_SYSTEM:
|
||||
return LENGTH_MILES
|
||||
return LENGTH_KILOMETERS
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue