Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose cycleSpeed for color changing lights #53

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 5 additions & 1 deletion smarttub/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,10 @@ def __init__(self, spa: Spa, **properties):

self.intensity = properties["intensity"]
self.mode = self.LightMode[properties["mode"]]
try:
self.cycleSpeed = properties["cycleSpeed"]
except KeyError as e:
logger.debug(f'Benign: {e}')
Comment on lines +468 to +471
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try:
self.cycleSpeed = properties["cycleSpeed"]
except KeyError as e:
logger.debug(f'Benign: {e}')
self.cycleSpeed = properties.get("cycleSpeed", None)

This way, the code below which accesses self.cycleSpeed won't throw an exception when it wasn't set

self.properties = properties

async def set_mode(self, mode: LightMode, intensity: int):
Expand All @@ -480,7 +484,7 @@ async def turn_off(self):
await self.set_mode(self.LightMode.OFF, 0)

def __str__(self):
return f"<SpaLight {self.zone}: {self.mode.name} (R {self.red}/G {self.green}/B {self.blue}/W {self.white}) @ {self.intensity}>"
return f"<SpaLight {self.zone}: {self.mode.name} {self.cycleSpeed} (R {self.red}/G {self.green}/B {self.blue}/W {self.white}) @ {self.intensity}>"


class SpaReminder:
Expand Down
3 changes: 3 additions & 0 deletions tests/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ 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,
"exterior": False,
"irt": None,
"zone": i + 1,
},
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
Loading