From 79fa9963da2f43e09da2cbb8e8f19e9c489bc546 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 6 Sep 2016 22:24:04 +0200 Subject: [PATCH] Use voluptuous for nma (#3241) --- homeassistant/components/notify/nma.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/notify/nma.py b/homeassistant/components/notify/nma.py index ef75abb2fe4..ffa4ae229c7 100644 --- a/homeassistant/components/notify/nma.py +++ b/homeassistant/components/notify/nma.py @@ -8,23 +8,24 @@ import logging import xml.etree.ElementTree as ET import requests +import voluptuous as vol from homeassistant.components.notify import ( - ATTR_TITLE, ATTR_TITLE_DEFAULT, DOMAIN, BaseNotificationService) + ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService) from homeassistant.const import CONF_API_KEY -from homeassistant.helpers import validate_config +import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) _RESOURCE = 'https://www.notifymyandroid.com/publicapi/' +PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ + vol.Required(CONF_API_KEY): cv.string, +}) + + def get_service(hass, config): """Get the NMA notification service.""" - if not validate_config({DOMAIN: config}, - {DOMAIN: [CONF_API_KEY]}, - _LOGGER): - return None - response = requests.get(_RESOURCE + 'verify', params={"apikey": config[CONF_API_KEY]}) tree = ET.fromstring(response.content)