mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Use voluptuous for twitter (#3126)
This commit is contained in:
parent
6b6d34ba51
commit
afdd734b44
@ -6,9 +6,12 @@ https://home-assistant.io/components/notify.twitter/
|
|||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.notify import DOMAIN, BaseNotificationService
|
import voluptuous as vol
|
||||||
|
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
from homeassistant.components.notify import (PLATFORM_SCHEMA,
|
||||||
|
BaseNotificationService)
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.helpers import validate_config
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
REQUIREMENTS = ['TwitterAPI==2.4.2']
|
REQUIREMENTS = ['TwitterAPI==2.4.2']
|
||||||
@ -17,16 +20,16 @@ CONF_CONSUMER_KEY = "consumer_key"
|
|||||||
CONF_CONSUMER_SECRET = "consumer_secret"
|
CONF_CONSUMER_SECRET = "consumer_secret"
|
||||||
CONF_ACCESS_TOKEN_SECRET = "access_token_secret"
|
CONF_ACCESS_TOKEN_SECRET = "access_token_secret"
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_CONSUMER_KEY): cv.string,
|
||||||
|
vol.Required(CONF_CONSUMER_SECRET): cv.string,
|
||||||
|
vol.Required(CONF_ACCESS_TOKEN): cv.string,
|
||||||
|
vol.Required(CONF_ACCESS_TOKEN_SECRET): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def get_service(hass, config):
|
def get_service(hass, config):
|
||||||
"""Get the Twitter notification service."""
|
"""Get the Twitter notification service."""
|
||||||
if not validate_config({DOMAIN: config},
|
|
||||||
{DOMAIN: [CONF_CONSUMER_KEY, CONF_CONSUMER_SECRET,
|
|
||||||
CONF_ACCESS_TOKEN,
|
|
||||||
CONF_ACCESS_TOKEN_SECRET]},
|
|
||||||
_LOGGER):
|
|
||||||
return None
|
|
||||||
|
|
||||||
return TwitterNotificationService(config[CONF_CONSUMER_KEY],
|
return TwitterNotificationService(config[CONF_CONSUMER_KEY],
|
||||||
config[CONF_CONSUMER_SECRET],
|
config[CONF_CONSUMER_SECRET],
|
||||||
config[CONF_ACCESS_TOKEN],
|
config[CONF_ACCESS_TOKEN],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user