mirror of
https://github.com/cyberjunky/home-assistant-garmin_connect.git
synced 2026-01-06 19:43:52 -05:00
Merge pull request #228 from lukas-hermans/main
Add total sleep duration sensor
This commit is contained in:
@@ -57,6 +57,7 @@ Sedentary Time
|
||||
Sleeping Time
|
||||
Awake Duration
|
||||
Sleep Duration
|
||||
Total Sleep Duration
|
||||
Floors Ascended
|
||||
Floors Descended
|
||||
Floors Ascended Goal
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user