mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Use voluptuous for twilio (#3134)
This commit is contained in:
parent
e5ef548f10
commit
28e939afcf
@ -6,27 +6,29 @@ https://home-assistant.io/components/notify.twilio_sms/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_TARGET, DOMAIN, BaseNotificationService)
|
||||
from homeassistant.helpers import validate_config
|
||||
ATTR_TARGET, PLATFORM_SCHEMA, BaseNotificationService)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
REQUIREMENTS = ["twilio==5.4.0"]
|
||||
|
||||
|
||||
CONF_ACCOUNT_SID = "account_sid"
|
||||
CONF_AUTH_TOKEN = "auth_token"
|
||||
CONF_FROM_NUMBER = "from_number"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_ACCOUNT_SID): cv.string,
|
||||
vol.Required(CONF_AUTH_TOKEN): cv.string,
|
||||
vol.Required(CONF_FROM_NUMBER): vol.Match(r"^\+?[1-9]\d{1,14}$"),
|
||||
})
|
||||
|
||||
|
||||
def get_service(hass, config):
|
||||
"""Get the Twilio SMS notification service."""
|
||||
if not validate_config({DOMAIN: config},
|
||||
{DOMAIN: [CONF_ACCOUNT_SID,
|
||||
CONF_AUTH_TOKEN,
|
||||
CONF_FROM_NUMBER]},
|
||||
_LOGGER):
|
||||
return None
|
||||
|
||||
# pylint: disable=import-error
|
||||
from twilio.rest import TwilioRestClient
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user