mirror of
https://github.com/cyberjunky/home-assistant-garmin_connect.git
synced 2026-01-08 20:38:00 -05:00
Add total sleep duration
This commit is contained in:
@@ -57,6 +57,7 @@ Sedentary Time
|
|||||||
Sleeping Time
|
Sleeping Time
|
||||||
Awake Duration
|
Awake Duration
|
||||||
Sleep Duration
|
Sleep Duration
|
||||||
|
Total Sleep Duration
|
||||||
Floors Ascended
|
Floors Ascended
|
||||||
Floors Descended
|
Floors Descended
|
||||||
Floors Ascended Goal
|
Floors Ascended Goal
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
activity_types = {}
|
activity_types = {}
|
||||||
sleep_data = {}
|
sleep_data = {}
|
||||||
sleep_score = None
|
sleep_score = None
|
||||||
|
sleep_time_seconds = None
|
||||||
hrv_data = {}
|
hrv_data = {}
|
||||||
hrvStatus = {"status": "UNKNOWN"}
|
hrvStatus = {"status": "UNKNOWN"}
|
||||||
|
|
||||||
@@ -190,6 +191,12 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
_LOGGER.debug("Sleep score data is not available")
|
_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:
|
try:
|
||||||
if hrv_data and "hrvSummary" in hrv_data:
|
if hrv_data and "hrvSummary" in hrv_data:
|
||||||
hrvStatus = hrv_data["hrvSummary"]
|
hrvStatus = hrv_data["hrvSummary"]
|
||||||
@@ -206,6 +213,7 @@ class GarminConnectDataUpdateCoordinator(DataUpdateCoordinator):
|
|||||||
"activity_types": activity_types,
|
"activity_types": activity_types,
|
||||||
"gear_defaults": gear_defaults,
|
"gear_defaults": gear_defaults,
|
||||||
"sleepScore": sleep_score,
|
"sleepScore": sleep_score,
|
||||||
|
"sleepTimeSeconds": sleep_time_seconds,
|
||||||
"hrvStatus": hrvStatus,
|
"hrvStatus": hrvStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,6 +409,7 @@ GARMIN_ENTITY_LIST = {
|
|||||||
SensorStateClass.MEASUREMENT,
|
SensorStateClass.MEASUREMENT,
|
||||||
True,
|
True,
|
||||||
],
|
],
|
||||||
|
"sleepTimeSeconds": ["Total Sleep Duration", UnitOfTime.MINUTES, "mdi:sleep", None, SensorStateClass.TOTAL, True],
|
||||||
"hrvStatus": [
|
"hrvStatus": [
|
||||||
"HRV Status",
|
"HRV Status",
|
||||||
None,
|
None,
|
||||||
|
|||||||
Reference in New Issue
Block a user