1 """Support for Huawei LTE router notifications."""
3 from __future__
import annotations
9 from huawei_lte_api.exceptions
import ResponseErrorException
17 from .const
import ATTR_CONFIG_ENTRY_ID, DOMAIN
19 _LOGGER = logging.getLogger(__name__)
25 discovery_info: DiscoveryInfoType |
None =
None,
26 ) -> HuaweiLteSmsNotificationService |
None:
27 """Get the notification service."""
28 if discovery_info
is None:
31 router = hass.data[DOMAIN].routers[discovery_info[ATTR_CONFIG_ENTRY_ID]]
32 default_targets = discovery_info[CONF_RECIPIENT]
or []
38 """Huawei LTE router SMS notification service."""
40 def __init__(self, router: Router, default_targets: list[str]) ->
None:
46 """Send message to target numbers."""
49 if not targets
or not message:
52 if self.
routerrouter.suspended:
54 "Integration suspended, not sending notification to %s", targets
59 resp = self.
routerrouter.client.sms.send_sms(
60 phone_numbers=targets, message=message
62 _LOGGER.debug(
"Sent to %s: %s", targets, resp)
63 except ResponseErrorException
as ex:
64 _LOGGER.error(
"Could not send to %s: %s", targets, ex)
66 self.
routerrouter.notify_last_attempt = time.monotonic()
None __init__(self, Router router, list[str] default_targets)
None send_message(self, str message="", **Any kwargs)
HuaweiLteSmsNotificationService|None async_get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)