From 1a9b50fa02043d4003b079138267ecf71c0a5dc4 Mon Sep 17 00:00:00 2001 From: Giles Harrison-Smit Date: Wed, 21 Jan 2026 14:34:04 +1100 Subject: [PATCH 01/10] Enable support for snoo sleepytime timeout levels with enum provide values --- python_snoo/baby.py | 6 +++--- python_snoo/containers.py | 43 ++++++++++++++++++++++++++++++++++++++- python_snoo/snoo.py | 5 +++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/python_snoo/baby.py b/python_snoo/baby.py index 6a3895b..4ced743 100644 --- a/python_snoo/baby.py +++ b/python_snoo/baby.py @@ -1,8 +1,8 @@ from datetime import datetime -from python_snoo.containers import Activity, BabyData, BreastfeedingActivity, DiaperActivity, DiaperTypes -from python_snoo.exceptions import SnooBabyError -from python_snoo.snoo import Snoo +from .containers import Activity, BabyData, BreastfeedingActivity, DiaperActivity, DiaperTypes +from .exceptions import SnooBabyError +from .snoo import Snoo class Baby: diff --git a/python_snoo/containers.py b/python_snoo/containers.py index 53972a5..21b2ea6 100644 --- a/python_snoo/containers.py +++ b/python_snoo/containers.py @@ -1,6 +1,9 @@ +#maybe we dont need this +from __future__ import annotations + import dataclasses import datetime -from enum import StrEnum +from enum import StrEnum, IntEnum from typing import Any, Union from mashumaro.mixins.json import DataClassJSONMixin @@ -15,6 +18,44 @@ class SnooLevels(StrEnum): level4 = "LEVEL4" stop = "ONLINE" +class SnooNoiseTimeoutLevels(IntEnum): + _5_minutes = 5 + _10_minutes = 10 + _15_minutes = 15 + _20_minutes = 20 + _25_minutes = 25 + _30_minutes = 30 + _35_minutes = 35 + _40_minutes = 40 + _45_minutes = 45 + _50_minutes = 50 + _55_minutes = 55 + _60_minutes = 60 + _65_minutes = 65 + _70_minutes = 70 + _75_minutes = 75 + _80_minutes = 80 + _85_minutes = 85 + _90_minutes = 90 + _95_minutes = 95 + _100_minutes = 100 + _105_minutes = 105 + _110_minutes = 110 + _115_minutes = 115 + _120_minutes = 120 + _125_minutes = 125 + _130_minutes = 130 + _135_minutes = 135 + _140_minutes = 140 + _145_minutes = 145 + _150_minutes = 150 + _155_minutes = 155 + _160_minutes = 160 + _165_minutes = 165 + _170_minutes = 170 + _175_minutes = 175 + _180_minutes = 180 + class SnooStates(StrEnum): baseline = "BASELINE" diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index b78add9..d6f177e 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -19,6 +19,7 @@ SnooData, SnooDevice, SnooStates, + SnooNoiseTimeoutLevels ) from .exceptions import InvalidSnooAuth, SnooAuthException, SnooBabyError, SnooCommandException, SnooDeviceError from .pubnub_async import SnooPubNub @@ -233,11 +234,11 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) - async def set_sticky_white_noise(self, device: SnooDevice, on: bool): + async def set_sticky_white_noise(self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes): await self.send_command( "set_sticky_white_noise", device, - **{"state": "on" if on else "off", "timeout_min": 15}, + **{"state": "on" if on else "off", "timeout_min": timeout_value}, ) async def get_status(self, device: SnooDevice): From d9e51f139a1406f1ef893d0cbad457e373915f90 Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:31:20 +1100 Subject: [PATCH 02/10] Update python_snoo/snoo.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- python_snoo/snoo.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index d6f177e..ccf00c3 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -235,6 +235,15 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) async def set_sticky_white_noise(self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes): + """Enable or disable sticky white noise for a device. + + Args: + device: The SnooDevice to control. + on: True to turn sticky white noise on, False to turn it off. + timeout_value: How long the white noise should remain on before timing out. + Must be a member of the SnooNoiseTimeoutLevels enum. The default is + SnooNoiseTimeoutLevels._15_minutes. + """ await self.send_command( "set_sticky_white_noise", device, From a84c8baafc69c70bf127955433d8bfacbead2029 Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:09:55 +1100 Subject: [PATCH 03/10] Update containers.py remove future annotations --- python_snoo/containers.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python_snoo/containers.py b/python_snoo/containers.py index 21b2ea6..e1c4e5e 100644 --- a/python_snoo/containers.py +++ b/python_snoo/containers.py @@ -1,6 +1,3 @@ -#maybe we dont need this -from __future__ import annotations - import dataclasses import datetime from enum import StrEnum, IntEnum From 3e263b5cf50bec34c81ef02a0081ef16a7948fb6 Mon Sep 17 00:00:00 2001 From: Giles Harrison-Smit Date: Thu, 22 Jan 2026 14:22:09 +1100 Subject: [PATCH 04/10] Fix up linting as suggested --- python_snoo/containers.py | 3 ++- python_snoo/snoo.py | 13 ++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/python_snoo/containers.py b/python_snoo/containers.py index e1c4e5e..e6f8283 100644 --- a/python_snoo/containers.py +++ b/python_snoo/containers.py @@ -1,6 +1,6 @@ import dataclasses import datetime -from enum import StrEnum, IntEnum +from enum import IntEnum, StrEnum from typing import Any, Union from mashumaro.mixins.json import DataClassJSONMixin @@ -15,6 +15,7 @@ class SnooLevels(StrEnum): level4 = "LEVEL4" stop = "ONLINE" + class SnooNoiseTimeoutLevels(IntEnum): _5_minutes = 5 _10_minutes = 10 diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index ccf00c3..3a05cfb 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -13,14 +13,7 @@ from pubnub.pnconfiguration import PNConfiguration from pubnub.pubnub_asyncio import PubNubAsyncio -from .containers import ( - AuthorizationInfo, - BabyData, - SnooData, - SnooDevice, - SnooStates, - SnooNoiseTimeoutLevels -) +from .containers import AuthorizationInfo, BabyData, SnooData, SnooDevice, SnooStates, SnooNoiseTimeoutLevels from .exceptions import InvalidSnooAuth, SnooAuthException, SnooBabyError, SnooCommandException, SnooDeviceError from .pubnub_async import SnooPubNub @@ -234,7 +227,9 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) - async def set_sticky_white_noise(self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes): + async def set_sticky_white_noise( + self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes + ): """Enable or disable sticky white noise for a device. Args: From 8a74f0c80bd3a374de61ed5b5828341f9a2a6595 Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:36:44 +1100 Subject: [PATCH 05/10] Fix ordering of imports As suggested by linter --- 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 3a05cfb..bf93721 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -13,7 +13,7 @@ from pubnub.pnconfiguration import PNConfiguration from pubnub.pubnub_asyncio import PubNubAsyncio -from .containers import AuthorizationInfo, BabyData, SnooData, SnooDevice, SnooStates, SnooNoiseTimeoutLevels +from .containers import AuthorizationInfo, BabyData, SnooData, SnooDevice, SnooNoiseTimeoutLevels, SnooStates from .exceptions import InvalidSnooAuth, SnooAuthException, SnooBabyError, SnooCommandException, SnooDeviceError from .pubnub_async import SnooPubNub From 04f2612cac7ca3b5456147bf8679f49db8c06f8b Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Thu, 22 Jan 2026 14:43:03 +1100 Subject: [PATCH 06/10] Update snoo.py --- 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 bf93721..5de6c96 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -229,7 +229,7 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa async def set_sticky_white_noise( self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes - ): + ): """Enable or disable sticky white noise for a device. Args: From 2e100ec3c7a146634c8aa52b8c56894d4dca297e Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Fri, 23 Jan 2026 19:56:58 +1100 Subject: [PATCH 07/10] Update python_snoo/snoo.py Co-authored-by: Luke Lashley --- 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 5de6c96..301a6cc 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -228,7 +228,7 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) async def set_sticky_white_noise( - self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels = SnooNoiseTimeoutLevels._15_minutes + self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes ): """Enable or disable sticky white noise for a device. From fa2232f3dde7aa7cd4affec48108aeaf2ed449eb Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:02:12 +1100 Subject: [PATCH 08/10] Update snoo.py for linter --- python_snoo/snoo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index 301a6cc..9869885 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -228,7 +228,10 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) async def set_sticky_white_noise( - self, device: SnooDevice, on: bool, timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes + self, + device: SnooDevice, + on: bool, + timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes ): """Enable or disable sticky white noise for a device. From e8f7697a1d91abb8bb01031698d9cd6a0339a134 Mon Sep 17 00:00:00 2001 From: lexiconzero <61072652+lexiconzero@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:08:14 +1100 Subject: [PATCH 09/10] trailing comma for linter --- 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 9869885..67f46aa 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -231,7 +231,7 @@ async def set_sticky_white_noise( self, device: SnooDevice, on: bool, - timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes + timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes, ): """Enable or disable sticky white noise for a device. From 27d4a75815d048e8b47e50c21caee00353b4c541 Mon Sep 17 00:00:00 2001 From: Luke Lashley Date: Wed, 28 Jan 2026 20:41:08 -0500 Subject: [PATCH 10/10] chore: lint --- python_snoo/snoo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python_snoo/snoo.py b/python_snoo/snoo.py index 67f46aa..f2895d5 100644 --- a/python_snoo/snoo.py +++ b/python_snoo/snoo.py @@ -228,9 +228,9 @@ async def set_level(self, device: SnooDevice, level: SnooStates, hold: bool = Fa await self.send_command("go_to_state", device, **{"state": level.value, "hold": hold}) async def set_sticky_white_noise( - self, - device: SnooDevice, - on: bool, + self, + device: SnooDevice, + on: bool, timeout_value: SnooNoiseTimeoutLevels | int = SnooNoiseTimeoutLevels._15_minutes, ): """Enable or disable sticky white noise for a device.