Skip to content

Commit

Permalink
fix: add checks to avoid updates if session closed
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed May 23, 2020
1 parent 0321908 commit ff3c9ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions custom_components/alexa_media/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ async def async_update(self):
pass
import json

if self._login.session.closed:
return
_LOGGER.debug("%s: Refreshing %s", self.account, self.name)
state = None
state_json = await self.alexa_api.get_guard_state(
Expand Down
9 changes: 5 additions & 4 deletions custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,11 +779,12 @@ async def async_update(self):
return
except AttributeError:
pass
if self.entity_id is None:
# Device has not initialized yet
return
email = self._login.email
if email not in self.hass.data[DATA_ALEXAMEDIA]["accounts"]:
if (
self.entity_id is None # Device has not initialized yet
or email not in self.hass.data[DATA_ALEXAMEDIA]["accounts"]
or self._login.session.closed
):
return
device = self.hass.data[DATA_ALEXAMEDIA]["accounts"][email]["devices"][
"media_player"
Expand Down

0 comments on commit ff3c9ed

Please sign in to comment.