Skip to content

Commit

Permalink
Use voluptuous for xmpp (#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli authored and Teagan42 committed Sep 2, 2016
1 parent dadcf92 commit 6b6d34b
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions homeassistant/components/notify/xmpp.py
Expand Up @@ -6,30 +6,41 @@
"""
import logging

import voluptuous as vol

import homeassistant.helpers.config_validation as cv
from homeassistant.components.notify import (
ATTR_TITLE, ATTR_TITLE_DEFAULT, DOMAIN, BaseNotificationService)
from homeassistant.helpers import validate_config
ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService)
from homeassistant.const import CONF_PASSWORD

REQUIREMENTS = ['sleekxmpp==1.3.1',
'dnspython3==1.12.0',
'pyasn1==0.1.9',
'pyasn1-modules==0.0.8']


CONF_SENDER = 'sender'
CONF_RECIPIENT = 'recipient'
CONF_TLS = 'tls'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_SENDER): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Required(CONF_RECIPIENT): cv.string,
vol.Optional(CONF_TLS, default=True): cv.boolean,
})


_LOGGER = logging.getLogger(__name__)


def get_service(hass, config):
"""Get the Jabber (XMPP) notification service."""
if not validate_config({DOMAIN: config},
{DOMAIN: ['sender', 'password', 'recipient']},
_LOGGER):
return None

return XmppNotificationService(
config.get('sender'),
config.get('password'),
config.get('recipient'),
config.get('tls', True))
config.get('tls'))


# pylint: disable=too-few-public-methods
Expand Down

0 comments on commit 6b6d34b

Please sign in to comment.