mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Skip template result parsing in several places (#42408)
* Skip template result parsing in several places * Adjust alert integration * Adjust Alexa integration * Adjust apns integration * Adjust arest integration * Adjust dialogflow integration * Adjust generic camera integration * Adjust imap email content integration * Adjust InfluxDB integration * Adjust intent integration * Adjust logbook integration * Adjust HP ILO integration * Adjust manual alarm control panel integration * Adjust manual mqtt alarm control panel integration * Adjust minio integration * Adjust mqtt integration * Adjust notify integration * Adjust persistent notification integration * Adjust rest integration * Adjust rss feed template integration * Adjust slack integration * Adjust Xiaomi integration * Adjust TCP integration * Adjust Telegram Bot integration * Bump CI cache version * Revert "Bump CI cache version" This reverts commit 875efe58cf165d84ce68aa8867b99a169fad4ea5. * Adjust demo tests
This commit is contained in:
parent
6380ebd1eb
commit
0e98bc5ea2
@ -276,7 +276,7 @@ class Alert(ToggleEntity):
|
|||||||
self._send_done_message = True
|
self._send_done_message = True
|
||||||
|
|
||||||
if self._message_template is not None:
|
if self._message_template is not None:
|
||||||
message = self._message_template.async_render()
|
message = self._message_template.async_render(parse_result=False)
|
||||||
else:
|
else:
|
||||||
message = self._name
|
message = self._name
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class Alert(ToggleEntity):
|
|||||||
if self._done_message_template is None:
|
if self._done_message_template is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
message = self._done_message_template.async_render()
|
message = self._done_message_template.async_render(parse_result=False)
|
||||||
|
|
||||||
await self._send_notification_message(message)
|
await self._send_notification_message(message)
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ class Alert(ToggleEntity):
|
|||||||
msg_payload = {ATTR_MESSAGE: message}
|
msg_payload = {ATTR_MESSAGE: message}
|
||||||
|
|
||||||
if self._title_template is not None:
|
if self._title_template is not None:
|
||||||
title = self._title_template.async_render()
|
title = self._title_template.async_render(parse_result=False)
|
||||||
msg_payload.update({ATTR_TITLE: title})
|
msg_payload.update({ATTR_TITLE: title})
|
||||||
if self._data:
|
if self._data:
|
||||||
msg_payload.update({ATTR_DATA: self._data})
|
msg_payload.update({ATTR_DATA: self._data})
|
||||||
|
@ -80,13 +80,17 @@ class AlexaFlashBriefingView(http.HomeAssistantView):
|
|||||||
output = {}
|
output = {}
|
||||||
if item.get(CONF_TITLE) is not None:
|
if item.get(CONF_TITLE) is not None:
|
||||||
if isinstance(item.get(CONF_TITLE), template.Template):
|
if isinstance(item.get(CONF_TITLE), template.Template):
|
||||||
output[ATTR_TITLE_TEXT] = item[CONF_TITLE].async_render()
|
output[ATTR_TITLE_TEXT] = item[CONF_TITLE].async_render(
|
||||||
|
parse_result=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
output[ATTR_TITLE_TEXT] = item.get(CONF_TITLE)
|
output[ATTR_TITLE_TEXT] = item.get(CONF_TITLE)
|
||||||
|
|
||||||
if item.get(CONF_TEXT) is not None:
|
if item.get(CONF_TEXT) is not None:
|
||||||
if isinstance(item.get(CONF_TEXT), template.Template):
|
if isinstance(item.get(CONF_TEXT), template.Template):
|
||||||
output[ATTR_MAIN_TEXT] = item[CONF_TEXT].async_render()
|
output[ATTR_MAIN_TEXT] = item[CONF_TEXT].async_render(
|
||||||
|
parse_result=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
output[ATTR_MAIN_TEXT] = item.get(CONF_TEXT)
|
output[ATTR_MAIN_TEXT] = item.get(CONF_TEXT)
|
||||||
|
|
||||||
@ -97,13 +101,17 @@ class AlexaFlashBriefingView(http.HomeAssistantView):
|
|||||||
|
|
||||||
if item.get(CONF_AUDIO) is not None:
|
if item.get(CONF_AUDIO) is not None:
|
||||||
if isinstance(item.get(CONF_AUDIO), template.Template):
|
if isinstance(item.get(CONF_AUDIO), template.Template):
|
||||||
output[ATTR_STREAM_URL] = item[CONF_AUDIO].async_render()
|
output[ATTR_STREAM_URL] = item[CONF_AUDIO].async_render(
|
||||||
|
parse_result=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
output[ATTR_STREAM_URL] = item.get(CONF_AUDIO)
|
output[ATTR_STREAM_URL] = item.get(CONF_AUDIO)
|
||||||
|
|
||||||
if item.get(CONF_DISPLAY_URL) is not None:
|
if item.get(CONF_DISPLAY_URL) is not None:
|
||||||
if isinstance(item.get(CONF_DISPLAY_URL), template.Template):
|
if isinstance(item.get(CONF_DISPLAY_URL), template.Template):
|
||||||
output[ATTR_REDIRECTION_URL] = item[CONF_DISPLAY_URL].async_render()
|
output[ATTR_REDIRECTION_URL] = item[CONF_DISPLAY_URL].async_render(
|
||||||
|
parse_result=False
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
output[ATTR_REDIRECTION_URL] = item.get(CONF_DISPLAY_URL)
|
output[ATTR_REDIRECTION_URL] = item.get(CONF_DISPLAY_URL)
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ class AlexaResponse:
|
|||||||
|
|
||||||
self.reprompt = {
|
self.reprompt = {
|
||||||
"type": speech_type.value,
|
"type": speech_type.value,
|
||||||
key: text.async_render(self.variables),
|
key: text.async_render(self.variables, parse_result=False),
|
||||||
}
|
}
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
|
@ -229,7 +229,7 @@ class ApnsNotificationService(BaseNotificationService):
|
|||||||
if isinstance(message, str):
|
if isinstance(message, str):
|
||||||
rendered_message = message
|
rendered_message = message
|
||||||
elif isinstance(message, template_helper.Template):
|
elif isinstance(message, template_helper.Template):
|
||||||
rendered_message = message.render()
|
rendered_message = message.render(parse_result=False)
|
||||||
else:
|
else:
|
||||||
rendered_message = ""
|
rendered_message = ""
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
def _render(value):
|
def _render(value):
|
||||||
try:
|
try:
|
||||||
return value_template.async_render({"value": value})
|
return value_template.async_render({"value": value}, parse_result=False)
|
||||||
except TemplateError:
|
except TemplateError:
|
||||||
_LOGGER.exception("Error parsing value")
|
_LOGGER.exception("Error parsing value")
|
||||||
return value
|
return value
|
||||||
|
@ -161,7 +161,7 @@ class DialogflowResponse:
|
|||||||
assert self.speech is None
|
assert self.speech is None
|
||||||
|
|
||||||
if isinstance(text, template.Template):
|
if isinstance(text, template.Template):
|
||||||
text = text.async_render(self.parameters)
|
text = text.async_render(self.parameters, parse_result=False)
|
||||||
|
|
||||||
self.speech = text
|
self.speech = text
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class GenericCamera(Camera):
|
|||||||
async def async_camera_image(self):
|
async def async_camera_image(self):
|
||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
try:
|
try:
|
||||||
url = self._still_image_url.async_render()
|
url = self._still_image_url.async_render(parse_result=False)
|
||||||
except TemplateError as err:
|
except TemplateError as err:
|
||||||
_LOGGER.error("Error parsing template %s: %s", self._still_image_url, err)
|
_LOGGER.error("Error parsing template %s: %s", self._still_image_url, err)
|
||||||
return self._last_image
|
return self._last_image
|
||||||
@ -178,7 +178,7 @@ class GenericCamera(Camera):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self._stream_source.async_render()
|
return self._stream_source.async_render(parse_result=False)
|
||||||
except TemplateError as err:
|
except TemplateError as err:
|
||||||
_LOGGER.error("Error parsing template %s: %s", self._stream_source, err)
|
_LOGGER.error("Error parsing template %s: %s", self._stream_source, err)
|
||||||
return None
|
return None
|
||||||
|
@ -157,7 +157,9 @@ class HpIloSensor(Entity):
|
|||||||
ilo_data = getattr(self.hp_ilo_data.data, self._ilo_function)()
|
ilo_data = getattr(self.hp_ilo_data.data, self._ilo_function)()
|
||||||
|
|
||||||
if self._sensor_value_template is not None:
|
if self._sensor_value_template is not None:
|
||||||
ilo_data = self._sensor_value_template.render(ilo_data=ilo_data)
|
ilo_data = self._sensor_value_template.render(
|
||||||
|
ilo_data=ilo_data, parse_result=False
|
||||||
|
)
|
||||||
|
|
||||||
self._state = ilo_data
|
self._state = ilo_data
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ class EmailContentSensor(Entity):
|
|||||||
ATTR_DATE: email_message["Date"],
|
ATTR_DATE: email_message["Date"],
|
||||||
ATTR_BODY: EmailContentSensor.get_msg_text(email_message),
|
ATTR_BODY: EmailContentSensor.get_msg_text(email_message),
|
||||||
}
|
}
|
||||||
return self._value_template.render(variables)
|
return self._value_template.render(variables, parse_result=False)
|
||||||
|
|
||||||
def sender_allowed(self, email_message):
|
def sender_allowed(self, email_message):
|
||||||
"""Check if the sender is in the allowed senders list."""
|
"""Check if the sender is in the allowed senders list."""
|
||||||
|
@ -268,7 +268,7 @@ class InfluxFluxSensorData:
|
|||||||
"""Get the latest data by querying influx."""
|
"""Get the latest data by querying influx."""
|
||||||
_LOGGER.debug(RENDERING_QUERY_MESSAGE, self.query)
|
_LOGGER.debug(RENDERING_QUERY_MESSAGE, self.query)
|
||||||
try:
|
try:
|
||||||
rendered_query = self.query.render()
|
rendered_query = self.query.render(parse_result=False)
|
||||||
except TemplateError as ex:
|
except TemplateError as ex:
|
||||||
_LOGGER.error(RENDERING_QUERY_ERROR_MESSAGE, ex)
|
_LOGGER.error(RENDERING_QUERY_ERROR_MESSAGE, ex)
|
||||||
return
|
return
|
||||||
@ -312,7 +312,7 @@ class InfluxQLSensorData:
|
|||||||
"""Get the latest data with a shell command."""
|
"""Get the latest data with a shell command."""
|
||||||
_LOGGER.debug(RENDERING_WHERE_MESSAGE, self.where)
|
_LOGGER.debug(RENDERING_WHERE_MESSAGE, self.where)
|
||||||
try:
|
try:
|
||||||
where_clause = self.where.render()
|
where_clause = self.where.render(parse_result=False)
|
||||||
except TemplateError as ex:
|
except TemplateError as ex:
|
||||||
_LOGGER.error(RENDERING_WHERE_ERROR_MESSAGE, ex)
|
_LOGGER.error(RENDERING_WHERE_ERROR_MESSAGE, ex)
|
||||||
return
|
return
|
||||||
|
@ -87,13 +87,14 @@ class ScriptIntentHandler(intent.IntentHandler):
|
|||||||
|
|
||||||
if speech is not None:
|
if speech is not None:
|
||||||
response.async_set_speech(
|
response.async_set_speech(
|
||||||
speech[CONF_TEXT].async_render(slots), speech[CONF_TYPE]
|
speech[CONF_TEXT].async_render(slots, parse_result=False),
|
||||||
|
speech[CONF_TYPE],
|
||||||
)
|
)
|
||||||
|
|
||||||
if card is not None:
|
if card is not None:
|
||||||
response.async_set_card(
|
response.async_set_card(
|
||||||
card[CONF_TITLE].async_render(slots),
|
card[CONF_TITLE].async_render(slots, parse_result=False),
|
||||||
card[CONF_CONTENT].async_render(slots),
|
card[CONF_CONTENT].async_render(slots, parse_result=False),
|
||||||
card[CONF_TYPE],
|
card[CONF_TYPE],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ async def async_setup(hass, config):
|
|||||||
domain = DOMAIN
|
domain = DOMAIN
|
||||||
|
|
||||||
message.hass = hass
|
message.hass = hass
|
||||||
message = message.async_render()
|
message = message.async_render(parse_result=False)
|
||||||
async_log_entry(hass, name, message, domain, entity_id)
|
async_log_entry(hass, name, message, domain, entity_id)
|
||||||
|
|
||||||
hass.components.frontend.async_register_built_in_panel(
|
hass.components.frontend.async_register_built_in_panel(
|
||||||
|
@ -385,7 +385,9 @@ class ManualAlarm(alarm.AlarmControlPanelEntity, RestoreEntity):
|
|||||||
if isinstance(self._code, str):
|
if isinstance(self._code, str):
|
||||||
alarm_code = self._code
|
alarm_code = self._code
|
||||||
else:
|
else:
|
||||||
alarm_code = self._code.render(from_state=self._state, to_state=state)
|
alarm_code = self._code.render(
|
||||||
|
parse_result=False, from_state=self._state, to_state=state
|
||||||
|
)
|
||||||
check = not alarm_code or code == alarm_code
|
check = not alarm_code or code == alarm_code
|
||||||
if not check:
|
if not check:
|
||||||
_LOGGER.warning("Invalid code given for %s", state)
|
_LOGGER.warning("Invalid code given for %s", state)
|
||||||
|
@ -406,7 +406,9 @@ class ManualMQTTAlarm(alarm.AlarmControlPanelEntity):
|
|||||||
if isinstance(self._code, str):
|
if isinstance(self._code, str):
|
||||||
alarm_code = self._code
|
alarm_code = self._code
|
||||||
else:
|
else:
|
||||||
alarm_code = self._code.render(from_state=self._state, to_state=state)
|
alarm_code = self._code.render(
|
||||||
|
from_state=self._state, to_state=state, parse_result=False
|
||||||
|
)
|
||||||
check = not alarm_code or code == alarm_code
|
check = not alarm_code or code == alarm_code
|
||||||
if not check:
|
if not check:
|
||||||
_LOGGER.warning("Invalid code given for %s", state)
|
_LOGGER.warning("Invalid code given for %s", state)
|
||||||
|
@ -124,7 +124,7 @@ def setup(hass, config):
|
|||||||
def _render_service_value(service, key):
|
def _render_service_value(service, key):
|
||||||
value = service.data[key]
|
value = service.data[key]
|
||||||
value.hass = hass
|
value.hass = hass
|
||||||
return value.async_render()
|
return value.async_render(parse_result=False)
|
||||||
|
|
||||||
def put_file(service):
|
def put_file(service):
|
||||||
"""Upload file service."""
|
"""Upload file service."""
|
||||||
|
@ -338,7 +338,7 @@ class MqttAlarm(
|
|||||||
"""Publish via mqtt."""
|
"""Publish via mqtt."""
|
||||||
command_template = self._config[CONF_COMMAND_TEMPLATE]
|
command_template = self._config[CONF_COMMAND_TEMPLATE]
|
||||||
values = {"action": action, "code": code}
|
values = {"action": action, "code": code}
|
||||||
payload = command_template.async_render(**values)
|
payload = command_template.async_render(**values, parse_result=False)
|
||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
self.hass,
|
||||||
self._config[CONF_COMMAND_TOPIC],
|
self._config[CONF_COMMAND_TOPIC],
|
||||||
|
@ -557,7 +557,7 @@ class MqttCover(
|
|||||||
position = kwargs[ATTR_POSITION]
|
position = kwargs[ATTR_POSITION]
|
||||||
percentage_position = position
|
percentage_position = position
|
||||||
if set_position_template is not None:
|
if set_position_template is not None:
|
||||||
position = set_position_template.async_render(**kwargs)
|
position = set_position_template.async_render(parse_result=False, **kwargs)
|
||||||
else:
|
else:
|
||||||
position = self.find_in_range_from_percent(position, COVER_PAYLOAD)
|
position = self.find_in_range_from_percent(position, COVER_PAYLOAD)
|
||||||
|
|
||||||
|
@ -441,7 +441,9 @@ class MqttLightTemplate(
|
|||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
self.hass,
|
||||||
self._topics[CONF_COMMAND_TOPIC],
|
self._topics[CONF_COMMAND_TOPIC],
|
||||||
self._templates[CONF_COMMAND_ON_TEMPLATE].async_render(**values),
|
self._templates[CONF_COMMAND_ON_TEMPLATE].async_render(
|
||||||
|
parse_result=False, **values
|
||||||
|
),
|
||||||
self._config[CONF_QOS],
|
self._config[CONF_QOS],
|
||||||
self._config[CONF_RETAIN],
|
self._config[CONF_RETAIN],
|
||||||
)
|
)
|
||||||
@ -464,7 +466,9 @@ class MqttLightTemplate(
|
|||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass,
|
self.hass,
|
||||||
self._topics[CONF_COMMAND_TOPIC],
|
self._topics[CONF_COMMAND_TOPIC],
|
||||||
self._templates[CONF_COMMAND_OFF_TEMPLATE].async_render(**values),
|
self._templates[CONF_COMMAND_OFF_TEMPLATE].async_render(
|
||||||
|
parse_result=False, **values
|
||||||
|
),
|
||||||
self._config[CONF_QOS],
|
self._config[CONF_QOS],
|
||||||
self._config[CONF_RETAIN],
|
self._config[CONF_RETAIN],
|
||||||
)
|
)
|
||||||
|
@ -133,7 +133,7 @@ class BaseNotificationService:
|
|||||||
|
|
||||||
if title:
|
if title:
|
||||||
title.hass = self.hass
|
title.hass = self.hass
|
||||||
kwargs[ATTR_TITLE] = title.async_render()
|
kwargs[ATTR_TITLE] = title.async_render(parse_result=False)
|
||||||
|
|
||||||
if self._registered_targets.get(service.service) is not None:
|
if self._registered_targets.get(service.service) is not None:
|
||||||
kwargs[ATTR_TARGET] = [self._registered_targets[service.service]]
|
kwargs[ATTR_TARGET] = [self._registered_targets[service.service]]
|
||||||
@ -141,7 +141,7 @@ class BaseNotificationService:
|
|||||||
kwargs[ATTR_TARGET] = service.data.get(ATTR_TARGET)
|
kwargs[ATTR_TARGET] = service.data.get(ATTR_TARGET)
|
||||||
|
|
||||||
message.hass = self.hass
|
message.hass = self.hass
|
||||||
kwargs[ATTR_MESSAGE] = message.async_render()
|
kwargs[ATTR_MESSAGE] = message.async_render(parse_result=False)
|
||||||
kwargs[ATTR_DATA] = service.data.get(ATTR_DATA)
|
kwargs[ATTR_DATA] = service.data.get(ATTR_DATA)
|
||||||
|
|
||||||
await self.async_send_message(**kwargs)
|
await self.async_send_message(**kwargs)
|
||||||
@ -229,12 +229,12 @@ async def async_setup(hass, config):
|
|||||||
payload = {}
|
payload = {}
|
||||||
message = service.data[ATTR_MESSAGE]
|
message = service.data[ATTR_MESSAGE]
|
||||||
message.hass = hass
|
message.hass = hass
|
||||||
payload[ATTR_MESSAGE] = message.async_render()
|
payload[ATTR_MESSAGE] = message.async_render(parse_result=False)
|
||||||
|
|
||||||
title = service.data.get(ATTR_TITLE)
|
title = service.data.get(ATTR_TITLE)
|
||||||
if title:
|
if title:
|
||||||
title.hass = hass
|
title.hass = hass
|
||||||
payload[ATTR_TITLE] = title.async_render()
|
payload[ATTR_TITLE] = title.async_render(parse_result=False)
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
pn.DOMAIN, pn.SERVICE_CREATE, payload, blocking=True
|
pn.DOMAIN, pn.SERVICE_CREATE, payload, blocking=True
|
||||||
|
@ -119,7 +119,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|||||||
if title is not None:
|
if title is not None:
|
||||||
try:
|
try:
|
||||||
title.hass = hass
|
title.hass = hass
|
||||||
title = title.async_render()
|
title = title.async_render(parse_result=False)
|
||||||
except TemplateError as ex:
|
except TemplateError as ex:
|
||||||
_LOGGER.error("Error rendering title %s: %s", title, ex)
|
_LOGGER.error("Error rendering title %s: %s", title, ex)
|
||||||
title = title.template
|
title = title.template
|
||||||
@ -128,7 +128,7 @@ async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
message.hass = hass
|
message.hass = hass
|
||||||
message = message.async_render()
|
message = message.async_render(parse_result=False)
|
||||||
except TemplateError as ex:
|
except TemplateError as ex:
|
||||||
_LOGGER.error("Error rendering message %s: %s", message, ex)
|
_LOGGER.error("Error rendering message %s: %s", message, ex)
|
||||||
message = message.template
|
message = message.template
|
||||||
|
@ -84,7 +84,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
|
|
||||||
if resource_template is not None:
|
if resource_template is not None:
|
||||||
resource_template.hass = hass
|
resource_template.hass = hass
|
||||||
resource = resource_template.render()
|
resource = resource_template.render(parse_result=False)
|
||||||
|
|
||||||
if value_template is not None:
|
if value_template is not None:
|
||||||
value_template.hass = hass
|
value_template.hass = hass
|
||||||
@ -189,6 +189,6 @@ class RestBinarySensor(BinarySensorEntity):
|
|||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Get the latest data from REST API and updates the state."""
|
"""Get the latest data from REST API and updates the state."""
|
||||||
if self._resource_template is not None:
|
if self._resource_template is not None:
|
||||||
self.rest.set_url(self._resource_template.render())
|
self.rest.set_url(self._resource_template.render(parse_result=False))
|
||||||
|
|
||||||
await self.rest.async_update()
|
await self.rest.async_update()
|
||||||
|
@ -163,7 +163,7 @@ class RestNotificationService(BaseNotificationService):
|
|||||||
key: _data_template_creator(item) for key, item in value.items()
|
key: _data_template_creator(item) for key, item in value.items()
|
||||||
}
|
}
|
||||||
value.hass = self._hass
|
value.hass = self._hass
|
||||||
return value.async_render(kwargs)
|
return value.async_render(kwargs, parse_result=False)
|
||||||
|
|
||||||
data.update(_data_template_creator(self._data_template))
|
data.update(_data_template_creator(self._data_template))
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
|
|
||||||
if resource_template is not None:
|
if resource_template is not None:
|
||||||
resource_template.hass = hass
|
resource_template.hass = hass
|
||||||
resource = resource_template.render()
|
resource = resource_template.render(parse_result=False)
|
||||||
|
|
||||||
if username and password:
|
if username and password:
|
||||||
if config.get(CONF_AUTHENTICATION) == HTTP_DIGEST_AUTHENTICATION:
|
if config.get(CONF_AUTHENTICATION) == HTTP_DIGEST_AUTHENTICATION:
|
||||||
@ -202,7 +202,7 @@ class RestSensor(Entity):
|
|||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Get the latest data from REST API and update the state."""
|
"""Get the latest data from REST API and update the state."""
|
||||||
if self._resource_template is not None:
|
if self._resource_template is not None:
|
||||||
self.rest.set_url(self._resource_template.render())
|
self.rest.set_url(self._resource_template.render(parse_result=False))
|
||||||
|
|
||||||
await self.rest.async_update()
|
await self.rest.async_update()
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ class RestSwitch(SwitchEntity):
|
|||||||
|
|
||||||
async def async_turn_on(self, **kwargs):
|
async def async_turn_on(self, **kwargs):
|
||||||
"""Turn the device on."""
|
"""Turn the device on."""
|
||||||
body_on_t = self._body_on.async_render()
|
body_on_t = self._body_on.async_render(parse_result=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
req = await self.set_device_state(body_on_t)
|
req = await self.set_device_state(body_on_t)
|
||||||
@ -178,7 +178,7 @@ class RestSwitch(SwitchEntity):
|
|||||||
|
|
||||||
async def async_turn_off(self, **kwargs):
|
async def async_turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
body_off_t = self._body_off.async_render()
|
body_off_t = self._body_off.async_render(parse_result=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
req = await self.set_device_state(body_off_t)
|
req = await self.set_device_state(body_off_t)
|
||||||
|
@ -93,17 +93,22 @@ async def async_setup(hass, config):
|
|||||||
payload = None
|
payload = None
|
||||||
if template_payload:
|
if template_payload:
|
||||||
payload = bytes(
|
payload = bytes(
|
||||||
template_payload.async_render(variables=service.data), "utf-8"
|
template_payload.async_render(
|
||||||
|
variables=service.data, parse_result=False
|
||||||
|
),
|
||||||
|
"utf-8",
|
||||||
)
|
)
|
||||||
|
|
||||||
request_url = template_url.async_render(variables=service.data)
|
request_url = template_url.async_render(
|
||||||
|
variables=service.data, parse_result=False
|
||||||
|
)
|
||||||
|
|
||||||
headers = None
|
headers = None
|
||||||
if template_headers:
|
if template_headers:
|
||||||
headers = {}
|
headers = {}
|
||||||
for header_name, template_header in template_headers.items():
|
for header_name, template_header in template_headers.items():
|
||||||
headers[header_name] = template_header.async_render(
|
headers[header_name] = template_header.async_render(
|
||||||
variables=service.data
|
variables=service.data, parse_result=False
|
||||||
)
|
)
|
||||||
|
|
||||||
if content_type:
|
if content_type:
|
||||||
|
@ -83,17 +83,19 @@ class RssView(HomeAssistantView):
|
|||||||
|
|
||||||
response += "<rss>\n"
|
response += "<rss>\n"
|
||||||
if self._title is not None:
|
if self._title is not None:
|
||||||
response += " <title>%s</title>\n" % escape(self._title.async_render())
|
response += " <title>%s</title>\n" % escape(
|
||||||
|
self._title.async_render(parse_result=False)
|
||||||
|
)
|
||||||
|
|
||||||
for item in self._items:
|
for item in self._items:
|
||||||
response += " <item>\n"
|
response += " <item>\n"
|
||||||
if "title" in item:
|
if "title" in item:
|
||||||
response += " <title>"
|
response += " <title>"
|
||||||
response += escape(item["title"].async_render())
|
response += escape(item["title"].async_render(parse_result=False))
|
||||||
response += "</title>\n"
|
response += "</title>\n"
|
||||||
if "description" in item:
|
if "description" in item:
|
||||||
response += " <description>"
|
response += " <description>"
|
||||||
response += escape(item["description"].async_render())
|
response += escape(item["description"].async_render(parse_result=False))
|
||||||
response += "</description>\n"
|
response += "</description>\n"
|
||||||
response += " </item>\n"
|
response += " </item>\n"
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ def _async_templatize_blocks(hass, value):
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl = template.Template(value, hass=hass)
|
tmpl = template.Template(value, hass=hass)
|
||||||
return tmpl.async_render()
|
return tmpl.async_render(parse_result=False)
|
||||||
|
|
||||||
|
|
||||||
class SlackNotificationService(BaseNotificationService):
|
class SlackNotificationService(BaseNotificationService):
|
||||||
|
@ -136,7 +136,9 @@ class TcpSensor(Entity):
|
|||||||
|
|
||||||
if self._config[CONF_VALUE_TEMPLATE] is not None:
|
if self._config[CONF_VALUE_TEMPLATE] is not None:
|
||||||
try:
|
try:
|
||||||
self._state = self._config[CONF_VALUE_TEMPLATE].render(value=value)
|
self._state = self._config[CONF_VALUE_TEMPLATE].render(
|
||||||
|
parse_result=False, value=value
|
||||||
|
)
|
||||||
return
|
return
|
||||||
except TemplateError:
|
except TemplateError:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
|
@ -329,7 +329,9 @@ async def async_setup(hass, config):
|
|||||||
else:
|
else:
|
||||||
attribute_templ.hass = hass
|
attribute_templ.hass = hass
|
||||||
try:
|
try:
|
||||||
data[attribute] = attribute_templ.async_render()
|
data[attribute] = attribute_templ.async_render(
|
||||||
|
parse_result=False
|
||||||
|
)
|
||||||
except TemplateError as exc:
|
except TemplateError as exc:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"TemplateError in %s: %s -> %s",
|
"TemplateError in %s: %s -> %s",
|
||||||
|
@ -142,7 +142,7 @@ class XiaomiCamera(Camera):
|
|||||||
"""Return a still image response from the camera."""
|
"""Return a still image response from the camera."""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host = self.host.async_render()
|
host = self.host.async_render(parse_result=False)
|
||||||
except TemplateError as exc:
|
except TemplateError as exc:
|
||||||
_LOGGER.error("Error parsing template %s: %s", self.host, exc)
|
_LOGGER.error("Error parsing template %s: %s", self.host, exc)
|
||||||
return self._last_image
|
return self._last_image
|
||||||
|
@ -108,7 +108,7 @@ async def test_sending_templated_message(hass, events):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
last_event = events[-1]
|
last_event = events[-1]
|
||||||
assert last_event.data[notify.ATTR_TITLE] == "temperature"
|
assert last_event.data[notify.ATTR_TITLE] == "temperature"
|
||||||
assert last_event.data[notify.ATTR_MESSAGE] == 10
|
assert last_event.data[notify.ATTR_MESSAGE] == "10"
|
||||||
|
|
||||||
|
|
||||||
async def test_method_forwards_correct_data(hass, events):
|
async def test_method_forwards_correct_data(hass, events):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user