nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.41k stars 119 forks source link

Templates in message field of notifications do not work anymore #1037

Closed c-lega closed 1 month ago

c-lega commented 1 month ago

Checklist

Alarmo Version

v1.10.4

HA Version

2024.10.0

Bug description

I have many notifications triggered by all kind of alarm events. As there are many, I used a template to include the time it occurred in the message of the notification. That is not working anymore (not sure since when, but it's been at least a week or so - and I update almost instantly any update available). Now I only can used a couple of wildcards and my templates do not work. BTW I have an Android device.

Steps to reproduce

Create a new notification, set target to a mobile device, set message to any template (I sue: "{{now().strftime('%m/%d/%Y - %H:%M:%S')}}", and then press "TRY IT->" You'll see the notification in the device contains the template itself instead of the expected output.

Relevant log output

No response

hanshanderson commented 1 month ago

I can confirm the same issue, starting with the update to HA 2024.10.0

Al3xand3R360 commented 1 month ago

Same issue here since update to HA2024.10

Gifford47 commented 1 month ago

Same issue on 2024.10.1.

elbel86 commented 1 month ago

Same issue here on 2024.10.1

nielsfaber commented 1 month ago

At this point I have no idea what caused this functionality to break or how to fix it. It seems that a change in the latest HA release introduced this bug, but there is no mentioning of this in the release notes of HA. The templates are processed on the side of HA, Alarmo simply forwards the message text when executing the service. I will have to dive deeper into the recent code changes in HA to see if I can find the cause. Unfortunately this may take some time. If anyone can find some relevant information, please share.

uvjim commented 1 month ago

I don't believe this is affecting only Alarmo. I have templates set on the notify group I use; they have also stopped working. I remember reading a warning in the logs (can't find it now) about templates being deprecated. So not sure if that may have an affect. Templates seem to work if I use them in a normal automation with notify though.

update: found the message I was talking about https://github.com/home-assistant/core/issues/72287

It may not have anything to do with this, so apologies for the noise if it doesn't.

kevinsaucier commented 1 month ago

Just chiming in here with the same issue. From info on the post above, seems like HA expects the integration to process the Template and pass plain text to Notify. Odd, though, as I can call the exact same service from the Developer window and it works as expected, unless the Developer window is processing the template before actually calling Notify.

Alexa Media is a custom component. It needs to process the templates before calling the notify service. You need to report that to the custom component author.

So, this works in Developer/Actions but doesn't work with 'Try It' from Alarmo. Hmmmmm....

service: notify.notify_kevin
data:
  message: Alarm Armed to Home {{ states('sensor.date_time') }}
  title: Don't Open the Doors!
  data:
    ttl: 0
    channel: ha_info
    actions:
      - action: Disarm Alarmo
        title: Disarm Alarmo
      - action: Turn off Inside Lights
        title: Turn off Inside Lights

Also tried this, with the same results (thought maybe it had something to do with the change of Service to Action):

action: notify.notify_kevin
data:
  message: Alarm Armed to Home {{ states('sensor.date_time') }}
  title: Don't Open the Doors!
  data:
    ttl: 0
    channel: ha_info
    actions:
      - action: Disarm Alarmo
        title: Disarm Alarmo
      - action: Turn off Inside Lights
        title: Turn off Inside Lights
thenextbutton commented 1 month ago

Good Evening, apologies if this does not add anything to the conversation I was wondering what are the thoughts on this one?

I have experienced the same when upgrading to 2024.10 and have rolled back

I have the title for notifications set to {{ now().strftime('%H:%M %a %d %b %Y') }} on 2024.9 it fills in the information on 2024.10 I get the raw data.

Thanks in advance.

Schermbecker commented 1 month ago

Seems to be the same topic as seen here: https://github.com/nielsfaber/alarmo/issues/989

nielsfaber commented 1 month ago

Just a small update: I am working on this issue, so far it looks fixable from the side of Alarmo.

cmd85 commented 1 month ago

Just a small update: I am working on this issue, so far it looks fixable from the side of Alarmo.

Thank you, was just about trying to start fixing workarounds in automations or rollback but I can wait if its being looked at, no real hurry =)

Im using this style which worked to recently: {{now().strftime("%H:%M:%S")}}

nielsfaber commented 1 month ago

After research I found out that support for templates in notifications is intentionally removed in the HA 2024.10 release, see https://github.com/home-assistant/core/pull/122820. The PR description states that templates can only be used in scripts/automations from now on, not in other integrations. This was marked as breaking change but not mentioned in the release notes of HA.

I will keep digging and see if I can make some workaround, but I have to say I'm very surprised by this PR as well as the lack of communication of the change.

Schermbecker commented 1 month ago

@nielsfaber thank you so much for your effort! Alarmo is a great tool, I love it 😍

Alarmo provides properties "bypassed_sonsors" and "open_sensors" in its actions. I print this information into the appropriate notifications.

To do so I use template scripting just for an IF statement - to insert an additional label in case there are open or bypassed sensors.

Now (without the IF) the labels are always inserted, even if the properties are empty. So no big issue at all.

nielsfaber commented 1 month ago

This issue should be resolved in the v1.10.6 release.

c-lega commented 1 month ago

@nielsfaber Thank you!... +1 for your effort!... It works, but had to recreate all actions due to a bug that just confirmed... it doesn't let you modify and the save (or even "Try it" after initial save).

thenextbutton commented 1 month ago

Thank you so much for resolving this. Much appreciated