mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
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
@ -13,7 +13,8 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.notify import ATTR_TARGET
|
from homeassistant.components.notify import ATTR_TARGET
|
||||||
from homeassistant.const import (
|
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.core import callback
|
||||||
from homeassistant.helpers import config_validation as cv, discovery
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||||
@ -27,10 +28,22 @@ DATA_KEY = 'tplink_lte'
|
|||||||
|
|
||||||
CONF_NOTIFY = "notify"
|
CONF_NOTIFY = "notify"
|
||||||
|
|
||||||
_NOTIFY_SCHEMA = vol.All(vol.Schema({
|
# 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(CONF_NAME): cv.string,
|
||||||
vol.Required(ATTR_TARGET): vol.All(cv.ensure_list, [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({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.All(cv.ensure_list, [vol.Schema({
|
DOMAIN: vol.All(cv.ensure_list, [vol.Schema({
|
||||||
|
@ -10,6 +10,7 @@ import attr
|
|||||||
|
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_TARGET, BaseNotificationService)
|
ATTR_TARGET, BaseNotificationService)
|
||||||
|
from homeassistant.const import CONF_RECIPIENT
|
||||||
|
|
||||||
from ..tplink_lte import DATA_KEY
|
from ..tplink_lte import DATA_KEY
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ class TplinkNotifyService(BaseNotificationService):
|
|||||||
_LOGGER.error("No modem available")
|
_LOGGER.error("No modem available")
|
||||||
return
|
return
|
||||||
|
|
||||||
phone = self.config[ATTR_TARGET]
|
phone = self.config[CONF_RECIPIENT]
|
||||||
targets = kwargs.get(ATTR_TARGET, phone)
|
targets = kwargs.get(ATTR_TARGET, phone)
|
||||||
if targets and message:
|
if targets and message:
|
||||||
for target in targets:
|
for target in targets:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user