2019-04-03 15:40:03 +00:00
|
|
|
"""Demo notification service."""
|
2019-03-28 03:36:13 +00:00
|
|
|
from homeassistant.components.notify import BaseNotificationService
|
2015-03-17 05:20:31 +00:00
|
|
|
|
|
|
|
EVENT_NOTIFY = "notify"
|
|
|
|
|
|
|
|
|
2017-01-15 02:53:14 +00:00
|
|
|
def get_service(hass, config, discovery_info=None):
|
2016-02-24 09:38:06 +00:00
|
|
|
"""Get the demo notification service."""
|
2015-03-17 05:20:31 +00:00
|
|
|
return DemoNotificationService(hass)
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-08-17 05:05:41 +00:00
|
|
|
@property
|
|
|
|
def targets(self):
|
|
|
|
"""Return a dictionary of registered targets."""
|
2016-09-25 16:41:11 +00:00
|
|
|
return {"test target name": "test target id"}
|
2016-08-17 05:05:41 +00:00
|
|
|
|
2015-03-17 05:20:31 +00:00
|
|
|
def send_message(self, message="", **kwargs):
|
2016-03-08 10:46:32 +00:00
|
|
|
"""Send a message to a user."""
|
2016-08-10 03:23:57 +00:00
|
|
|
kwargs['message'] = message
|
|
|
|
self.hass.bus.fire(EVENT_NOTIFY, kwargs)
|