From 8f249f9149b103dbfa89609c2096f57501e977ec Mon Sep 17 00:00:00 2001 From: Rohan Kapoor Date: Sun, 10 Feb 2019 12:52:35 -0800 Subject: [PATCH] Use CONF_RECIPIENT for default recipient in config (#20925) * Use CONF_RECIPIENT for default recipient in config * Fix typo --- .../components/tplink_lte/__init__.py | 23 +++++++++++++++---- homeassistant/components/tplink_lte/notify.py | 3 ++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/tplink_lte/__init__.py b/homeassistant/components/tplink_lte/__init__.py index 17288a881aa..3f33cbe9fb3 100644 --- a/homeassistant/components/tplink_lte/__init__.py +++ b/homeassistant/components/tplink_lte/__init__.py @@ -13,7 +13,8 @@ import voluptuous as vol from homeassistant.components.notify import ATTR_TARGET from homeassistant.const import ( - CONF_HOST, CONF_NAME, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP) + CONF_HOST, CONF_NAME, CONF_PASSWORD, EVENT_HOMEASSISTANT_STOP, + CONF_RECIPIENT) from homeassistant.core import callback from homeassistant.helpers import config_validation as cv, discovery from homeassistant.helpers.aiohttp_client import async_create_clientsession @@ -27,10 +28,22 @@ DATA_KEY = 'tplink_lte' CONF_NOTIFY = "notify" -_NOTIFY_SCHEMA = vol.All(vol.Schema({ - vol.Optional(CONF_NAME): cv.string, - vol.Required(ATTR_TARGET): vol.All(cv.ensure_list, [cv.string]), -})) +# Deprecated in 0.88.0, invalidated in 0.91.0, remove in 0.92.0 +ATTR_TARGET_INVALIDATION_VERSION = '0.91.0' + +_NOTIFY_SCHEMA = vol.All( + vol.Schema({ + vol.Optional(CONF_NAME): cv.string, + vol.Optional(ATTR_TARGET): vol.All(cv.ensure_list, [cv.string]), + vol.Optional(CONF_RECIPIENT): vol.All(cv.ensure_list, [cv.string]) + }), + cv.deprecated( + ATTR_TARGET, + replacement_key=CONF_RECIPIENT, + invalidation_version=ATTR_TARGET_INVALIDATION_VERSION + ), + cv.has_at_least_one_key(CONF_RECIPIENT), +) CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.All(cv.ensure_list, [vol.Schema({ diff --git a/homeassistant/components/tplink_lte/notify.py b/homeassistant/components/tplink_lte/notify.py index 9bb80e2591c..f80345a4362 100644 --- a/homeassistant/components/tplink_lte/notify.py +++ b/homeassistant/components/tplink_lte/notify.py @@ -10,6 +10,7 @@ import attr from homeassistant.components.notify import ( ATTR_TARGET, BaseNotificationService) +from homeassistant.const import CONF_RECIPIENT from ..tplink_lte import DATA_KEY @@ -40,7 +41,7 @@ class TplinkNotifyService(BaseNotificationService): _LOGGER.error("No modem available") return - phone = self.config[ATTR_TARGET] + phone = self.config[CONF_RECIPIENT] targets = kwargs.get(ATTR_TARGET, phone) if targets and message: for target in targets: