mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Fix wind speed unit (#65723)
This commit is contained in:
parent
57526bd21f
commit
9695235920
@ -17,7 +17,12 @@ from homeassistant.components.weather import (
|
|||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import (
|
||||||
|
CONF_NAME,
|
||||||
|
SPEED_MILES_PER_HOUR,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
TEMP_FAHRENHEIT,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||||
from homeassistant.helpers.entity import DeviceInfo
|
from homeassistant.helpers.entity import DeviceInfo
|
||||||
@ -62,9 +67,13 @@ class AccuWeatherEntity(CoordinatorEntity, WeatherEntity):
|
|||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._unit_system = API_METRIC if coordinator.is_metric else API_IMPERIAL
|
self._unit_system = API_METRIC if coordinator.is_metric else API_IMPERIAL
|
||||||
self._attr_wind_speed_unit = self.coordinator.data["Wind"]["Speed"][
|
wind_speed_unit = self.coordinator.data["Wind"]["Speed"][self._unit_system][
|
||||||
self._unit_system
|
"Unit"
|
||||||
]["Unit"]
|
]
|
||||||
|
if wind_speed_unit == "mi/h":
|
||||||
|
self._attr_wind_speed_unit = SPEED_MILES_PER_HOUR
|
||||||
|
else:
|
||||||
|
self._attr_wind_speed_unit = wind_speed_unit
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
self._attr_unique_id = coordinator.location_key
|
self._attr_unique_id = coordinator.location_key
|
||||||
self._attr_temperature_unit = (
|
self._attr_temperature_unit = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user