Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions smarttub/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,10 @@ async def _wait_for_state_change(
RuntimeError if the state change is not reflected within the timeout period
"""
start_time = datetime.datetime.now().timestamp()
# Use the provided method if available, otherwise use default get_status
status_method = get_status_method if get_status_method else self.get_status
while True:
state = await self.get_status()
state = await status_method()
if check_func(state):
return state

Expand All @@ -206,9 +208,6 @@ async def _wait_for_state_change(

await asyncio.sleep(0.5)

if get_status_method:
state = await get_status_method()

async def get_status(self) -> "SpaState":
"""Query the status of the spa."""
return SpaState(self, **await self.request("GET", "status"))
Expand Down Expand Up @@ -407,10 +406,12 @@ class SpaStateFull(SpaState):
def __init__(self, spa: Spa, state: dict):
super().__init__(spa, **state)
self.lights = [
SpaLight(spa, **light_props) for light_props in self.properties["lights"]
SpaLight(spa, **light_props)
for light_props in (self.properties.get("lights") or [])
]
self.pumps = [
SpaPump(spa, **pump_props) for pump_props in self.properties["pumps"]
SpaPump(spa, **pump_props)
for pump_props in (self.properties.get("pumps") or [])
]
self.sensors = [
SpaSensor(spa, **sensor_props)
Expand Down