From 7f23ab9d86178a9fe00cfedd14cfee088270ce97 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Mon, 7 Nov 2022 15:46:41 -0500 Subject: [PATCH] Add measurement state class to eight_sleep sensors (#81589) * Add measurement state class to eight_sleep sensors * tweaks --- homeassistant/components/eight_sleep/sensor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/eight_sleep/sensor.py b/homeassistant/components/eight_sleep/sensor.py index 7cce1293707..58648123dcf 100644 --- a/homeassistant/components/eight_sleep/sensor.py +++ b/homeassistant/components/eight_sleep/sensor.py @@ -7,7 +7,11 @@ from typing import Any from pyeight.eight import EightSleep import voluptuous as vol -from homeassistant.components.sensor import SensorDeviceClass, SensorEntity +from homeassistant.components.sensor import ( + SensorDeviceClass, + SensorEntity, + SensorStateClass, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import PERCENTAGE, UnitOfTemperature from homeassistant.core import HomeAssistant @@ -179,6 +183,9 @@ class EightUserSensor(EightSleepBaseEntity, SensorEntity): elif self._sensor in ("current_sleep", "last_sleep", "current_sleep_fitness"): self._attr_native_unit_of_measurement = "Score" + if self._sensor != "sleep_stage": + self._attr_state_class = SensorStateClass.MEASUREMENT + _LOGGER.debug( "User Sensor: %s, Side: %s, User: %s", self._sensor, @@ -272,6 +279,7 @@ class EightRoomSensor(EightSleepBaseEntity, SensorEntity): _attr_icon = "mdi:thermometer" _attr_device_class = SensorDeviceClass.TEMPERATURE + _attr_state_class = SensorStateClass.MEASUREMENT _attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS def __init__(