Use new device class in netatmo (#83367)

This commit is contained in:
epenet 2022-12-08 20:57:51 +01:00 committed by GitHub
parent 0edcb26844
commit 0f2097595e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,13 +19,13 @@ from homeassistant.const import (
ATTR_LONGITUDE, ATTR_LONGITUDE,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
LENGTH_MILLIMETERS,
PERCENTAGE, PERCENTAGE,
POWER_WATT,
PRESSURE_MBAR,
SOUND_PRESSURE_DB, SOUND_PRESSURE_DB,
SPEED_KILOMETERS_PER_HOUR, UnitOfPower,
TEMP_CELSIUS, UnitOfPrecipitationDepth,
UnitOfPressure,
UnitOfSpeed,
UnitOfTemperature,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import device_registry as dr from homeassistant.helpers import device_registry as dr
@ -88,7 +88,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Temperature", name="Temperature",
netatmo_name="temperature", netatmo_name="temperature",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=UnitOfTemperature.CELSIUS,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.TEMPERATURE, device_class=SensorDeviceClass.TEMPERATURE,
), ),
@ -113,7 +113,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Pressure", name="Pressure",
netatmo_name="pressure", netatmo_name="pressure",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
native_unit_of_measurement=PRESSURE_MBAR, native_unit_of_measurement=UnitOfPressure.MBAR,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.PRESSURE, device_class=SensorDeviceClass.PRESSURE,
), ),
@ -147,27 +147,27 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Rain", name="Rain",
netatmo_name="rain", netatmo_name="rain",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
native_unit_of_measurement=LENGTH_MILLIMETERS, native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:weather-rainy",
), ),
NetatmoSensorEntityDescription( NetatmoSensorEntityDescription(
key="sum_rain_1", key="sum_rain_1",
name="Rain last hour", name="Rain last hour",
netatmo_name="sum_rain_1", netatmo_name="sum_rain_1",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
native_unit_of_measurement=LENGTH_MILLIMETERS, native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.TOTAL, state_class=SensorStateClass.TOTAL,
icon="mdi:weather-rainy",
), ),
NetatmoSensorEntityDescription( NetatmoSensorEntityDescription(
key="sum_rain_24", key="sum_rain_24",
name="Rain today", name="Rain today",
netatmo_name="sum_rain_24", netatmo_name="sum_rain_24",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
native_unit_of_measurement=LENGTH_MILLIMETERS, native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS,
device_class=SensorDeviceClass.PRECIPITATION,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
icon="mdi:weather-rainy",
), ),
NetatmoSensorEntityDescription( NetatmoSensorEntityDescription(
key="battery_percent", key="battery_percent",
@ -200,9 +200,8 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Wind Strength", name="Wind Strength",
netatmo_name="wind_strength", netatmo_name="wind_strength",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
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,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
NetatmoSensorEntityDescription( NetatmoSensorEntityDescription(
@ -226,9 +225,8 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Gust Strength", name="Gust Strength",
netatmo_name="gust_strength", netatmo_name="gust_strength",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
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,
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
NetatmoSensorEntityDescription( NetatmoSensorEntityDescription(
@ -267,7 +265,7 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
name="Power", name="Power",
netatmo_name="power", netatmo_name="power",
entity_registry_enabled_default=True, entity_registry_enabled_default=True,
native_unit_of_measurement=POWER_WATT, native_unit_of_measurement=UnitOfPower.WATT,
state_class=SensorStateClass.TOTAL, state_class=SensorStateClass.TOTAL,
device_class=SensorDeviceClass.POWER, device_class=SensorDeviceClass.POWER,
), ),