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.
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
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.
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.
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.
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!