Skip to content

Commit

Permalink
Add refresh states command (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Aug 29, 2020
1 parent 49983e4 commit 7788f4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ async def main() -> None:
print(f"{device.label} ({device.id}) - {device.controllable_name}")
print(f"{device.widget} - {device.ui_class}")

# Create an event listener and poll it
listener_id = await client.register_event_listener()

while True:
events = await client.fetch_events()
print(events)
Expand Down
9 changes: 9 additions & 0 deletions pyhoma/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ async def get_state(self, deviceurl: str) -> List[State]:

return state

@backoff.on_exception(
backoff.expo, NotAuthenticatedException, max_tries=2, on_backoff=relogin
)
async def refresh_states(self) -> None:
"""
Ask the box to refresh all devices states for protocols supporting that operation
"""
await self.__post("/setup/devices/states/refresh")

async def register_event_listener(self) -> str:
"""
Register a new setup event listener on the current session and return a new
Expand Down

0 comments on commit 7788f4f

Please sign in to comment.