diff --git a/homeassistant/components/notify/html5.py b/homeassistant/components/notify/html5.py
index 70ab9580a04..04e49ecabca 100644
--- a/homeassistant/components/notify/html5.py
+++ b/homeassistant/components/notify/html5.py
@@ -7,6 +7,7 @@ https://home-assistant.io/components/notify.html5/
import os
import logging
import json
+import time
import voluptuous as vol
from voluptuous.humanize import humanize_error
@@ -15,7 +16,7 @@ from homeassistant.const import (
HTTP_BAD_REQUEST, HTTP_INTERNAL_SERVER_ERROR)
from homeassistant.util import ensure_unique_string
from homeassistant.components.notify import (
- ATTR_TARGET, ATTR_DATA, BaseNotificationService,
+ ATTR_TARGET, ATTR_TITLE, ATTR_DATA, BaseNotificationService,
PLATFORM_SCHEMA)
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.frontend import add_manifest_json_key
@@ -145,9 +146,14 @@ class HTML5NotificationService(BaseNotificationService):
"""Send a message to a user."""
from pywebpush import WebPusher
+ timestamp = int(time.time())
+
payload = {
- 'title': message,
+ 'body': message,
+ 'data': {},
'icon': '/static/icons/favicon-192x192.png',
+ 'timestamp': (timestamp*1000), # Javascript ms since epoch
+ 'title': kwargs.get(ATTR_TITLE)
}
data = kwargs.get(ATTR_DATA)
@@ -155,6 +161,12 @@ class HTML5NotificationService(BaseNotificationService):
if data:
payload.update(data)
+ if data.get('url') is not None:
+ payload['data']['url'] = data.get('url')
+ elif (payload['data'].get('url') is None and
+ payload.get('actions') is None):
+ payload['data']['url'] = '/'
+
targets = kwargs.get(ATTR_TARGET)
if not targets:
@@ -170,4 +182,4 @@ class HTML5NotificationService(BaseNotificationService):
continue
WebPusher(info[ATTR_SUBSCRIPTION]).send(
- json.dumps(payload), gcm_key=self._gcm_key, ttl='0')
+ json.dumps(payload), gcm_key=self._gcm_key, ttl='86400')
diff --git a/tests/components/notify/test_html5.py b/tests/components/notify/test_html5.py
index b562775d32e..121cc1096d2 100644
--- a/tests/components/notify/test_html5.py
+++ b/tests/components/notify/test_html5.py
@@ -65,7 +65,7 @@ class TestHtml5Notify(object):
# Call to send
payload = json.loads(mock_wp.mock_calls[1][1][0])
- assert payload['title'] == 'Hello'
+ assert payload['body'] == 'Hello'
assert payload['icon'] == 'beer.png'
def test_registering_new_device_view(self):