# Buggy code
async def process_notifications(login_obj, raw_notifications=None):
    """Process raw notifications json."""
    from alexapy import AlexaAPI

    if not raw_notifications:
        raw_notifications = await AlexaAPI.get_notifications(login_obj)
    email: Text = login_obj.email
    notifications = {"process_timestamp": datetime.utcnow()}
    for notification in raw_notifications:
        n_dev_id = notification.get("deviceSerialNumber")
        if n_dev_id is None:
            # skip notifications untied to a device for now
            # https://github.com/custom-components/alexa_media_player/issues/633#issuecomment-610705651
            continue
        n_type = notification["type"]
        if n_type == "MusicAlarm":
            n_type = "Alarm"
        n_id = notification["notificationIndex"]
        if n_type != "Timer":
            n_date = notification["originalDate"]
            n_time = notification["originalTime"]
            notification["date_time"] = f"{n_date} {n_time}"
        if n_dev_id not in notifications:
            notifications[n_dev_id] = {}
        if n_type not in notifications[n_dev_id]:
            notifications[n_dev_id][n_type] = {}
        notifications[n_dev_id][n_type][n_id] = notification
    hass.data[DATA_ALEXAMEDIA]["accounts"][email]["notifications"] = notifications
    _LOGGER.debug(
        "%s: Updated %s notifications for %s devices at %s",
        hide_email(email),
        len(raw_notifications),
        len(notifications),
        dt.as_local(
            hass.data[DATA_ALEXAMEDIA]["accounts"][email]["notifications"][
                "process_timestamp"
            ]
        ),
    )


# Traceback (KeyError)
2020-04-10 15:25:43 ERROR (MainThread) [homeassistant.components.alexa.state_report] Timeout sending report to Alexa.
2020-04-10 15:24:15 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py", line 152, in process_messages
await self.on_message(cast(bytes, msg.data))
File "/usr/local/lib/python3.7/site-packages/alexapy/alexawebsocket.py", line 234, in on_message
await self.msg_callback(message_obj)
File "/config/custom_components/alexa_media/__init__.py", line 926, in ws_handler
login_obj, no_throttle=True
File "/config/custom_components/alexa_media/__init__.py", line 469, in update_devices
await process_notifications(login_obj, raw_notifications)
File "/config/custom_components/alexa_media/__init__.py", line 613, in process_notifications
n_time = notification["originalTime"]
KeyError: 'originalTime'
2020-04-10 15:24:36 ERROR (MainThread) [homeassistant.core] Error doing job: Unclosed client session

# Fixed code
async def process_notifications(login_obj, raw_notifications=None):
    """Process raw notifications json."""
    from alexapy import AlexaAPI

    if not raw_notifications:
        raw_notifications = await AlexaAPI.get_notifications(login_obj)
    email: Text = login_obj.email
    notifications = {"process_timestamp": datetime.utcnow()}
    for notification in raw_notifications:
        n_dev_id = notification.get("deviceSerialNumber")
        if n_dev_id is None:
            # skip notifications untied to a device for now
            # https://github.com/custom-components/alexa_media_player/issues/633#issuecomment-610705651
            continue
        n_type = notification.get("type")
        if n_type is None:
            continue
        if n_type == "MusicAlarm":
            n_type = "Alarm"
        n_id = notification["notificationIndex"]
        if n_type == "Alarm":
            n_date = notification.get("originalDate")
            n_time = notification.get("originalTime")
            notification["date_time"] = (
                f"{n_date} {n_time}" if n_date and n_time else None
            )
        if n_dev_id not in notifications:
            notifications[n_dev_id] = {}
        if n_type not in notifications[n_dev_id]:
            notifications[n_dev_id][n_type] = {}
        notifications[n_dev_id][n_type][n_id] = notification
    hass.data[DATA_ALEXAMEDIA]["accounts"][email]["notifications"] = notifications
    _LOGGER.debug(
        "%s: Updated %s notifications for %s devices at %s",
        hide_email(email),
        len(raw_notifications),
        len(notifications),
        dt.as_local(
            hass.data[DATA_ALEXAMEDIA]["accounts"][email]["notifications"][
                "process_timestamp"
            ]
        ),
    )