mirror of
https://github.com/home-assistant/core.git
synced 2025-08-10 08:05:06 +02:00
Added message to data_template at notify REST (#23108)
* Added message to data_template at notify rest * Added missing newlines
This commit is contained in:
@@ -11,8 +11,8 @@ from homeassistant.const import (
|
|||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from homeassistant.components.notify import (
|
from homeassistant.components.notify import (
|
||||||
ATTR_TARGET, ATTR_TITLE, ATTR_TITLE_DEFAULT, PLATFORM_SCHEMA,
|
ATTR_TARGET, ATTR_TITLE, ATTR_TITLE_DEFAULT, ATTR_MESSAGE,
|
||||||
BaseNotificationService)
|
PLATFORM_SCHEMA, BaseNotificationService)
|
||||||
|
|
||||||
CONF_DATA = 'data'
|
CONF_DATA = 'data'
|
||||||
CONF_DATA_TEMPLATE = 'data_template'
|
CONF_DATA_TEMPLATE = 'data_template'
|
||||||
@@ -110,6 +110,8 @@ class RestNotificationService(BaseNotificationService):
|
|||||||
if self._data:
|
if self._data:
|
||||||
data.update(self._data)
|
data.update(self._data)
|
||||||
elif self._data_template:
|
elif self._data_template:
|
||||||
|
kwargs[ATTR_MESSAGE] = message
|
||||||
|
|
||||||
def _data_template_creator(value):
|
def _data_template_creator(value):
|
||||||
"""Recursive template creator helper function."""
|
"""Recursive template creator helper function."""
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
@@ -119,6 +121,7 @@ class RestNotificationService(BaseNotificationService):
|
|||||||
for key, item in value.items()}
|
for key, item in value.items()}
|
||||||
value.hass = self._hass
|
value.hass = self._hass
|
||||||
return value.async_render(kwargs)
|
return value.async_render(kwargs)
|
||||||
|
|
||||||
data.update(_data_template_creator(self._data_template))
|
data.update(_data_template_creator(self._data_template))
|
||||||
|
|
||||||
if self._method == 'POST':
|
if self._method == 'POST':
|
||||||
|
Reference in New Issue
Block a user