Add time created to persistent notifications. (#17121)

* Add time created to persistent notifications.

* UTC
This commit is contained in:
Jerad Meisner authored and Paulus Schoutsen committed 2018-10-04 10:24:14 +02:00
1 parent 05d8c57212
commit cc1891ef2b
2 files changed
+8 -2

No files matched your search

@@ -17,7 +17,9 @@ from homeassistant.loader import bind_hass
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import async_generate_entity_id
from homeassistant.util import slugify
import homeassistant.util.dt as dt_util
ATTR_CREATED_AT = 'created_at'
ATTR_MESSAGE = 'message'
ATTR_NOTIFICATION_ID = 'notification_id'
ATTR_TITLE = 'title'
@@ -147,6 +149,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> Awaitable[bool]:
ATTR_NOTIFICATION_ID: notification_id,
ATTR_STATUS: STATUS_UNREAD,
ATTR_TITLE: title,
ATTR_CREATED_AT: dt_util.utcnow(),
}
hass.bus.async_fire(EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
@@ -203,8 +206,9 @@ def websocket_get_notifications(
connection.send_message(
websocket_api.result_message(msg['id'], [
{
key: data[key] for key in (ATTR_NOTIFICATION_ID, ATTR_MESSAGE,
ATTR_STATUS, ATTR_TITLE)
key: data[key] for key in (ATTR_NOTIFICATION_ID,
ATTR_MESSAGE, ATTR_STATUS,
ATTR_TITLE, ATTR_CREATED_AT)
}
for data in hass.data[DOMAIN]['notifications'].values()
])