From aa879e70dba8ae2befca0154f1c9c6f96e4f5c3e Mon Sep 17 00:00:00 2001 From: Michael Ross Date: Fri, 24 Oct 2025 22:56:46 -0500 Subject: [PATCH 1/2] Added get_babies function --- python_snoo/containers.py | 4 ++-- python_snoo/snoo.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/python_snoo/containers.py b/python_snoo/containers.py index a43b1e0..53972a5 100644 --- a/python_snoo/containers.py +++ b/python_snoo/containers.py @@ -150,15 +150,15 @@ class BabySettings(DataClassJSONMixin): class BabyData(DataClassJSONMixin): _id: str babyName: str - birthDate: str breathSettingHistory: list createdAt: str disabledLimiter: bool - expectedBirthDate: str pictures: list settings: BabySettings sex: str preemie: Any | None = None # Not sure what datatype this is yet & may not be supplied - boolean? + birthDate: str | None = None + expectedBirthDate: str | None = None startedUsingSnooAt: str | None = None updatedAt: str | None = None diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index c1b93ab..4f0b3fd 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -15,11 +15,12 @@ from .containers import ( AuthorizationInfo, + BabyData, SnooData, SnooDevice, SnooStates, ) -from .exceptions import InvalidSnooAuth, SnooAuthException, SnooCommandException, SnooDeviceError +from .exceptions import InvalidSnooAuth, SnooAuthException, SnooBabyError, SnooCommandException, SnooDeviceError from .pubnub_async import SnooPubNub _LOGGER = logging.getLogger(__name__) @@ -34,7 +35,7 @@ def __init__(self, email: str, password: str, clientsession: aiohttp.ClientSessi self.snoo_auth_url = "https://api-us-east-1-prod.happiestbaby.com/us/me/v10/pubnub/authorize" self.snoo_devices_url = "https://api-us-east-1-prod.happiestbaby.com/hds/me/v11/devices" self.snoo_data_url = "https://happiestbaby.pubnubapi.com" - self.snoo_baby_url = "https://api-us-east-1-prod.happiestbaby.com/us/me/v10/babies/" + self.snoo_baby_url = "https://api-us-east-1-prod.happiestbaby.com/us/me/v10/babies" self.aws_auth_hdr = { "x-amz-target": "AWSCognitoIdentityProviderService.InitiateAuth", "accept-language": "US", @@ -325,6 +326,16 @@ async def get_devices(self) -> list[SnooDevice]: raise SnooDeviceError from ex devs = [SnooDevice.from_dict(dev) for dev in resp["snoo"]] return devs + + async def get_babies(self) -> list[BabyData]: + hdrs = self.generate_snoo_auth_headers(self.tokens.aws_id) + try: + r = await self.session.get(self.snoo_baby_url, headers=hdrs) + resp = await r.json() + except Exception as ex: + raise SnooBabyError from ex + babies = [BabyData.from_dict(baby) for baby in resp] + return babies def start_subscribe(self, device: SnooDevice, function: Callable): if device.serialNumber in self._mqtt_tasks and not self._mqtt_tasks[device.serialNumber].done(): From 29ac6f9570157c12d088a5a6484c07f3bbbe6490 Mon Sep 17 00:00:00 2001 From: Michael Ross Date: Sun, 26 Oct 2025 09:05:28 -0500 Subject: [PATCH 2/2] Fixed linting --- python_snoo/snoo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index 4f0b3fd..b78add9 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -326,7 +326,7 @@ async def get_devices(self) -> list[SnooDevice]: raise SnooDeviceError from ex devs = [SnooDevice.from_dict(dev) for dev in resp["snoo"]] return devs - + async def get_babies(self) -> list[BabyData]: hdrs = self.generate_snoo_auth_headers(self.tokens.aws_id) try: