Skip to content

Commit

Permalink
Merge branch 'clear_history' of github.com:macbury/alexa_media_player…
Browse files Browse the repository at this point in the history
… into notifications
  • Loading branch information
alandtse committed Sep 29, 2019
2 parents 64c5d8f + 804aaeb commit 805dace
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion custom_components/alexa_media/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
CONF_DEBUG = 'debug'
CONF_INCLUDE_DEVICES = 'include_devices'
CONF_EXCLUDE_DEVICES = 'exclude_devices'

SERVICE_CLEAR_HISTORY = 'clear_history'
SERVICE_UPDATE_LAST_CALLED = 'update_last_called'
ATTR_MESSAGE = 'message'
ATTR_EMAIL = 'email'

ATTR_NUM_ENTRIES = 'entries'
STARTUP = """
-------------------------------------------------------------------
{}
Expand Down
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 @@ -20,7 +20,6 @@
from homeassistant.const import (STATE_IDLE, STATE_PAUSED, STATE_PLAYING,
STATE_STANDBY)
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.service import extract_entity_ids

from . import CONF_EMAIL, DATA_ALEXAMEDIA
from . import DOMAIN as ALEXA_DOMAIN
Expand Down Expand Up @@ -154,7 +153,7 @@ async def async_added_to_hass(self):
# Register event handler on bus
self._listener = self.hass.bus.async_listen(
f'{ALEXA_DOMAIN}_{hide_email(self._login.email)}'[0:32],
self._handle_event)
self._handle_event)

async def async_will_remove_from_hass(self):
"""Prepare to remove entity."""
Expand Down Expand Up @@ -183,10 +182,11 @@ async def _handle_event(self, event):
except AttributeError:
pass
if 'last_called_change' in event.data:
event_serial = event.data['last_called_change']['serialNumber']
if (event_serial == self.device_serial_number or
any(item['serialNumber'] ==
event_serial for item in self._app_device_list)):
event_serial = (event.data['last_called_change']['serialNumber']
if event.data['last_called_change'] else None)
if (event_serial and (event_serial == self.device_serial_number or
any(item['serialNumber'] ==
event_serial for item in self._app_device_list))):
_LOGGER.debug("%s is last_called: %s", self.name,
hide_serial(self.device_serial_number))
self._last_called = True
Expand Down Expand Up @@ -538,7 +538,7 @@ async def async_update(self):
self.hass,
300,
lambda _:
self.async_schedule_update_ha_state(
self.async_schedule_update_ha_state(
force_refresh=True))
else:
_LOGGER.debug("Disabling polling for %s",
Expand Down

0 comments on commit 805dace

Please sign in to comment.