Skip to content

Commit

Permalink
one more bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Sep 22, 2020
1 parent 7085295 commit 8394a6f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions custom_components/zoom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ def __init__(self, hass: HomeAssistantType, config_entry: ConfigEntry) -> None:

async def async_update(self) -> None:
"""Update state of entity."""
try:
self._profile = await self._api.async_get_contact_user_profile(self.id)
self._set_state(self._profile["presence_status"])
except HTTPUnauthorized:
_LOGGER.warning(
"Unable to poll presence status for user %s. Relying solely on webhooks.",
self.profile["email"],
)
self._should_poll = False
if self.id:
try:
self._profile = await self._api.async_get_contact_user_profile(self.id)
self._set_state(self._profile["presence_status"])
except HTTPUnauthorized:
_LOGGER.warning(
"Unable to poll presence status for user %s. Relying solely on webhooks.",
self.profile["email"],
)
self._should_poll = False

async def async_added_to_hass(self) -> None:
"""Register callbacks when entity is added."""
Expand Down

0 comments on commit 8394a6f

Please sign in to comment.