Skip to content

Commit

Permalink
perf: remove unnecessary async calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed May 23, 2020
1 parent f543d66 commit 11bd6fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ async def _refresh_if_no_audiopush(already_refreshed=False):
)
await _refresh_if_no_audiopush(already_refreshed)

async def _clear_media_details(self):
def _clear_media_details(self):
"""Set all Media Items to None."""
# General
self._media_duration = None
Expand All @@ -439,7 +439,7 @@ async def _clear_media_details(self):
# volume is also used for announce/tts so state should remain
# self._media_vol_level = None

async def _set_authentication_details(self, auth):
def _set_authentication_details(self, auth):
"""Set Authentication based off auth."""
self._authenticated = auth["authenticated"]
self._can_access_prime_music = auth["canAccessPrimeMusicContent"]
Expand Down Expand Up @@ -479,7 +479,7 @@ async def refresh(self, device=None, skip_api: bool = False):
self._locale = device["locale"] if "locale" in device else "en-US"
self._timezone = device["timeZoneId"] if "timeZoneId" in device else "UTC"
self._dnd = device["dnd"] if "dnd" in device else None
await self._set_authentication_details(device["auth_info"])
self._set_authentication_details(device["auth_info"])
session = None
if self.available:
_LOGGER.debug("%s: Refreshing %s", self.account, self.name)
Expand All @@ -488,7 +488,7 @@ async def refresh(self, device=None, skip_api: bool = False):
self._source_list = self._get_source_list()
self._connected_bluetooth = self._get_connected_bluetooth()
self._bluetooth_list = self._get_bluetooth_list()
self._last_called = await self._get_last_called()
self._last_called = self._get_last_called()
if self._last_called:
self._last_called_timestamp = self.hass.data[DATA_ALEXAMEDIA][
"accounts"
Expand Down Expand Up @@ -542,7 +542,7 @@ async def refresh(self, device=None, skip_api: bool = False):
else:
self._playing_parent = None
session = await self.alexa_api.get_state()
await self._clear_media_details()
self._clear_media_details()
# update the session if it exists
self._session = session if session else None
if self._session and self._session.get("playerInfo"):
Expand Down Expand Up @@ -689,7 +689,7 @@ def _get_bluetooth_list(self):
sources.append(devices["friendlyName"])
return sources

async def _get_last_called(self):
def _get_last_called(self):
try:
last_called_serial = (
None
Expand Down Expand Up @@ -1054,7 +1054,7 @@ async def async_turn_off(self):
"""
self._should_poll = False
await self.async_media_pause()
await self._clear_media_details()
self._clear_media_details()

@_catch_login_errors
async def async_turn_on(self):
Expand Down

0 comments on commit 11bd6fa

Please sign in to comment.