Skip to content

Commit

Permalink
fix: enable refresh polling if no PUSH_AUDIO_PLAYER_STATE
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Oct 13, 2019
1 parent 2b4a9bb commit e3795b6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion custom_components/alexa_media/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,21 @@ async def async_update(self):
['devices']
['media_player']
[self.unique_id])
seen_commands = ((self.hass.data[DATA_ALEXAMEDIA]['accounts']
[email]['websocket_commands'].keys()
if 'websocket_commands' in (
self.hass.data[DATA_ALEXAMEDIA]
['accounts']
[email]) else None))
await self.refresh(device, # pylint: disable=unexpected-keyword-arg
no_throttle=True)
if (self.state in [STATE_PLAYING] and
# only enable polling if websocket not connected
(not self.hass.data[DATA_ALEXAMEDIA]
['accounts'][email]['websocket'])):
['accounts'][email]['websocket'] or
# or if no PUSH_AUDIO_PLAYER_STATE
not seen_commands or
'PUSH_AUDIO_PLAYER_STATE' not in seen_commands)):
self._should_poll = False # disable polling since manual update
if(self._last_update == 0 or util.dt.as_timestamp(util.utcnow()) -
util.dt.as_timestamp(self._last_update)
Expand Down

0 comments on commit e3795b6

Please sign in to comment.