2019-04-03 15:40:03 +00:00
|
|
|
"""Demo notification service."""
|
2022-08-26 09:34:38 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
from typing import Any
|
|
|
|
|
2019-03-28 03:36:13 +00:00
|
|
|
from homeassistant.components.notify import BaseNotificationService
|
2022-08-26 09:34:38 +00:00
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
2015-03-17 05:20:31 +00:00
|
|
|
|
|
|
|
EVENT_NOTIFY = "notify"
|
|
|
|
|
|
|
|
|
2022-08-26 09:34:38 +00:00
|
|
|
def get_service(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
config: ConfigType,
|
|
|
|
discovery_info: DiscoveryInfoType | None = None,
|
|
|
|
) -> BaseNotificationService:
|
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."""
|
|
|
|
|
2022-08-26 09:34:38 +00:00
|
|
|
def __init__(self, hass: HomeAssistant) -> None:
|
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
|
2022-08-26 09:34:38 +00:00
|
|
|
def targets(self) -> dict[str, str]:
|
2016-08-17 05:05:41 +00:00
|
|
|
"""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
|
|
|
|
2022-08-26 09:34:38 +00:00
|
|
|
def send_message(self, message: str = "", **kwargs: Any) -> None:
|
2016-03-08 10:46:32 +00:00
|
|
|
"""Send a message to a user."""
|
2019-07-31 19:25:30 +00:00
|
|
|
kwargs["message"] = message
|
2016-08-10 03:23:57 +00:00
|
|
|
self.hass.bus.fire(EVENT_NOTIFY, kwargs)
|