Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions homeassistant/components/notify/synology_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@

from homeassistant.components.notify import (
BaseNotificationService, PLATFORM_SCHEMA, ATTR_DATA)
from homeassistant.const import CONF_RESOURCE
from homeassistant.const import CONF_RESOURCE, CONF_VERIFY_SSL
import homeassistant.helpers.config_validation as cv

ATTR_FILE_URL = 'file_url'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_RESOURCE): cv.url,
vol.Optional(CONF_VERIFY_SSL, default=True): cv.boolean,
})

_LOGGER = logging.getLogger(__name__)
Expand All @@ -27,16 +28,18 @@
def get_service(hass, config, discovery_info=None):
"""Get the Synology Chat notification service."""
resource = config.get(CONF_RESOURCE)
verify_ssl = config.get(CONF_VERIFY_SSL)

return SynologyChatNotificationService(resource)
return SynologyChatNotificationService(resource, verify_ssl)


class SynologyChatNotificationService(BaseNotificationService):
"""Implementation of a notification service for Synology Chat."""

def __init__(self, resource):
def __init__(self, resource, verify_ssl):
"""Initialize the service."""
self._resource = resource
self._verify_ssl = verify_ssl

def send_message(self, message="", **kwargs):
"""Send a message to a user."""
Expand All @@ -52,7 +55,8 @@ def send_message(self, message="", **kwargs):

to_send = 'payload={}'.format(json.dumps(data))

response = requests.post(self._resource, data=to_send, timeout=10)
response = requests.post(self._resource, data=to_send, timeout=10,
verify=self._verify_ssl)

if response.status_code not in (200, 201):
_LOGGER.exception(
Expand Down