Add POD support, sleep fitness sensor to EightSleep (#31874)
* Add POD support, sleep fitness sensor * Black format changes * Change dict formatting
This commit is contained in:
1 parent
b77f2670a7
commit
164e970ba0
5 files changed
+43
-11
No files matched your search
@@ -28,6 +28,11 @@ ATTR_ACTIVE_HEAT = "Heating Active"
|
||||
ATTR_DURATION_HEAT = "Heating Time Remaining"
|
||||
ATTR_PROCESSING = "Processing"
|
||||
ATTR_SESSION_START = "Session Start"
|
||||
ATTR_FIT_DATE = "Fitness Date"
|
||||
ATTR_FIT_DURATION_SCORE = "Fitness Duration Score"
|
||||
ATTR_FIT_ASLEEP_SCORE = "Fitness Asleep Score"
|
||||
ATTR_FIT_OUT_SCORE = "Fitness Out-of-Bed Score"
|
||||
ATTR_FIT_WAKEUP_SCORE = "Fitness Wakeup Score"
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -151,7 +156,11 @@ class EightUserSensor(EightSleepUserEntity):
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
"""Return the unit the value is expressed in."""
|
||||
if "current_sleep" in self._sensor or "last_sleep" in self._sensor:
|
||||
if (
|
||||
"current_sleep" in self._sensor
|
||||
or "last_sleep" in self._sensor
|
||||
or "current_sleep_fitness" in self._sensor
|
||||
):
|
||||
return "Score"
|
||||
if "bed_temp" in self._sensor:
|
||||
if self._units == "si":
|
||||
@@ -169,8 +178,12 @@ class EightUserSensor(EightSleepUserEntity):
|
||||
"""Retrieve latest state."""
|
||||
_LOGGER.debug("Updating User sensor: %s", self._sensor)
|
||||
if "current" in self._sensor:
|
||||
self._state = self._usrobj.current_sleep_score
|
||||
self._attr = self._usrobj.current_values
|
||||
if "fitness" in self._sensor:
|
||||
self._state = self._usrobj.current_sleep_fitness_score
|
||||
self._attr = self._usrobj.current_fitness_values
|
||||
else:
|
||||
self._state = self._usrobj.current_sleep_score
|
||||
self._attr = self._usrobj.current_values
|
||||
elif "last" in self._sensor:
|
||||
self._state = self._usrobj.last_sleep_score
|
||||
self._attr = self._usrobj.last_values
|
||||
@@ -193,6 +206,16 @@ class EightUserSensor(EightSleepUserEntity):
|
||||
# Skip attributes if sensor type doesn't support
|
||||
return None
|
||||
|
||||
if "fitness" in self._sensor_root:
|
||||
state_attr = {
|
||||
ATTR_FIT_DATE: self._attr["date"],
|
||||
ATTR_FIT_DURATION_SCORE: self._attr["duration"],
|
||||
ATTR_FIT_ASLEEP_SCORE: self._attr["asleep"],
|
||||
ATTR_FIT_OUT_SCORE: self._attr["out"],
|
||||
ATTR_FIT_WAKEUP_SCORE: self._attr["wakeup"],
|
||||
}
|
||||
return state_attr
|
||||
|
||||
state_attr = {ATTR_SESSION_START: self._attr["date"]}
|
||||
state_attr[ATTR_TNT] = self._attr["tnt"]
|
||||
state_attr[ATTR_PROCESSING] = self._attr["processing"]
|
||||
|
||||
Reference in new issue
Block a user