How to use the alexapy.hide_serial function in AlexaPy

To help you get started, we’ve selected a few AlexaPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ikifar2012 / Home-AssistantConfig / custom_components / alexa_media / __init__.py View on Github external
message_obj.json_payload["payload"]
            if isinstance(message_obj.json_payload, dict)
            and "payload" in message_obj.json_payload
            else None
        )
        existing_serials = _existing_serials(hass, login_obj)
        seen_commands = hass.data[DATA_ALEXAMEDIA]["accounts"][email][
            "websocket_commands"
        ]
        if command and json_payload:

            _LOGGER.debug(
                "%s: Received websocket command: %s : %s",
                hide_email(email),
                command,
                hide_serial(json_payload),
            )
            serial = None
            if command not in seen_commands:
                seen_commands[command] = time.time()
                _LOGGER.debug("Adding %s to seen_commands: %s", command, seen_commands)
            if (
                "dopplerId" in json_payload
                and "deviceSerialNumber" in json_payload["dopplerId"]
            ):
                serial = json_payload["dopplerId"]["deviceSerialNumber"]
            elif (
                "key" in json_payload
                and "entryId" in json_payload["key"]
                and json_payload["key"]["entryId"].find("#") != -1
            ):
                serial = (json_payload["key"]["entryId"]).split("#")[2]
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
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})
        (hass.data[DATA_ALEXAMEDIA]
         ['accounts']
         [email]
         ['last_called']) = last_called
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
continue

            if 'bluetoothStates' in bluetooth:
                for b_state in bluetooth['bluetoothStates']:
                    if device['serialNumber'] == b_state['deviceSerialNumber']:
                        device['bluetooth_state'] = b_state

            if 'devicePreferences' in preferences:
                for dev in preferences['devicePreferences']:
                    if dev['deviceSerialNumber'] == device['serialNumber']:
                        device['locale'] = dev['locale']
                        device['timeZoneId'] = dev['timeZoneId']
                        _LOGGER.debug("Locale %s timezone %s found for %s",
                                      device['locale'],
                                      device['timeZoneId'],
                                      hide_serial(device['serialNumber']))

            if 'doNotDisturbDeviceStatusList' in dnd:
                for dev in dnd['doNotDisturbDeviceStatusList']:
                    if dev['deviceSerialNumber'] == device['serialNumber']:
                        device['dnd'] = dev['enabled']
                        _LOGGER.debug("DND %s found for %s",
                                      device['dnd'],
                                      hide_serial(device['serialNumber']))
            device['auth_info'] = auth_info
            (hass.data[DATA_ALEXAMEDIA]
             ['accounts']
             [email]
             ['devices']
             ['media_player']
             [device['serialNumber']]) = device
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
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})
        (hass.data[DATA_ALEXAMEDIA]
         ['accounts']
         [email]
         ['last_called']) = last_called
github eifinger / homeassistant-config / custom_components / alexa_media / __init__.py View on Github external
if serial and serial in existing_serials:
                    _LOGGER.debug(
                        "Updating media_player queue %s", hide_serial(json_payload)
                    )
                    async_dispatcher_send(
                        hass,
                        f"{DOMAIN}_{hide_email(email)}"[0:32],
                        {"queue_state": json_payload},
                    )
            elif command == "PUSH_NOTIFICATION_CHANGE":
                # Player update
                await process_notifications(login_obj)
                if serial and serial in existing_serials:
                    _LOGGER.debug(
                        "Updating mediaplayer notifications: %s",
                        hide_serial(json_payload),
                    )
                    async_dispatcher_send(
                        hass,
                        f"{DOMAIN}_{hide_email(email)}"[0:32],
                        {"notification_update": json_payload},
                    )
            elif command in [
                "PUSH_DELETE_DOPPLER_ACTIVITIES",  # delete Alexa history
                "PUSH_LIST_ITEM_CHANGE",  # update shopping list
                "PUSH_CONTENT_FOCUS_CHANGE",  # likely prime related refocus
            ]:
                pass
            else:
                _LOGGER.warning(
                    "Unhandled command: %s with data %s. Please report at %s",
                    command,
github eliseomartelli / ParentsHomeAutomation / homeassistant / custom_components / alexa_media / __init__.py View on Github external
"media_player"
        ][device_serial]

        if "bluetoothStates" in bluetooth:
            for b_state in bluetooth["bluetoothStates"]:
                if device_serial == b_state["deviceSerialNumber"]:
                    # _LOGGER.debug("%s: setting value for: %s to %s",
                    #               hide_email(email),
                    #               hide_serial(device_serial),
                    #               hide_serial(b_state))
                    device["bluetooth_state"] = b_state
                    return device["bluetooth_state"]
        _LOGGER.debug(
            "%s: get_bluetooth for: %s failed with %s",
            hide_email(email),
            hide_serial(device_serial),
            hide_serial(bluetooth),
        )
        return None
