1 """SynologyChat platform for notify component."""
3 from __future__
import annotations
5 from http
import HTTPStatus
10 import voluptuous
as vol
14 PLATFORM_SCHEMA
as NOTIFY_PLATFORM_SCHEMA,
15 BaseNotificationService,
22 ATTR_FILE_URL =
"file_url"
24 PLATFORM_SCHEMA = NOTIFY_PLATFORM_SCHEMA.extend(
26 vol.Required(CONF_RESOURCE): cv.url,
27 vol.Optional(CONF_VERIFY_SSL, default=
True): cv.boolean,
31 _LOGGER = logging.getLogger(__name__)
37 discovery_info: DiscoveryInfoType |
None =
None,
38 ) -> SynologyChatNotificationService:
39 """Get the Synology Chat notification service."""
40 resource = config.get(CONF_RESOURCE)
41 verify_ssl = config.get(CONF_VERIFY_SSL)
47 """Implementation of a notification service for Synology Chat."""
50 """Initialize the service."""
55 """Send a message to a user."""
56 data = {
"text": message}
58 extended_data = kwargs.get(ATTR_DATA)
59 file_url = extended_data.get(ATTR_FILE_URL)
if extended_data
else None
62 data[
"file_url"] = file_url
64 to_send = f
"payload={json.dumps(data)}"
66 response = requests.post(
70 if response.status_code
not in (HTTPStatus.OK, HTTPStatus.CREATED):
72 "Error sending message. Response %d: %s:",
def send_message(self, message="", **kwargs)
def __init__(self, resource, verify_ssl)
SynologyChatNotificationService get_service(HomeAssistant hass, ConfigType config, DiscoveryInfoType|None discovery_info=None)