Help needed to fix a problem

Hi there,

Correct me if I’m wrong.
Just installed HA Core 2024.10.0 and my Node-RED gives me wrong messages to my phone.
Where it should be like this:
P 1 BDH-03 (Middel BR) BR woning (parkeergarage) Fagelstraat Katwijk ZH 16-9199
it now shows:
{{states.sensor.middel.state}}

When looking into Node-RED everything seems normal, and I also updated the flows.
Can someone help me with this?

I just installed HA Core 2024.10.0 and my Node-RED companion integration (v4.0.0) would not load on HA restart (hence no NR entities in HA) so had to update that to 4.1.1

I updated NR yesterday to the latest version and I am see a similar issue. I am just trying to find out where they are failing and so far the alerts that I have going through a Change Node are not working, but they work fine in the template editor.

image

I rolled back to 18.0.5 and it still has the same issue so it could be related to the latest version of HA 2024.10.0.

So it appears to be related to the latest update to core and not with NodeRed - here

I have the same issue
and rolling back HA to 2024.09.x resolves the issue
which is weird to me as the function occurs within NodeRed in the function node
and passes the output

clearly its somehow affected by HA 2024.10
but why/how just doesn’t make sense to me

Did you update Alexa media player to 4.13.3 ?

If yes, this is certainly the reason of your problem.

You are trying to use a jinja template, it’s not going to return a value in NR.

{{states.sensor.particulate_matter...}}

NR uses jsonata, retrieving home assistant sensor data in a change node can only be done through the global object. It’s easier to get the state of another sensor inside a HA web socket node using the $entities() variable.

$entities('sensor.some_sensor').attributes.some_value

A quick explanation of jsonata

More detailed guides

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

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

Hi there,

I’m facing a very similar issue with resolving templates, but in my case, it’s happening in notifications sent through Node-RED. Before the latest Home Assistant update, I was able to include dynamic sensor values in my notification messages using templates like {{ states('sensor.inverter_dzienna_produkcja') }}, and they worked fine. However, after updating, the variables are no longer being resolved and are instead showing as plaintext in the notifications.

I’ve also posted about my issue in this thread:
Issue with Variables in Notifications Not Working After Update

If anyone has found a solution or workaround, it would be great to hear about it!

Thanks!

I don’t think this was ever intended to work. I’ve not come across it in the documentation. It seems to have been a bug that has been corrected.

To access states using mustache templates you would use

{{entity.sensor.inverter_dzienna_produkcja}}

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

Mustache templates are limited in use, jsonata is native to nodered and will give you more flexibility especially with numbers.

1 Like

Your solution helped with displaying individual variables, thank you Mikefila!

However, I’m now wondering if there’s no longer any way to handle more complex template logic like if/elif structures and other functionality that used to be possible? Previously, I was able to include multi-line Jinja templates within my notifications to handle dynamic content based on multiple conditions (for example, dishwasher program status), but it seems that this might not be supported anymore.

Is there any workaround for handling more complex logic in the new update?

{
   "title": "Zmywarka pracuje - {{states('sensor.zmywarka_do_naczyn_program_progress')}} %",
   "message": "{% set end_time = as_datetime(states('sensor.zmywarka_do_naczyn_remaining_program_time')) %}\n\
{% set now = now() %}\n\
{% set remaining_time = (end_time - now).total_seconds() %}\n\
{% if remaining_time > 0 %}\n\
  {% set hours = (remaining_time // 3600) | int %}\n\
  {% set minutes = ((remaining_time % 3600) // 60) | int %}\n\
  {% if hours > 0 %}\n\
    Pozostało {{ hours }} {{ 'godzin' if hours > 1 else 'godzina' }}, {{ minutes }} {{ 'minut' if minutes != 1 else 'minuta' }}\n\
  {% else %}\n\
    Pozostało {{ minutes }} {{ 'minut' if minutes != 1 else 'minuta' }}\n\
  {% endif %}\n\
{% endif %},\n\
koniec o {{ as_timestamp(states('sensor.zmywarka_do_naczyn_remaining_program_time')) | timestamp_custom('%H:%M', true) }}.<br>\n\
{% if is_state('switch.zmywarka_do_naczyn_program_auto2', 'on') %}Program Auto\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_eco50', 'on') %}Program Eco 50°C\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_glas40', 'on') %}Program Szkło 40°C\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_intensiv70', 'on') %}Program Intensywny 70°C\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_machinecare', 'on') %}Program MachineCare\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_prerinse', 'on') %}Program Wstępne płukanie\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_quick45', 'on') %}Program Szybki 45°C\n\
{% elif is_state('switch.zmywarka_do_naczyn_program_quick65', 'on') %}Program Szybki 65°C\n\
{% else %}Żaden program nie jest aktywny{% endif %}",
   "data": {
       "color": "#1565c0",
       "notification_icon": "mdi:dishwasher",
       "persistent": true,
       "tag": "zmywarka",
       "sticky": true,
       "alert_once": true,
       "notification_id": "zmywarka"
    }
}

Complex logic is typically written in javascript and executed in a function node. The HA template node is made to render jinja templates, using templates there will always work.

If you continue with NR I’d encourage embracing javascript and jsonata as that is it’s native language.

image

1 Like

Mikefila thanks for the reply! It works perfectly now. I’ve adjusted my notifications using the template node in Node-RED, and they are working as expected. Thanks again for the help!

1 Like