Use new unit enums in weather integrations (#82938)

This commit is contained in:
epenet 2022-11-29 18:13:05 +01:00 committed by GitHub
parent 4ad9633dfb
commit c092f2be04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 151 additions and 160 deletions

View file

@ -41,11 +41,11 @@ from homeassistant.const import (
CONF_LATITUDE,
CONF_LONGITUDE,
CONF_NAME,
LENGTH_METERS,
LENGTH_MILLIMETERS,
PRESSURE_HPA,
SPEED_METERS_PER_SECOND,
TEMP_CELSIUS,
UnitOfLength,
UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -120,11 +120,11 @@ async def async_setup_entry(
class BrWeather(WeatherEntity):
"""Representation of a weather condition."""
_attr_native_precipitation_unit = LENGTH_MILLIMETERS
_attr_native_pressure_unit = PRESSURE_HPA
_attr_native_temperature_unit = TEMP_CELSIUS
_attr_native_visibility_unit = LENGTH_METERS
_attr_native_wind_speed_unit = SPEED_METERS_PER_SECOND
_attr_native_precipitation_unit = UnitOfPrecipitationDepth.MILLIMETERS
_attr_native_pressure_unit = UnitOfPressure.HPA
_attr_native_temperature_unit = UnitOfTemperature.CELSIUS
_attr_native_visibility_unit = UnitOfLength.METERS
_attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
def __init__(self, data, config, coordinates):
"""Initialize the platform with a data instance and station name."""