diff --git a/homeassistant/components/nest/legacy/sensor.py b/homeassistant/components/nest/legacy/sensor.py index 86e73114568..ce38b2dbf0d 100644 --- a/homeassistant/components/nest/legacy/sensor.py +++ b/homeassistant/components/nest/legacy/sensor.py @@ -3,7 +3,11 @@ import logging -from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, +) from homeassistant.const import ( CONF_MONITORED_CONDITIONS, CONF_SENSORS, @@ -48,6 +52,8 @@ SENSOR_UNITS = {"humidity": PERCENTAGE} SENSOR_DEVICE_CLASSES = {"humidity": SensorDeviceClass.HUMIDITY} +SENSOR_STATE_CLASSES = {"humidity": SensorStateClass.MEASUREMENT} + VARIABLE_NAME_MAPPING = {"eta": "eta_begin", "operation_mode": "mode"} VALUE_MAPPING = { @@ -167,6 +173,11 @@ class NestBasicSensor(NestSensorDevice, SensorEntity): """Return the device class of the sensor.""" return SENSOR_DEVICE_CLASSES.get(self.variable) + @property + def state_class(self): + """Return the state class of the sensor.""" + return SENSOR_STATE_CLASSES.get(self.variable) + def update(self): """Retrieve latest state.""" self._unit = SENSOR_UNITS.get(self.variable) @@ -202,6 +213,11 @@ class NestTempSensor(NestSensorDevice, SensorEntity): """Return the device class of the sensor.""" return SensorDeviceClass.TEMPERATURE + @property + def state_class(self): + """Return the state class of the sensor.""" + return SensorStateClass.MEASUREMENT + def update(self): """Retrieve latest state.""" if self.device.temperature_scale == "C":