github ikifar2012 / Home-AssistantConfig / custom_components / alexa_media / __init__.py View on Github external
"Updating media_player volume: %s", hide_serial(json_payload)
                    )
                    async_dispatcher_send(
                        hass,
                        f"{DOMAIN}_{hide_email(email)}"[0:32],
                        {"player_state": json_payload},
                    )
            elif command in (
                "PUSH_DOPPLER_CONNECTION_CHANGE",
                "PUSH_EQUALIZER_STATE_CHANGE",
            ):
                # Player availability update
                if serial and serial in existing_serials:
                    _LOGGER.debug(
                        "Updating media_player availability %s",
                        hide_serial(json_payload),
                    )
                    async_dispatcher_send(
                        hass,
                        f"{DOMAIN}_{hide_email(email)}"[0:32],
                        {"player_state": json_payload},
                    )
            elif command == "PUSH_BLUETOOTH_STATE_CHANGE":
                # Player bluetooth update
                bt_event = json_payload["bluetoothEvent"]
                bt_success = json_payload["bluetoothEventSuccess"]
                if (
                    serial
                    and serial in existing_serials
                    and bt_success
                    and bt_event
                    and bt_event in ["DEVICE_CONNECTED", "DEVICE_DISCONNECTED"]
github eliseomartelli / ParentsHomeAutomation / homeassistant / custom_components / alexa_media / __init__.py View on Github external
][device_serial]

        if "bluetoothStates" in bluetooth:
            for b_state in bluetooth["bluetoothStates"]:
                if device_serial == b_state["deviceSerialNumber"]:
                    # _LOGGER.debug("%s: setting value for: %s to %s",
                    #               hide_email(email),
                    #               hide_serial(device_serial),
                    #               hide_serial(b_state))
                    device["bluetooth_state"] = b_state
                    return device["bluetooth_state"]
        _LOGGER.debug(
            "%s: get_bluetooth for: %s failed with %s",
            hide_email(email),
            hide_serial(device_serial),
            hide_serial(bluetooth),
        )
        return None
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
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})
        (hass.data[DATA_ALEXAMEDIA]
         ['accounts']
         [email]
github custom-components / alexa_media_player / custom_components / alexa_media / __init__.py View on Github external
hass.bus.async_fire(
                    f'{DOMAIN}_{hide_email(email)}'[0:32],
                    {'push_activity': json_payload})
            elif command in ('PUSH_AUDIO_PLAYER_STATE', 'PUSH_MEDIA_CHANGE'):
                # Player update/ Push_media from tune_in
                if (serial and serial in existing_serials):
                    _LOGGER.debug("Updating media_player: %s",
                                  hide_serial(json_payload))
                    hass.bus.async_fire(
                        f'{DOMAIN}_{hide_email(email)}'[0:32],
                        {'player_state': json_payload})
            elif command == 'PUSH_VOLUME_CHANGE':
                # Player volume update
                if (serial and serial in existing_serials):
                    _LOGGER.debug("Updating media_player volume: %s",
                                  hide_serial(json_payload))
                    hass.bus.async_fire(
                        f'{DOMAIN}_{hide_email(email)}'[0:32],
                        {'player_state': json_payload})
            elif command == 'PUSH_DOPPLER_CONNECTION_CHANGE':
                # Player availability update
                if (serial and serial in existing_serials):
                    _LOGGER.debug("Updating media_player availability %s",
                                  hide_serial(json_payload))
                    hass.bus.async_fire(
                        f'{DOMAIN}_{hide_email(email)}'[0:32],
                        {'player_state': json_payload})
            elif command == 'PUSH_BLUETOOTH_STATE_CHANGE':
                # Player bluetooth update
                bt_event = json_payload['bluetoothEvent']
                bt_success = json_payload['bluetoothEventSuccess']
                if (serial and serial in existing_serials and