Skip to content

Commit 7788f4f

Browse files
authored
Add refresh states command (#44)
1 parent 49983e4 commit 7788f4f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ async def main() -> None:
4242
print(f"{device.label} ({device.id}) - {device.controllable_name}")
4343
print(f"{device.widget} - {device.ui_class}")
4444

45-
# Create an event listener and poll it
46-
listener_id = await client.register_event_listener()
47-
4845
while True:
4946
events = await client.fetch_events()
5047
print(events)

pyhoma/client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,15 @@ async def get_state(self, deviceurl: str) -> List[State]:
114114

115115
return state
116116

117+
@backoff.on_exception(
118+
backoff.expo, NotAuthenticatedException, max_tries=2, on_backoff=relogin
119+
)
120+
async def refresh_states(self) -> None:
121+
"""
122+
Ask the box to refresh all devices states for protocols supporting that operation
123+
"""
124+
await self.__post("/setup/devices/states/refresh")
125+
117126
async def register_event_listener(self) -> str:
118127
"""
119128
Register a new setup event listener on the current session and return a new

0 commit comments

Comments
 (0)