Merge pull request #228 from lukas-hermans/main

Add total sleep duration sensor
This commit is contained in:
Ron
2025-01-17 13:08:44 +01:00
committed by GitHub
3 changed files with 10 additions and 0 deletions

View File

@@ -57,6 +57,7 @@ Sedentary Time
Sleeping Time
Awake Duration
Sleep Duration
Total Sleep Duration
Floors Ascended
Floors Descended
Floors Ascended Goal

View File

@@ -111,6 +111,7 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
activity_types = {}
sleep_data = {}
sleep_score = None
sleep_time_seconds = None
hrv_data = {}
hrvStatus = {"status": "UNKNOWN"}
@@ -190,6 +191,12 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
except KeyError:
_LOGGER.debug("Sleep score data is not available")
try:
sleep_time_seconds = sleep_data["dailySleepDTO"]["sleepTimeSeconds"]
_LOGGER.debug(f"Sleep time seconds data: {sleep_time_seconds}")
except KeyError:
_LOGGER.debug("Sleep time seconds data is not available")
try:
if hrv_data and "hrvSummary" in hrv_data:
hrvStatus = hrv_data["hrvSummary"]
@@ -206,6 +213,7 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
"activity_types": activity_types,
"gear_defaults": gear_defaults,
"sleepScore": sleep_score,
"sleepTimeSeconds": sleep_time_seconds,
"hrvStatus": hrvStatus,
}

View File

@@ -409,6 +409,7 @@ GARMIN_ENTITY_LIST = {
SensorStateClass.MEASUREMENT,
True,
],
"sleepTimeSeconds": ["Total Sleep Duration", UnitOfTime.MINUTES, "mdi:sleep", None, SensorStateClass.TOTAL, True],
"hrvStatus": [
"HRV Status",
None,