Use CONF_RECIPIENT for default recipient in config (#20925)
* Use CONF_RECIPIENT for default recipient in config * Fix typo
This commit is contained in:
parent
203a6fd349
commit
8f249f9149
2 changed files with 20 additions and 6 deletions
|
@ -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({
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue