Use voluptuous for xmpp (#3127)

This commit is contained in:
Pascal Vizeli 2016-09-02 06:27:28 +02:00 committed by Teagan Glenn
parent dadcf92290
commit 6b6d34ba51

View file

@ -6,30 +6,41 @@ https://home-assistant.io/components/notify.xmpp/
"""
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