1 """Clickatell platform for notify component."""
3 from __future__
import annotations
5 from http
import HTTPStatus
10 import voluptuous
as vol
13 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
14 BaseNotificationService,
21 _LOGGER = logging.getLogger(__name__)
23 DEFAULT_NAME =
"clickatell"
25 BASE_API_URL =
"https://platform.clickatell.com/messages/http/send"
27 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
28 {vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_RECIPIENT): cv.string}
35 discovery_info: DiscoveryInfoType |
None =
None,
36 ) -> ClickatellNotificationService:
37 """Get the Clickatell notification service."""
42 """Implementation of a notification service for the Clickatell service."""
44 def __init__(self, config: ConfigType) ->
None:
45 """Initialize the service."""
46 self.api_key: str = config[CONF_API_KEY]
47 self.recipient: str = config[CONF_RECIPIENT]
50 """Send a message to a user."""
51 data = {
"apiKey": self.api_key,
"to": self.recipient,
"content": message}
53 resp = requests.get(BASE_API_URL, params=data, timeout=5)
54 if resp.status_code
not in (HTTPStatus.OK, HTTPStatus.ACCEPTED):
55 _LOGGER.error(
"Error %s : %s", resp.status_code, resp.text)
None send_message(self, str message="", **Any kwargs)
None __init__(self, ConfigType config)
ClickatellNotificationService get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)