Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if last_called:
last_called = last_called
else:
last_called = AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug("%s: Updated last_called: %s",
hide_email(email),
hide_serial(last_called))
stored_data = hass.data[DATA_ALEXAMEDIA]['accounts'][email]
if (('last_called' in stored_data and
last_called != stored_data['last_called']) or
('last_called' not in stored_data and
last_called is not None)):
_LOGGER.debug("%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(stored_data['last_called'] if
'last_called' in stored_data else None),
hide_serial(last_called))
hass.bus.fire(('{}_{}'.format(DOMAIN, hide_email(email)))[0:32],
{'last_called_change': last_called})
(hass.data[DATA_ALEXAMEDIA]
def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if last_called:
last_called = last_called
else:
last_called = AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug("%s: Updated last_called: %s",
hide_email(email),
hide_serial(last_called))
stored_data = hass.data[DATA_ALEXAMEDIA]['accounts'][email]
if (('last_called' in stored_data and
last_called != stored_data['last_called']) or
('last_called' not in stored_data and
last_called is not None)):
_LOGGER.debug("%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(stored_data['last_called'] if
'last_called' in stored_data else None),
hide_serial(last_called))
hass.bus.fire(('{}_{}'.format(DOMAIN, hide_email(email)))[0:32],
{'last_called_change': last_called})
(hass.data[DATA_ALEXAMEDIA]
async def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if not last_called:
last_called = await AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug(
"%s: Updated last_called: %s", hide_email(email), hide_serial(last_called)
)
stored_data = hass.data[DATA_ALEXAMEDIA]["accounts"][email]
if (
"last_called" in stored_data and last_called != stored_data["last_called"]
) or ("last_called" not in stored_data and last_called is not None):
_LOGGER.debug(
"%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(
stored_data["last_called"] if "last_called" in stored_data else None
),
hide_serial(last_called),
)
async_dispatcher_send(
async def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if not last_called:
last_called = await AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug(
"%s: Updated last_called: %s", hide_email(email), hide_serial(last_called)
)
stored_data = hass.data[DATA_ALEXAMEDIA]["accounts"][email]
if (
"last_called" in stored_data and last_called != stored_data["last_called"]
) or ("last_called" not in stored_data and last_called is not None):
_LOGGER.debug(
"%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(
stored_data["last_called"] if "last_called" in stored_data else None
),
hide_serial(last_called),
)
async_dispatcher_send(
async def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if last_called:
last_called = last_called
else:
last_called = await AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug("%s: Updated last_called: %s",
hide_email(email),
hide_serial(last_called))
stored_data = hass.data[DATA_ALEXAMEDIA]['accounts'][email]
if (('last_called' in stored_data and
last_called != stored_data['last_called']) or
('last_called' not in stored_data and
last_called is not None)):
_LOGGER.debug("%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(stored_data['last_called'] if
'last_called' in stored_data else None),
hide_serial(last_called))
hass.bus.async_fire(
('{}_{}'.format(DOMAIN,
hide_email(email)))[0:32],
async def update_last_called(login_obj, last_called=None):
"""Update the last called device for the login_obj.
This will store the last_called in hass.data and also fire an event
to notify listeners.
"""
from alexapy import AlexaAPI
if not last_called:
last_called = await AlexaAPI.get_last_device_serial(login_obj)
_LOGGER.debug("%s: Updated last_called: %s",
hide_email(email),
hide_serial(last_called))
stored_data = hass.data[DATA_ALEXAMEDIA]['accounts'][email]
if (('last_called' in stored_data and
last_called != stored_data['last_called']) or
('last_called' not in stored_data and
last_called is not None)):
_LOGGER.debug("%s: last_called changed: %s to %s",
hide_email(email),
hide_serial(stored_data['last_called'] if
'last_called' in stored_data else None),
hide_serial(last_called))
hass.bus.async_fire(
f'{DOMAIN}_{hide_email(email)}'[0:32],
{'last_called_change': last_called})