Use new DeviceClass and StateClass enums in darksky (#61342)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
cfb1002920
commit
f4d66f67d5
1 changed files with 20 additions and 23 deletions
|
@ -11,11 +11,11 @@ from requests.exceptions import ConnectionError as ConnectError, HTTPError, Time
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
ATTR_ATTRIBUTION,
|
||||||
|
@ -26,9 +26,6 @@ from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_SCAN_INTERVAL,
|
CONF_SCAN_INTERVAL,
|
||||||
DEGREE,
|
DEGREE,
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_OZONE,
|
|
||||||
DEVICE_CLASS_PRESSURE,
|
|
||||||
LENGTH_CENTIMETERS,
|
LENGTH_CENTIMETERS,
|
||||||
LENGTH_INCHES,
|
LENGTH_INCHES,
|
||||||
LENGTH_KILOMETERS,
|
LENGTH_KILOMETERS,
|
||||||
|
@ -181,8 +178,8 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"temperature": DarkskySensorEntityDescription(
|
"temperature": DarkskySensorEntityDescription(
|
||||||
key="temperature",
|
key="temperature",
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -193,8 +190,8 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"apparent_temperature": DarkskySensorEntityDescription(
|
"apparent_temperature": DarkskySensorEntityDescription(
|
||||||
key="apparent_temperature",
|
key="apparent_temperature",
|
||||||
name="Apparent Temperature",
|
name="Apparent Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -205,8 +202,8 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"dew_point": DarkskySensorEntityDescription(
|
"dew_point": DarkskySensorEntityDescription(
|
||||||
key="dew_point",
|
key="dew_point",
|
||||||
name="Dew Point",
|
name="Dew Point",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -261,8 +258,8 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"humidity": DarkskySensorEntityDescription(
|
"humidity": DarkskySensorEntityDescription(
|
||||||
key="humidity",
|
key="humidity",
|
||||||
name="Humidity",
|
name="Humidity",
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
si_unit=PERCENTAGE,
|
si_unit=PERCENTAGE,
|
||||||
us_unit=PERCENTAGE,
|
us_unit=PERCENTAGE,
|
||||||
ca_unit=PERCENTAGE,
|
ca_unit=PERCENTAGE,
|
||||||
|
@ -273,7 +270,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"pressure": DarkskySensorEntityDescription(
|
"pressure": DarkskySensorEntityDescription(
|
||||||
key="pressure",
|
key="pressure",
|
||||||
name="Pressure",
|
name="Pressure",
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
si_unit=PRESSURE_MBAR,
|
si_unit=PRESSURE_MBAR,
|
||||||
us_unit=PRESSURE_MBAR,
|
us_unit=PRESSURE_MBAR,
|
||||||
ca_unit=PRESSURE_MBAR,
|
ca_unit=PRESSURE_MBAR,
|
||||||
|
@ -295,7 +292,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"ozone": DarkskySensorEntityDescription(
|
"ozone": DarkskySensorEntityDescription(
|
||||||
key="ozone",
|
key="ozone",
|
||||||
name="Ozone",
|
name="Ozone",
|
||||||
device_class=DEVICE_CLASS_OZONE,
|
device_class=SensorDeviceClass.OZONE,
|
||||||
si_unit="DU",
|
si_unit="DU",
|
||||||
us_unit="DU",
|
us_unit="DU",
|
||||||
ca_unit="DU",
|
ca_unit="DU",
|
||||||
|
@ -306,7 +303,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"apparent_temperature_max": DarkskySensorEntityDescription(
|
"apparent_temperature_max": DarkskySensorEntityDescription(
|
||||||
key="apparent_temperature_max",
|
key="apparent_temperature_max",
|
||||||
name="Daily High Apparent Temperature",
|
name="Daily High Apparent Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -317,7 +314,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"apparent_temperature_high": DarkskySensorEntityDescription(
|
"apparent_temperature_high": DarkskySensorEntityDescription(
|
||||||
key="apparent_temperature_high",
|
key="apparent_temperature_high",
|
||||||
name="Daytime High Apparent Temperature",
|
name="Daytime High Apparent Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -328,7 +325,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"apparent_temperature_min": DarkskySensorEntityDescription(
|
"apparent_temperature_min": DarkskySensorEntityDescription(
|
||||||
key="apparent_temperature_min",
|
key="apparent_temperature_min",
|
||||||
name="Daily Low Apparent Temperature",
|
name="Daily Low Apparent Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -339,7 +336,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"apparent_temperature_low": DarkskySensorEntityDescription(
|
"apparent_temperature_low": DarkskySensorEntityDescription(
|
||||||
key="apparent_temperature_low",
|
key="apparent_temperature_low",
|
||||||
name="Overnight Low Apparent Temperature",
|
name="Overnight Low Apparent Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -350,7 +347,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"temperature_max": DarkskySensorEntityDescription(
|
"temperature_max": DarkskySensorEntityDescription(
|
||||||
key="temperature_max",
|
key="temperature_max",
|
||||||
name="Daily High Temperature",
|
name="Daily High Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -361,7 +358,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"temperature_high": DarkskySensorEntityDescription(
|
"temperature_high": DarkskySensorEntityDescription(
|
||||||
key="temperature_high",
|
key="temperature_high",
|
||||||
name="Daytime High Temperature",
|
name="Daytime High Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -372,7 +369,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"temperature_min": DarkskySensorEntityDescription(
|
"temperature_min": DarkskySensorEntityDescription(
|
||||||
key="temperature_min",
|
key="temperature_min",
|
||||||
name="Daily Low Temperature",
|
name="Daily Low Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
@ -383,7 +380,7 @@ SENSOR_TYPES: dict[str, DarkskySensorEntityDescription] = {
|
||||||
"temperature_low": DarkskySensorEntityDescription(
|
"temperature_low": DarkskySensorEntityDescription(
|
||||||
key="temperature_low",
|
key="temperature_low",
|
||||||
name="Overnight Low Temperature",
|
name="Overnight Low Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
si_unit=TEMP_CELSIUS,
|
si_unit=TEMP_CELSIUS,
|
||||||
us_unit=TEMP_FAHRENHEIT,
|
us_unit=TEMP_FAHRENHEIT,
|
||||||
ca_unit=TEMP_CELSIUS,
|
ca_unit=TEMP_CELSIUS,
|
||||||
|
|
Loading…
Add table
Reference in a new issue