Fix body text of imap message not available in custom event data template (#139609)

This commit is contained in:
Jan Bouwhuis 2025-03-02 05:00:22 +01:00 committed by Bram Kragten
parent 3690e03951
commit 6abdb28a03
2 changed files with 3 additions and 2 deletions

View File

@ -280,7 +280,7 @@ class ImapDataUpdateCoordinator(DataUpdateCoordinator[int | None]):
if self.custom_event_template is not None:
try:
data["custom"] = self.custom_event_template.async_render(
data, parse_result=True
data | {"text": message.text}, parse_result=True
)
_LOGGER.debug(
"IMAP custom template (%s) for msguid %s (%s) rendered to: %s, initial: %s",

View File

@ -726,9 +726,10 @@ async def test_message_data(
[
("{{ subject }}", "Test subject", None),
('{{ "@example.com" in sender }}', True, None),
('{{ "body" in text }}', True, None),
("{% bad template }}", None, "Error rendering IMAP custom template"),
],
ids=["subject_test", "sender_filter", "template_error"],
ids=["subject_test", "sender_filter", "body_filter", "template_error"],
)
async def test_custom_template(
hass: HomeAssistant,