From 8394a6f021d3d3cf315808688b6d8ccbe5479f58 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Mon, 21 Sep 2020 22:39:20 -0400 Subject: [PATCH] one more bug fix --- custom_components/zoom/binary_sensor.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/custom_components/zoom/binary_sensor.py b/custom_components/zoom/binary_sensor.py index b429a10..d4bce53 100644 --- a/custom_components/zoom/binary_sensor.py +++ b/custom_components/zoom/binary_sensor.py @@ -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."""