Update to 2024.10 broke notifications / template rendering

Hi there,

I use state nodes exporting values to msg. messages mainly but I am also using template nodes to manage complete sentences to send to mobile phones or Alexa TTS.
Since 2024.10 I’m getting the code and not the values in place of the states.
Example:

I’m aware that I can probably go to dozens of nodes and change this for state nodes exporting values to msg. messages and then make the sentences but can’t this be fixed and continue to work like before?

My nodes:

Thank you very much.
Pedro.

That was a bug/exploit that allowed you to use a jinja template in NR. It’s been fixed. The only node that can resolve jinja templates in NR is the blue render template node.

image

1 Like

Thank you very much for your quick reply.

So you’re telling me that this was a “malfunction” for (don’t know exactly) but maybe 3 or 4 years? (that I have that working :smiley: )… uauuu… could it be just a “breaking change”?

It was an unintended behavior that I’d venture to guess the developers were unaware of. Jinja was never supposed to work. It’s only just came up recently with the update, that people were using jinja templates, successfully. This may have been a change to HA’s api that changed this behavior

Jijna is a templating language that sits on top of HA’s primary scripting language, python. Node red’s primary language is javascript and uses jsonata as a templating language. Templating is basically how you manipulate data.

If you plan to continue to use NR, learning how to use jsonata is advisable.

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/jsonata/

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/jsonata/jsonata-primer.html

1 Like

Jinja templates worked fine in services that supported them, but there was a breaking change that removed this functionality from the notification service. You can refer to this issue for more details:

https://github.com/home-assistant/core/pull/122820

2 Likes

oh ok, so I was right, it was a kind of hidden breaking change.

1 Like

If you need to use Jinja templates in a notification, you can use the execute_script endpoint instead of call_service. Here’s an example of how to do it using the API node:

{
   "type": "execute_script",
   "sequence": [
       {
          "action": "notify.person",
          "data": {
              "message": "{{ states('sun.sun') }}"
          }
       }
   ]
}

This way, the Jinja template can be rendered properly within the script execution.