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

feat: abstract the need to check pubnub since it yale will use websocets #118

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion yalexs/manager/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ def get_latest_device_activity(

return latest_activity

@property
def push_updates_connected(self) -> bool:
"""Return if the push updates are connected."""
return self.pubnub.connected

async def _async_refresh(self) -> None:
"""Update the activity stream from August."""
# This is the only place we refresh the api token
await self._august_gateway.async_refresh_access_token_if_needed()
if self.pubnub.connected:
if self.push_updates_connected:
_LOGGER.debug("Skipping update because pubnub is connected")
return
_LOGGER.debug("Start retrieving device activities")
Expand Down
12 changes: 10 additions & 2 deletions yalexs/manager/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,22 @@ async def refresh_camera_by_id(self, device_id: str) -> None:
self._api.async_get_doorbell_detail,
)

@property
def push_updates_connected(self) -> bool:
"""Return if the push updates are connected."""
return (
self.activity_stream is not None
and self.activity_stream.push_updates_connected
)

async def _async_refresh_device_detail_by_id(self, device_id: str) -> None:
if device_id in self._locks_by_id:
if self.activity_stream and self.activity_stream.pubnub.connected:
if self.activity_stream and self.push_updates_connected:
saved_attrs = _save_live_attrs(self._device_detail_by_id[device_id])
await self._async_update_device_detail(
self._locks_by_id[device_id], self._api.async_get_lock_detail
)
if self.activity_stream and self.activity_stream.pubnub.connected:
if self.activity_stream and self.push_updates_connected:
_restore_live_attrs(self._device_detail_by_id[device_id], saved_attrs)
# keypads are always attached to locks
if (
Expand Down
Loading