Use new device class in environment canada (#83297)
parent
6053b6f94a
commit
9682249830
|
@ -15,13 +15,13 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ATTR_LOCATION,
|
||||
DEGREE,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILLIMETERS,
|
||||
PERCENTAGE,
|
||||
PRESSURE_KPA,
|
||||
SPEED_KILOMETERS_PER_HOUR,
|
||||
TEMP_CELSIUS,
|
||||
UV_INDEX,
|
||||
UnitOfLength,
|
||||
UnitOfPrecipitationDepth,
|
||||
UnitOfPressure,
|
||||
UnitOfSpeed,
|
||||
UnitOfTemperature,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -59,7 +59,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="dewpoint",
|
||||
name="Dew point",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("dewpoint", {}).get("value"),
|
||||
),
|
||||
|
@ -67,7 +67,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="high_temp",
|
||||
name="High temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("high_temp", {}).get("value"),
|
||||
),
|
||||
|
@ -75,7 +75,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="humidex",
|
||||
name="Humidex",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("humidex", {}).get("value"),
|
||||
),
|
||||
|
@ -96,7 +96,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="low_temp",
|
||||
name="Low temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("low_temp", {}).get("value"),
|
||||
),
|
||||
|
@ -104,14 +104,14 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="normal_high",
|
||||
name="Normal high temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
value_fn=lambda data: data.conditions.get("normal_high", {}).get("value"),
|
||||
),
|
||||
ECSensorEntityDescription(
|
||||
key="normal_low",
|
||||
name="Normal low temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
value_fn=lambda data: data.conditions.get("normal_low", {}).get("value"),
|
||||
),
|
||||
ECSensorEntityDescription(
|
||||
|
@ -123,7 +123,8 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
ECSensorEntityDescription(
|
||||
key="precip_yesterday",
|
||||
name="Precipitation yesterday",
|
||||
native_unit_of_measurement=LENGTH_MILLIMETERS,
|
||||
device_class=SensorDeviceClass.PRECIPITATION,
|
||||
native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("precip_yesterday", {}).get("value"),
|
||||
),
|
||||
|
@ -131,7 +132,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="pressure",
|
||||
name="Barometric pressure",
|
||||
device_class=SensorDeviceClass.PRESSURE,
|
||||
native_unit_of_measurement=PRESSURE_KPA,
|
||||
native_unit_of_measurement=UnitOfPressure.KPA,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("pressure", {}).get("value"),
|
||||
),
|
||||
|
@ -139,7 +140,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="temperature",
|
||||
name="Temperature",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("temperature", {}).get("value"),
|
||||
),
|
||||
|
@ -171,7 +172,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
ECSensorEntityDescription(
|
||||
key="visibility",
|
||||
name="Visibility",
|
||||
native_unit_of_measurement=LENGTH_KILOMETERS,
|
||||
native_unit_of_measurement=UnitOfLength.KILOMETERS,
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("visibility", {}).get("value"),
|
||||
|
@ -186,7 +187,7 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
key="wind_chill",
|
||||
name="Wind chill",
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=TEMP_CELSIUS,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("wind_chill", {}).get("value"),
|
||||
),
|
||||
|
@ -198,16 +199,16 @@ SENSOR_TYPES: tuple[ECSensorEntityDescription, ...] = (
|
|||
ECSensorEntityDescription(
|
||||
key="wind_gust",
|
||||
name="Wind gust",
|
||||
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
|
||||
device_class=SensorDeviceClass.SPEED,
|
||||
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
|
||||
device_class=SensorDeviceClass.WIND_SPEED,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("wind_gust", {}).get("value"),
|
||||
),
|
||||
ECSensorEntityDescription(
|
||||
key="wind_speed",
|
||||
name="Wind speed",
|
||||
native_unit_of_measurement=SPEED_KILOMETERS_PER_HOUR,
|
||||
device_class=SensorDeviceClass.SPEED,
|
||||
native_unit_of_measurement=UnitOfSpeed.KILOMETERS_PER_HOUR,
|
||||
device_class=SensorDeviceClass.WIND_SPEED,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda data: data.conditions.get("wind_speed", {}).get("value"),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue