From d06a3c91459364deb9e9638839c10938c4c7cf3c Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 6 Sep 2016 21:33:11 +0200 Subject: [PATCH] Use voluptuous for free mobile (#3236) --- .../components/notify/free_mobile.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/notify/free_mobile.py b/homeassistant/components/notify/free_mobile.py index e12cc5893b8..e5209e06582 100644 --- a/homeassistant/components/notify/free_mobile.py +++ b/homeassistant/components/notify/free_mobile.py @@ -6,22 +6,25 @@ https://home-assistant.io/components/notify.free_mobile/ """ import logging -from homeassistant.components.notify import DOMAIN, BaseNotificationService +import voluptuous as vol + +from homeassistant.components.notify import ( + PLATFORM_SCHEMA, BaseNotificationService) from homeassistant.const import CONF_ACCESS_TOKEN, CONF_USERNAME -from homeassistant.helpers import validate_config +import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) REQUIREMENTS = ['freesms==0.1.0'] +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ + vol.Required(CONF_USERNAME): cv.string, + vol.Required(CONF_ACCESS_TOKEN): cv.string, +}) + + def get_service(hass, config): """Get the Free Mobile SMS notification service.""" - if not validate_config({DOMAIN: config}, - {DOMAIN: [CONF_USERNAME, - CONF_ACCESS_TOKEN]}, - _LOGGER): - return None - return FreeSMSNotificationService(config[CONF_USERNAME], config[CONF_ACCESS_TOKEN])