From 0c70888ff1eed1131f753d06b9a8a0a1b6ccbc26 Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Tue, 15 Oct 2024 16:17:40 -0700 Subject: [PATCH 1/6] add COLOR_WHEEL light mode --- smarttub/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smarttub/api.py b/smarttub/api.py index eb23435..490e8c7 100644 --- a/smarttub/api.py +++ b/smarttub/api.py @@ -450,7 +450,7 @@ def __str__(self): class SpaLight: LightMode = Enum( "LightMode", - "PURPLE ORANGE RED YELLOW GREEN AQUA BLUE WHITE AMBER HIGH_SPEED_COLOR_WHEEL HIGH_SPEED_WHEEL LOW_SPEED_WHEEL FULL_DYNAMIC_RGB AUTO_TIMER_EXTERIOR PARTY OFF ON", + "PURPLE ORANGE RED YELLOW GREEN AQUA BLUE WHITE AMBER HIGH_SPEED_COLOR_WHEEL HIGH_SPEED_WHEEL LOW_SPEED_WHEEL FULL_DYNAMIC_RGB AUTO_TIMER_EXTERIOR PARTY COLOR_WHEEL OFF ON", ) def __init__(self, spa: Spa, **properties): From f660fe2f014c610bc53c62ff9e921219f8844aba Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Fri, 18 Oct 2024 15:01:03 -0700 Subject: [PATCH 2/6] expose cycleSpeed for color changing lights --- smarttub/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smarttub/api.py b/smarttub/api.py index 490e8c7..13d0779 100644 --- a/smarttub/api.py +++ b/smarttub/api.py @@ -465,6 +465,7 @@ def __init__(self, spa: Spa, **properties): self.intensity = properties["intensity"] self.mode = self.LightMode[properties["mode"]] + self.cycleSpeed = properties["cycleSpeed"] self.properties = properties async def set_mode(self, mode: LightMode, intensity: int): @@ -480,7 +481,7 @@ async def turn_off(self): await self.set_mode(self.LightMode.OFF, 0) def __str__(self): - return f"" + return f"" class SpaReminder: From c670958af809aa5f1a06bf83c3d808b8a2fe98ec Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Fri, 18 Oct 2024 15:27:25 -0700 Subject: [PATCH 3/6] update mock light to include cycleSpeed --- tests/test_light.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_light.py b/tests/test_light.py index 55ef780..afee2dd 100644 --- a/tests/test_light.py +++ b/tests/test_light.py @@ -14,6 +14,7 @@ def lights(mock_spa): "color": {"blue": 0, "green": 0, "red": 0, "white": 0}, "intensity": 0 if mode == SpaLight.LightMode.OFF else 50, "mode": mode.name, + "cycleSpeed": 0, "zone": i + 1, }, ) From c5c763f32edd17bdc4a30f83ad7cda8400f836e2 Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Fri, 18 Oct 2024 15:30:09 -0700 Subject: [PATCH 4/6] add irt and exterior to mock light --- tests/test_light.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_light.py b/tests/test_light.py index afee2dd..2a2edf2 100644 --- a/tests/test_light.py +++ b/tests/test_light.py @@ -15,6 +15,8 @@ def lights(mock_spa): "intensity": 0 if mode == SpaLight.LightMode.OFF else 50, "mode": mode.name, "cycleSpeed": 0, + "exterior": False, + "irt": None, "zone": i + 1, }, ) @@ -22,7 +24,6 @@ def lights(mock_spa): ] return lights - async def test_light(mock_spa, lights): purple = lights[0] assert str(purple) From 5810d7a87db288474281ca0c960402972c1b3d5f Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Fri, 18 Oct 2024 15:32:20 -0700 Subject: [PATCH 5/6] ahem, fix spacing --- tests/test_light.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_light.py b/tests/test_light.py index 2a2edf2..082dafb 100644 --- a/tests/test_light.py +++ b/tests/test_light.py @@ -24,6 +24,7 @@ def lights(mock_spa): ] return lights + async def test_light(mock_spa, lights): purple = lights[0] assert str(purple) From 5c9c0ed6f2133bceb0ca3ebd73d3e815e288c32b Mon Sep 17 00:00:00 2001 From: steve mats mats Date: Sat, 26 Oct 2024 08:01:20 -0700 Subject: [PATCH 6/6] added try for cycleSpeed, updated mock response --- smarttub/api.py | 5 ++++- tests/test_spa.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/smarttub/api.py b/smarttub/api.py index 13d0779..bfe426c 100644 --- a/smarttub/api.py +++ b/smarttub/api.py @@ -465,7 +465,10 @@ def __init__(self, spa: Spa, **properties): self.intensity = properties["intensity"] self.mode = self.LightMode[properties["mode"]] - self.cycleSpeed = properties["cycleSpeed"] + try: + self.cycleSpeed = properties["cycleSpeed"] + except KeyError as e: + logger.debug(f'Benign: {e}') self.properties = properties async def set_mode(self, mode: LightMode, intensity: int): diff --git a/tests/test_spa.py b/tests/test_spa.py index d241ac6..0d01bd7 100644 --- a/tests/test_spa.py +++ b/tests/test_spa.py @@ -381,6 +381,7 @@ async def test_get_lights(mock_api, spa): { "color": {"blue": 0, "green": 0, "red": 0, "white": 0}, "intensity": 0, + "cycleSpeed": 0, "mode": "OFF", "zone": 1, }