1 """Support for TP-Link LTE notifications."""
3 from __future__
import annotations
16 from .
import DATA_KEY, LTEData
18 _LOGGER = logging.getLogger(__name__)
24 discovery_info: DiscoveryInfoType |
None =
None,
25 ) -> TplinkNotifyService |
None:
26 """Get the notification service."""
27 if discovery_info
is None:
34 """Implementation of a notification service."""
36 hass: HomeAssistant = attr.ib()
37 config: dict[str, Any] = attr.ib()
40 """Send a message to a user."""
42 lte_data: LTEData = self.hass.data[DATA_KEY]
43 modem_data = lte_data.get_modem_data(self.config)
45 _LOGGER.error(
"No modem available")
48 phone = self.config[CONF_RECIPIENT]
49 targets = kwargs.get(ATTR_TARGET, phone)
50 if targets
and message:
51 for target
in targets:
53 await modem_data.modem.sms(target, message)
54 except tp_connected.Error:
55 _LOGGER.error(
"Unable to send to %s", target)
None async_send_message(self, str message="", **Any kwargs)
TplinkNotifyService|None async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)