2015-03-17 05:20:31 +00:00
|
|
|
"""
|
|
|
|
Demo notification service.
|
2016-02-24 09:38:06 +00:00
|
|
|
|
|
|
|
For more details about this platform, please refer to the documentation
|
|
|
|
https://home-assistant.io/components/demo/
|
2015-03-17 05:20:31 +00:00
|
|
|
"""
|
|
|
|
from homeassistant.components.notify import ATTR_TITLE, BaseNotificationService
|
|
|
|
|
|
|
|
EVENT_NOTIFY = "notify"
|
|
|
|
|
|
|
|
|
|
|
|
def get_service(hass, config):
|
2016-02-24 09:38:06 +00:00
|
|
|
"""Get the demo notification service."""
|
2015-03-17 05:20:31 +00:00
|
|
|
return DemoNotificationService(hass)
|
|
|
|
|
|
|
|
|
|
|
|
# pylint: disable=too-few-public-methods
|
|
|
|
class DemoNotificationService(BaseNotificationService):
|
2016-03-08 10:46:32 +00:00
|
|
|
"""Implement demo notification service."""
|
|
|
|
|
2015-03-17 05:20:31 +00:00
|
|
|
def __init__(self, hass):
|
2016-03-08 10:46:32 +00:00
|
|
|
"""Initialize the service."""
|
2015-03-17 05:20:31 +00:00
|
|
|
self.hass = hass
|
|
|
|
|
|
|
|
def send_message(self, message="", **kwargs):
|
2016-03-08 10:46:32 +00:00
|
|
|
"""Send a message to a user."""
|
2015-03-17 05:20:31 +00:00
|
|
|
title = kwargs.get(ATTR_TITLE)
|
|
|
|
self.hass.bus.fire(EVENT_NOTIFY, {"title": title, "message": message})
|