Add time created to persistent notifications. (#17121)
* Add time created to persistent notifications. * UTC
This commit is contained in:
parent
05d8c57212
commit
cc1891ef2b
2 changed files with 8 additions and 2 deletions
|
@ -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()
|
||||
])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue