Home Assistant Unofficial Reference 2024.12.1
notify.py
Go to the documentation of this file.
1 """Support for Keba notifications."""
2 
3 from __future__ import annotations
4 
5 from homeassistant.components.notify import ATTR_DATA, BaseNotificationService
6 from homeassistant.core import HomeAssistant
7 from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
8 
9 from . import DOMAIN
10 
11 
13  hass: HomeAssistant,
14  config: ConfigType,
15  discovery_info: DiscoveryInfoType | None = None,
16 ) -> KebaNotificationService:
17  """Return the notify service."""
18 
19  client = hass.data[DOMAIN]
20  return KebaNotificationService(client)
21 
22 
23 class KebaNotificationService(BaseNotificationService):
24  """Notification service for KEBA EV Chargers."""
25 
26  def __init__(self, client):
27  """Initialize the service."""
28  self._client_client = client
29 
30  async def async_send_message(self, message="", **kwargs):
31  """Send the message."""
32  text = message.replace(" ", "$") # Will be translated back by the display
33 
34  data = kwargs[ATTR_DATA] or {}
35  min_time = float(data.get("min_time", 2))
36  max_time = float(data.get("max_time", 10))
37 
38  await self._client_client.set_text(text, min_time, max_time)
def async_send_message(self, message="", **kwargs)
Definition: notify.py:30
KebaNotificationService async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)
Definition: notify.py:16