Notify.send_message in UI does not evaluate template

I have a grid card with 3 buttons defined.
Buttons: [Sun seen] [Sun in shadow] [Sun not seen]
The button reads the current sun azimuth and elevation and prints it to file together with a string based on the button option (yes/no/shadow).

I did this with the old notify service which has worked for a long time and still does. However when trying to migrate to the new “notify.send_message” action the sensor values are no longer evaluated. Instead of printing the following expected value to file:

2024-10-19T12:00:00+00:00 , sun, 180,50, yes

it prints:

2024-10-19T12:00:00+00:00 , sun, {{states(‘sensor.sun_current_azimuth’)}},{{states(‘sensor.sun_current_elevation’)}}, yes

New code:

square: false
type: grid
cards:
  - show_name: true
    show_icon: false
    type: button
    tap_action:
      action: perform-action
      target:
        entity_id: notify.sky_basementview
      perform_action: notify.send_message
      data:
        message: >-
          , sun,
          "{{states('sensor.sun_current_azimuth')}}","{{states('sensor.sun_current_elevation')}}",
          yes 
    name: Sun seen
    icon: mdi:white-balance-sunny

Old code:

square: false
type: grid
cards:
  - show_name: true
    show_icon: false
    type: button
    tap_action:
      action: perform-action
      target: {}
      perform_action: notify.sky_basementview
      data:
        message: >-
          , sun,
          {{states('sensor.sun_current_azimuth')}},{{states('sensor.sun_current_elevation')}},
          yes 
    name: Sun seen
    icon: mdi:white-balance-sunny

Until this is fixed, I can not replace my old notify services with the new notify.send_message actions.

Home Assistant Version:

  • Core2024.9.3
  • Frontend20240909.1

Which notification integration are you using?

Has it been updated to use the new method?

Very few have.

The button card tap action has never supported templates.

The way to do this is to perform your actions in a script, as they support templates. Then call the script from your tap action.

notify.sky_basementview is defined as follows in configuration.yaml:

notify:
  - name: sky_basementview
    platform: file
    filename: sky_basementview.log
    timestamp: true

The “old code” above gives me what I want. It doesn’t require a script to print the sensor values to the file.

Which does not change the fact that you were doing something that was not supported.

https://www.home-assistant.io/dashboards/actions/#limitations