From c06fe51122fa5f785518674385bdeb1bad00aa26 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Tue, 6 Sep 2016 16:48:24 +0200 Subject: [PATCH] Fix email validation (fixes #3138) (#3227) --- homeassistant/components/notify/sendgrid.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/notify/sendgrid.py b/homeassistant/components/notify/sendgrid.py index ac249dc2c97..37253cd5c97 100644 --- a/homeassistant/components/notify/sendgrid.py +++ b/homeassistant/components/notify/sendgrid.py @@ -8,27 +8,28 @@ import logging import voluptuous as vol -import homeassistant.helpers.config_validation as cv from homeassistant.components.notify import ( ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA, BaseNotificationService) -from homeassistant.const import CONF_API_KEY, CONF_SENDER, CONF_RECIPIENT +from homeassistant.const import (CONF_API_KEY, CONF_SENDER, CONF_RECIPIENT) +import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['sendgrid==3.2.10'] + _LOGGER = logging.getLogger(__name__) - +# pylint: disable=no-value-for-parameter PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_API_KEY): cv.string, - vol.Required(CONF_SENDER): vol.Email, - vol.Required(CONF_RECIPIENT): cv.string, + vol.Required(CONF_SENDER): vol.Email(), + vol.Required(CONF_RECIPIENT): vol.Email(), }) def get_service(hass, config): """Get the SendGrid notification service.""" - api_key = config[CONF_API_KEY] - sender = config[CONF_SENDER] - recipient = config[CONF_RECIPIENT] + api_key = config.get(CONF_API_KEY) + sender = config.get(CONF_SENDER) + recipient = config.get(CONF_RECIPIENT) return SendgridNotificationService(api_key, sender, recipient)