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