Return the device id from the input request.

    The method retrieves the `deviceId` property from the input request.
    This value uniquely identifies the device and is generally used as
    input for some Alexa-specific API calls. More information about this
    can be found here :
    https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#system-object

    If there is no device information in the input request, then a ``None``
    is returned.

    :param handler_input: The handler input instance that is generally
        passed in the sdk's request and exception components
    :type handler_input: ask_sdk_core.handler_input.HandlerInput
    :return: Unique device id of the device used to send the alexa request
        or `None` if device information is not present
    :rtype: Optional[str]

def get_device_id(handler_input):
    # type: (HandlerInput) -> Optional[AnyStr]
    """Return the device id from the input request.

    The method retrieves the `deviceId` property from the input request.
    This value uniquely identifies the device and is generally used as
    input for some Alexa-specific API calls. More information about this
    can be found here :
    https://developer.amazon.com/docs/custom-skills/request-and-response-json-reference.html#system-object

    If there is no device information in the input request, then a ``None``
    is returned.

    :param handler_input: The handler input instance that is generally
        passed in the sdk's request and exception components
    :type handler_input: ask_sdk_core.handler_input.HandlerInput
    :return: Unique device id of the device used to send the alexa request
        or `None` if device information is not present
    :rtype: Optional[str]
    """
    device = handler_input.request_envelope.context.system.device
    if device:
        return device.device_id
    else:
        return None