Skip to content

Commit

Permalink
fix bug with id property
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Sep 22, 2020
1 parent 24ea411 commit d7c8b73
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions custom_components/zoom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ async def async_update(self) -> None:
try:
self._profile = await self._api.async_get_contact_user_profile(self.id)
self._set_state(self._profile["presence_status"])
except Exception:
self._should_poll = True
except:
_LOGGER.warning(
"Unable to poll presence status for user %s. Relying solely on webhooks.",
self.profile["email"],
exc_info=True
)
self._should_poll = False

Expand All @@ -95,10 +97,6 @@ async def async_added_to_hass(self) -> None:
self._coordinator.async_add_listener(self.async_write_ha_state)
)

if not self.id:
_LOGGER.debug("ID not found, restoring state.")
await self._restore_state()

if self.id:
try:
contact = await self._api.async_get_contact_user_profile(self.id)
Expand Down Expand Up @@ -179,7 +177,7 @@ def last_name(self) -> Optional[str]:
@property
def id(self) -> Optional[str]:
"""Return the id."""
self._config_entry.data.get(CONF_ID) or self.profile.get("id")
return self._config_entry.data.get(CONF_ID) or self.profile.get("id")

@property
def email(self) -> Optional[str]:
Expand Down

0 comments on commit d7c8b73

Please sign in to comment.