1 """LlamaLab Automate notification service."""
3 from __future__
import annotations
5 from http
import HTTPStatus
9 import voluptuous
as vol
13 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
14 BaseNotificationService,
21 _LOGGER = logging.getLogger(__name__)
22 _RESOURCE =
"https://llamalab.com/automate/cloud/message"
24 ATTR_PRIORITY =
"priority"
28 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
30 vol.Required(CONF_API_KEY): cv.string,
31 vol.Required(CONF_TO): cv.string,
32 vol.Optional(CONF_DEVICE): cv.string,
40 discovery_info: DiscoveryInfoType |
None =
None,
41 ) -> AutomateNotificationService:
42 """Get the LlamaLab Automate notification service."""
43 secret = config.get(CONF_API_KEY)
44 recipient = config.get(CONF_TO)
45 device = config.get(CONF_DEVICE)
51 """Implement the notification service for LlamaLab Automate."""
53 def __init__(self, secret, recipient, device=None):
54 """Initialize the service."""
60 """Send a message to a user."""
63 data =
dict(kwargs.get(ATTR_DATA)
or {})
64 priority = data.get(ATTR_PRIORITY,
"normal").lower()
78 response = requests.post(_RESOURCE, json=data, timeout=10)
79 if response.status_code != HTTPStatus.OK:
80 _LOGGER.error(
"Error sending message: %s", response)
def __init__(self, secret, recipient, device=None)
def send_message(self, message="", **kwargs)
AutomateNotificationService get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)