Use voluptuous for xmpp (#3127)
This commit is contained in:
parent
dadcf92290
commit
6b6d34ba51
1 changed files with 19 additions and 8 deletions
|
@ -6,30 +6,41 @@ https://home-assistant.io/components/notify.xmpp/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_TITLE, ATTR_TITLE_DEFAULT, DOMAIN, BaseNotificationService)
|
ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService)
|
||||||
from homeassistant.helpers import validate_config
|
from homeassistant.const import CONF_PASSWORD
|
||||||
|
|
||||||
REQUIREMENTS = ['sleekxmpp==1.3.1',
|
REQUIREMENTS = ['sleekxmpp==1.3.1',
|
||||||
'dnspython3==1.12.0',
|
'dnspython3==1.12.0',
|
||||||
'pyasn1==0.1.9',
|
'pyasn1==0.1.9',
|
||||||
'pyasn1-modules==0.0.8']
|
'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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Jabber (XMPP) notification service."""
|
"""Get the Jabber (XMPP) notification service."""
|
||||||
if not validate_config({DOMAIN: config},
|
|
||||||
{DOMAIN: ['sender', 'password', 'recipient']},
|
|
||||||
_LOGGER):
|
|
||||||
return None
|
|
||||||
|
|
||||||
return XmppNotificationService(
|
return XmppNotificationService(
|
||||||
config.get('sender'),
|
config.get('sender'),
|
||||||
config.get('password'),
|
config.get('password'),
|
||||||
config.get('recipient'),
|
config.get('recipient'),
|
||||||
config.get('tls', True))
|
config.get('tls'))
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue