mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use new enums in nest (#61942)
This commit is contained in:
parent
1e9e056671
commit
25d33a2126
@ -3,10 +3,7 @@ from itertools import chain
|
||||
import logging
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_CONNECTIVITY,
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OCCUPANCY,
|
||||
DEVICE_CLASS_SOUND,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import CONF_BINARY_SENSORS, CONF_MONITORED_CONDITIONS
|
||||
@ -16,7 +13,7 @@ from .const import DATA_NEST, DATA_NEST_CONFIG
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
BINARY_TYPES = {"online": DEVICE_CLASS_CONNECTIVITY}
|
||||
BINARY_TYPES = {"online": BinarySensorDeviceClass.CONNECTIVITY}
|
||||
|
||||
CLIMATE_BINARY_TYPES = {
|
||||
"fan": None,
|
||||
@ -26,9 +23,9 @@ CLIMATE_BINARY_TYPES = {
|
||||
}
|
||||
|
||||
CAMERA_BINARY_TYPES = {
|
||||
"motion_detected": DEVICE_CLASS_MOTION,
|
||||
"sound_detected": DEVICE_CLASS_SOUND,
|
||||
"person_detected": DEVICE_CLASS_OCCUPANCY,
|
||||
"motion_detected": BinarySensorDeviceClass.MOTION,
|
||||
"sound_detected": BinarySensorDeviceClass.SOUND,
|
||||
"person_detected": BinarySensorDeviceClass.OCCUPANCY,
|
||||
}
|
||||
|
||||
STRUCTURE_BINARY_TYPES = {"away": None}
|
||||
@ -160,7 +157,7 @@ class NestActivityZoneSensor(NestBinarySensor):
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the binary sensor."""
|
||||
return DEVICE_CLASS_MOTION
|
||||
return BinarySensorDeviceClass.MOTION
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
|
@ -1,12 +1,10 @@
|
||||
"""Support for Nest Thermostat sensors for the legacy API."""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.const import (
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_SENSORS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
PERCENTAGE,
|
||||
STATE_OFF,
|
||||
TEMP_CELSIUS,
|
||||
@ -47,7 +45,7 @@ _VALID_SENSOR_TYPES = (
|
||||
|
||||
SENSOR_UNITS = {"humidity": PERCENTAGE}
|
||||
|
||||
SENSOR_DEVICE_CLASSES = {"humidity": DEVICE_CLASS_HUMIDITY}
|
||||
SENSOR_DEVICE_CLASSES = {"humidity": SensorDeviceClass.HUMIDITY}
|
||||
|
||||
VARIABLE_NAME_MAPPING = {"eta": "eta_begin", "operation_mode": "mode"}
|
||||
|
||||
@ -201,7 +199,7 @@ class NestTempSensor(NestSensorDevice, SensorEntity):
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the sensor."""
|
||||
return DEVICE_CLASS_TEMPERATURE
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
|
@ -7,14 +7,13 @@ from google_nest_sdm.device import Device
|
||||
from google_nest_sdm.device_traits import HumidityTrait, TemperatureTrait
|
||||
from google_nest_sdm.exceptions import GoogleNestException
|
||||
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -58,7 +57,7 @@ class SensorBase(SensorEntity):
|
||||
"""Representation of a dynamically updated Sensor."""
|
||||
|
||||
_attr_shoud_poll = False
|
||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
def __init__(self, device: Device) -> None:
|
||||
"""Initialize the sensor."""
|
||||
@ -77,7 +76,7 @@ class SensorBase(SensorEntity):
|
||||
class TemperatureSensor(SensorBase):
|
||||
"""Representation of a Temperature Sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_TEMPERATURE
|
||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
|
||||
@property
|
||||
@ -98,7 +97,7 @@ class TemperatureSensor(SensorBase):
|
||||
class HumiditySensor(SensorBase):
|
||||
"""Representation of a Humidity Sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_HUMIDITY
|
||||
_attr_device_class = SensorDeviceClass.HUMIDITY
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user