Add notify demo data test

This commit is contained in:
Paulus Schoutsen committed 2016-08-09 20:26:17 -07:00
1 parent 492ade7b1a
commit 6bb6a6ebe9
3 files changed
+24 -7

No files matched your search

+7 -4
View File
@@ -44,16 +44,19 @@ NOTIFY_SERVICE_SCHEMA = vol.Schema({
_LOGGER = logging.getLogger(__name__)
def send_message(hass, message, title=None):
def send_message(hass, message, title=None, data=None):
"""Send a notification message."""
data = {
info = {
ATTR_MESSAGE: message
}
if title is not None:
data[ATTR_TITLE] = title
info[ATTR_TITLE] = title
hass.services.call(DOMAIN, SERVICE_NOTIFY, data)
if data is not None:
info[ATTR_DATA] = data
hass.services.call(DOMAIN, SERVICE_NOTIFY, info)
def setup(hass, config):
+3 -3
View File
@@ -4,7 +4,7 @@ Demo notification service.
For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
"""
from homeassistant.components.notify import ATTR_TITLE, BaseNotificationService
from homeassistant.components.notify import BaseNotificationService
EVENT_NOTIFY = "notify"
@@ -24,5 +24,5 @@ class DemoNotificationService(BaseNotificationService):
def send_message(self, message="", **kwargs):
"""Send a message to a user."""
title = kwargs.get(ATTR_TITLE)
self.hass.bus.fire(EVENT_NOTIFY, {"title": title, "message": message})
kwargs['message'] = message
self.hass.bus.fire(EVENT_NOTIFY, kwargs)