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

2 Likes

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

Years ago I have created this notify subflow in Node-RED:

[{"id":"bb718c62d1afd0f3","type":"subflow","name":"notify","info":"","category":"","in":[{"x":40,"y":340,"wires":[{"id":"f9ddc04f43d890ec"},{"id":"1f9c603b292db2c9"},{"id":"36b8c191ad2ab932"},{"id":"35654c5032f27a3b"},{"id":"ec0d2e29c35b9b1d"},{"id":"4e5497c27f1e19a3"},{"id":"92d3b23cb281d233"},{"id":"a1bd42ba2b3dfdbe"},{"id":"5302b362cae9da7b"},{"id":"75907596f40ebd47"},{"id":"8f97ef2a05dc6883"}]}],"out":[{"x":700,"y":340,"wires":[{"id":"89cf89a419fbac0f","port":0},{"id":"783c52cc2fda59b9","port":0},{"id":"af890dd68d83ec8b","port":0},{"id":"f6438857998b23dd","port":0},{"id":"7f772770d939f52e","port":0},{"id":"71a6ea0bf3a5dfee","port":0},{"id":"4766ef165d108a5b","port":0},{"id":"adf0d2490d35e13e","port":0},{"id":"f15367ebc354e13f","port":0},{"id":"6b57d6f02011940e","port":0},{"id":"8ffa9d7ea5dc6cc7","port":0},{"id":"65caf4b58907b71f","port":0},{"id":"c254fb95397fd161","port":0}]}],"env":[{"name":"title","type":"str","value":"Title"},{"name":"message","type":"str","value":"Textmessage"},{"name":"voice","type":"str","value":"Sprachnachricht"},{"name":"handy","type":"str","value":"Handyansage"},{"name":"imageurl","type":"str","value":"/local/images/snapshots/garden_door.jpg"},{"name":"iconurl","type":"str","value":"/local/images/notification_icons/attention.png"},{"name":"echo1","type":"bool","value":"true","ui":{"label":{"en-US":"Echo1 (Living Room)"},"type":"checkbox"}},{"name":"echo2","type":"bool","value":"true","ui":{"label":{"en-US":"Echo2 (Fitness Room)"},"type":"checkbox"}},{"name":"echodot1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot1 (Heating Room)"},"type":"checkbox"}},{"name":"echodot2","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot2 (Kitchen)"},"type":"checkbox"}},{"name":"echodot3","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot3 (Bathroom)"},"type":"checkbox"}},{"name":"echodot4","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot4 (Garage)"},"type":"checkbox"}},{"name":"echoball1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoBall1 (Bedroom)"},"type":"checkbox"}},{"name":"echopop1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoPop1 (Water Pump)"},"type":"checkbox"}},{"name":"echopop2","type":"bool","value":"true","ui":{"label":{"en-US":"EchoPop2"},"type":"checkbox"}},{"name":"mobile_notify","type":"str","value":"mobile_off","ui":{"label":{"en-US":"Mobile Notify"},"type":"select","opts":{"opts":[{"l":{"en-US":"off"},"v":"mobile_off"},{"l":{"en-US":"Action"},"v":"mobile_action"},{"l":{"en-US":"Image"},"v":"mobile_image"},{"l":{"en-US":"Text"},"v":"mobile_text"}]}}},{"name":"mobile_voice","type":"bool","value":"false","ui":{"label":{"en-US":"Mobile Voice"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action1_title","type":"str","value":"","ui":{"label":{"en-US":"Action1 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action1_uri","type":"str","value":"","ui":{"label":{"en-US":"Action1 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action2_title","type":"str","value":"","ui":{"label":{"en-US":"Action2 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action2_uri","type":"str","value":"","ui":{"label":{"en-US":"Action2 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action3_title","type":"str","value":"","ui":{"label":{"en-US":"Action3 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action3_uri","type":"str","value":"","ui":{"label":{"en-US":"Action3 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}}],"meta":{},"color":"#DDAA99"},{"id":"f9ddc04f43d890ec","type":"switch","z":"bb718c62d1afd0f3","name":"echo1 ON?","property":"echo1","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":100,"wires":[["89cf89a419fbac0f"],[]]},{"id":"89cf89a419fbac0f","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starecho1","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starecho1\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":480,"y":100,"wires":[[]]},{"id":"1f9c603b292db2c9","type":"switch","z":"bb718c62d1afd0f3","name":"echo2 ON?","property":"echo2","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":250,"y":160,"wires":[["783c52cc2fda59b9"],[]]},{"id":"783c52cc2fda59b9","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starecho2","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starecho2\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":480,"y":160,"wires":[[]]},{"id":"36b8c191ad2ab932","type":"switch","z":"bb718c62d1afd0f3","name":"echodot1 ON?","property":"echodot1","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":220,"wires":[["af890dd68d83ec8b"],[]]},{"id":"af890dd68d83ec8b","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechodot1","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechodot1\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":490,"y":220,"wires":[[]]},{"id":"35654c5032f27a3b","type":"switch","z":"bb718c62d1afd0f3","name":"echodot2 ON?","property":"echodot2","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":280,"wires":[["f6438857998b23dd"],[]]},{"id":"f6438857998b23dd","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechodot2","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechodot2\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":490,"y":280,"wires":[[]]},{"id":"ec0d2e29c35b9b1d","type":"switch","z":"bb718c62d1afd0f3","name":"echodot3 ON?","property":"echodot3","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":340,"wires":[["6b57d6f02011940e"],[]]},{"id":"7f772770d939f52e","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechodot4","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechodot4\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":490,"y":400,"wires":[[]]},{"id":"adf0d2490d35e13e","type":"api-call-service","z":"bb718c62d1afd0f3","name":"mobile_voice","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": \"TTS\",\t   \"data\": {\"ttl\": 0, \"tts_text\": $env('handy'), \"priority\": \"high\"} \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":490,"y":820,"wires":[[]]},{"id":"4766ef165d108a5b","type":"api-call-service","z":"bb718c62d1afd0f3","name":"mobile_text","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{ \"title\": $env('title'), \"message\": $env('message'), \"data\": {\"sticky\":\"true\",\"color\":\"red\",\"ttl\":1,\"priority\":\"high\",\"icon_url\":$env('iconurl')} }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":490,"y":760,"wires":[[]]},{"id":"71a6ea0bf3a5dfee","type":"api-call-service","z":"bb718c62d1afd0f3","name":"mobile_image","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{ \"title\": $env('title'), \"message\": $env('message'), \"data\": {\"sticky\":\"true\",\"color\":\"red\",\"ttl\":1,\"priority\":\"high\",\"image\":$env('imageurl')} }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":500,"y":700,"wires":[[]]},{"id":"4e5497c27f1e19a3","type":"switch","z":"bb718c62d1afd0f3","name":"mobile_voice ON?","property":"mobile_voice","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":780,"wires":[["adf0d2490d35e13e"],[]]},{"id":"92d3b23cb281d233","type":"switch","z":"bb718c62d1afd0f3","name":"mobile_notify","property":"mobile_notify","propertyType":"env","rules":[{"t":"eq","v":"mobile_action","vt":"str"},{"t":"eq","v":"mobile_image","vt":"str"},{"t":"eq","v":"mobile_text","vt":"str"},{"t":"eq","v":"mobile_off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":680,"wires":[["f15367ebc354e13f"],["71a6ea0bf3a5dfee"],["4766ef165d108a5b"],[]]},{"id":"f15367ebc354e13f","type":"api-call-service","z":"bb718c62d1afd0f3","name":"mobile_action","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"title\": $env('title'),\t   \"message\": $env('message'),\t   \"data\": {\t       \"sticky\":\"true\",\t       \"color\":\"red\",\t       \"ttl\":1,\t       \"priority\":\"high\",\t       \"image\":$env('imageurl'),\t       \"actions\": [\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action1_title'),\t               \"uri\": $env('action1_uri')\t            },\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action2_title'),\t               \"uri\": $env('action2_uri')\t            },\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action3_title'),\t               \"uri\": $env('action3_uri')\t            }\t        ]    \t   } \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":500,"y":640,"wires":[[]]},{"id":"a1bd42ba2b3dfdbe","type":"switch","z":"bb718c62d1afd0f3","name":"echodot4 ON?","property":"echodot4","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":400,"wires":[["7f772770d939f52e"],[]]},{"id":"6b57d6f02011940e","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechodot3","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechodot3\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":490,"y":340,"wires":[[]]},{"id":"5302b362cae9da7b","type":"switch","z":"bb718c62d1afd0f3","name":"echoball1 ON?","property":"echoball1","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":460,"wires":[["8ffa9d7ea5dc6cc7"],[]]},{"id":"8ffa9d7ea5dc6cc7","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechoball1","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechoball1\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":490,"y":460,"wires":[[]]},{"id":"75907596f40ebd47","type":"switch","z":"bb718c62d1afd0f3","name":"echopop1 ON?","property":"echopop1","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":520,"wires":[["65caf4b58907b71f"],[]]},{"id":"65caf4b58907b71f","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechopop1","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechopop1\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":500,"y":520,"wires":[[]]},{"id":"8f97ef2a05dc6883","type":"switch","z":"bb718c62d1afd0f3","name":"echopop2 ON?","property":"echopop2","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":580,"wires":[["c254fb95397fd161"],[]]},{"id":"c254fb95397fd161","type":"api-call-service","z":"bb718c62d1afd0f3","name":"starechopop2","server":"3ea003e9.8319ac","version":7,"debugenabled":false,"action":"notify.alexa_media","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": $env('voice'),\t   \"title\": $env('title'),\t   \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t   \"target\": [\t       \"starechopop2\"\t   ] \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":500,"y":580,"wires":[[]]},{"id":"3ea003e9.8319ac","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

A typical call looked like this:

where the $env(‘voice’) variable is set in this example via the GUI to

The temperature is {{ states(‘sensor.starnetatmo_indoor1_temperature’) | replace(‘.’, ’ Komma ') }} degree Celsius

This has been working for a long time. Unfortunately, the in this thread mentioned update broke it such that {{ states(‘sensor.starnetatmo_indoor1_temperature’) | replace(‘.’, ’ Komma ') }} isn’t replaced by the value of the temperature sensor anymore.

Any ideas or hints how to solve this problem would be great.

Thanks in advance and kind regards!

Yes - as noted in the discussion thread, your subflow UI includes templates and the HA notification engine was pre-processing templates sent in call parameters, from inside HA. This unofficial arrangement has been fixed (ie removed) so it no longer works.

You now have to either use a Render Template node to process templates, or switch to using JSONata.

The JSONata required is basic:

"The temperature is " &
$replace($entities('sensor.starnetatmo_indoor1_temperature').state,",", " Komma ") & " degree Celcius"

and with the $entities() function would work quite well inside any WebSocket node, so you could use a Current State node just as a means to do this.

Subflows do not permit JSONata within the properties definition. They don’t even accept msg.fields. Flow tabs (both main and sub) permit setting Environment variables but these can only be read, not set, from within the flow, and for subflows can only be set to literals not variables. Env variables are really intended as immutable pre-declared global settings.

The following JSONata should independently create the input parameter string you want, but you will have to use this in a Change node prior to calling the subflow.

(
    $e:=$globalContext('homeassistant').homeAssistant.states.'sensor.starnetatmo_indoor1_temperature'.state;
    "The temperature is " & $replace($e,",", " Komma ") & " degree celcius";
)

Subflows are OK with UI settings, but can be made much more flexible if the code inside the flow accepts msg.payload (or something like msg.input) as an object with the subflow input parameters in the various fields eg

msg.input = {"voice": "my string"}

Then instead of referring to $env(‘voice’) inside the subflow, use msg.input.voice instead. The most advanced option is to accept both - capture the $env(‘variable’) first, then check to see if msg.input.variable exists, and use that instead.

I had a look at your flow and have had a go at changing this for you. This is just a suggestion, and you will have to make the necessary changes to get it to work [you will have to move the ‘standard notification’ action node into the flow] but I have used JSONata to iterate through the UI Boolean switches and create an array of Actions (service calls). This refactors most of the flow to use just one Action node, as it appears that most of the Action nodes use the same code but just with a different target.

In this I have picked up input.voice from the input message rather than the environment variable, and I have added a change node up front to pre-create the msg.input.voice field. This should solve your original issue…

I can’t really test this, so it comes with no guarantees whatsoever, but I hope it gives you some good ideas

[{"id":"bb718c62d1afd0f3","type":"subflow","name":"notify","info":"","category":"","in":[{"x":40,"y":320,"wires":[{"id":"4e5497c27f1e19a3"},{"id":"92d3b23cb281d233"},{"id":"55da7e45e1a70750"}]}],"out":[{"x":780,"y":520,"wires":[{"id":"71a6ea0bf3a5dfee","port":0},{"id":"4766ef165d108a5b","port":0},{"id":"adf0d2490d35e13e","port":0},{"id":"f15367ebc354e13f","port":0}]},{"x":1160,"y":320,"wires":[{"id":"7d853c0fe3952bf4","port":0}]}],"env":[{"name":"title","type":"str","value":"Title"},{"name":"message","type":"str","value":"Textmessage"},{"name":"voice","type":"str","value":"Sprachnachricht"},{"name":"handy","type":"str","value":"Handyansage"},{"name":"imageurl","type":"str","value":"/local/images/snapshots/garden_door.jpg"},{"name":"iconurl","type":"str","value":"/local/images/notification_icons/attention.png"},{"name":"echo1","type":"bool","value":"true","ui":{"label":{"en-US":"Echo1 (Living Room)"},"type":"checkbox"}},{"name":"echo2","type":"bool","value":"true","ui":{"label":{"en-US":"Echo2 (Fitness Room)"},"type":"checkbox"}},{"name":"echodot1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot1 (Heating Room)"},"type":"checkbox"}},{"name":"echodot2","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot2 (Kitchen)"},"type":"checkbox"}},{"name":"echodot3","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot3 (Bathroom)"},"type":"checkbox"}},{"name":"echodot4","type":"bool","value":"true","ui":{"label":{"en-US":"EchoDot4 (Garage)"},"type":"checkbox"}},{"name":"echoball1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoBall1 (Bedroom)"},"type":"checkbox"}},{"name":"echopop1","type":"bool","value":"true","ui":{"label":{"en-US":"EchoPop1 (Water Pump)"},"type":"checkbox"}},{"name":"echopop2","type":"bool","value":"true","ui":{"label":{"en-US":"EchoPop2"},"type":"checkbox"}},{"name":"mobile_notify","type":"str","value":"mobile_off","ui":{"label":{"en-US":"Mobile Notify"},"type":"select","opts":{"opts":[{"l":{"en-US":"off"},"v":"mobile_off"},{"l":{"en-US":"Action"},"v":"mobile_action"},{"l":{"en-US":"Image"},"v":"mobile_image"},{"l":{"en-US":"Text"},"v":"mobile_text"}]}}},{"name":"mobile_voice","type":"bool","value":"false","ui":{"label":{"en-US":"Mobile Voice"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action1_title","type":"str","value":"","ui":{"label":{"en-US":"Action1 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action1_uri","type":"str","value":"","ui":{"label":{"en-US":"Action1 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action2_title","type":"str","value":"","ui":{"label":{"en-US":"Action2 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action2_uri","type":"str","value":"","ui":{"label":{"en-US":"Action2 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action3_title","type":"str","value":"","ui":{"label":{"en-US":"Action3 Title"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}},{"name":"action3_uri","type":"str","value":"","ui":{"label":{"en-US":"Action3 URI"},"type":"input","opts":{"types":["str","num","bool","json","bin","env","conf-types"]}}}],"meta":{},"color":"#DDAA99"},{"id":"adf0d2490d35e13e","type":"api-call-service","z":"bb718c62d1afd0f3","d":true,"name":"mobile_voice","server":"","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"message\": \"TTS\",\t   \"data\": {\"ttl\": 0, \"tts_text\": $env('handy'), \"priority\": \"high\"} \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":510,"y":640,"wires":[[]]},{"id":"4766ef165d108a5b","type":"api-call-service","z":"bb718c62d1afd0f3","d":true,"name":"mobile_text","server":"","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{ \"title\": $env('title'), \"message\": $env('message'), \"data\": {\"sticky\":\"true\",\"color\":\"red\",\"ttl\":1,\"priority\":\"high\",\"icon_url\":$env('iconurl')} }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":510,"y":580,"wires":[[]]},{"id":"71a6ea0bf3a5dfee","type":"api-call-service","z":"bb718c62d1afd0f3","d":true,"name":"mobile_image","server":"","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{ \"title\": $env('title'), \"message\": $env('message'), \"data\": {\"sticky\":\"true\",\"color\":\"red\",\"ttl\":1,\"priority\":\"high\",\"image\":$env('imageurl')} }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":520,"y":520,"wires":[[]]},{"id":"4e5497c27f1e19a3","type":"switch","z":"bb718c62d1afd0f3","name":"mobile_voice ON?","property":"mobile_voice","propertyType":"env","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":600,"wires":[["adf0d2490d35e13e"],[]]},{"id":"92d3b23cb281d233","type":"switch","z":"bb718c62d1afd0f3","name":"mobile_notify","property":"mobile_notify","propertyType":"env","rules":[{"t":"eq","v":"mobile_action","vt":"str"},{"t":"eq","v":"mobile_image","vt":"str"},{"t":"eq","v":"mobile_text","vt":"str"},{"t":"eq","v":"mobile_off","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":270,"y":500,"wires":[["f15367ebc354e13f"],["71a6ea0bf3a5dfee"],["4766ef165d108a5b"],[]]},{"id":"f15367ebc354e13f","type":"api-call-service","z":"bb718c62d1afd0f3","d":true,"name":"mobile_action","server":"","version":7,"debugenabled":false,"action":"notify.mobile_app_starmobile","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"{\t   \"title\": $env('title'),\t   \"message\": $env('message'),\t   \"data\": {\t       \"sticky\":\"true\",\t       \"color\":\"red\",\t       \"ttl\":1,\t       \"priority\":\"high\",\t       \"image\":$env('imageurl'),\t       \"actions\": [\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action1_title'),\t               \"uri\": $env('action1_uri')\t            },\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action2_title'),\t               \"uri\": $env('action2_uri')\t            },\t           {\t               \"action\": \"URI\",\t               \"title\": $env('action3_title'),\t               \"uri\": $env('action3_uri')\t            }\t        ]    \t   } \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"mobile_app_starmobile","x":520,"y":460,"wires":[[]]},{"id":"55da7e45e1a70750","type":"change","z":"bb718c62d1afd0f3","name":"Check all echos and build Data field","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t    $voice:=input.voice;\t    $title:=input.title;\t\t    $echoList:=[\t        {\"env\": \"echo1\", \"target\": \"starecho1\"},\t        {\"env\": \"echo2\", \"target\": \"starecho2\"},\t        {\"env\": \"echodot1\", \"target\": \"starechodot1\"},\t        {\"env\": \"echodot2\", \"target\": \"starechodot2\"},\t        {\"env\": \"echodot3\", \"target\": \"starechodot3\"},\t        {\"env\": \"echodot4\", \"target\": \"starechodot4\"},\t        {\"env\": \"echoball1\", \"target\": \"starechoball1\"},\t        {\"env\": \"echopop1\", \"target\": \"starechopop1\"},\t        {\"env\": \"echopop2\", \"target\": \"starechopop2\"}\t    ];\t    $echoList.(\t        $env($.env) ? {\t            \"message\": $voice,\t            \"title\": $title,\t            \"data\": { \"type\": \"announce\", \"method\": \"all\" },\t            \"target\": [ $.target ] }\t    )[]\t\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":320,"wires":[["7d853c0fe3952bf4"]]},{"id":"78adae9edd6cb682","type":"api-call-service","z":"bb718c62d1afd0f3","d":true,"name":"Standard Notification","server":"","version":7,"debugenabled":false,"action":"","floorId":[],"areaId":[],"deviceId":[],"entityId":[],"labelId":[],"data":"payload","dataType":"jsonata","mergeContext":"","mustacheAltTags":true,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"notify","service":"alexa_media","x":900,"y":280,"wires":[[]]},{"id":"7d853c0fe3952bf4","type":"split","z":"bb718c62d1afd0f3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"payload","x":610,"y":320,"wires":[[]]},{"id":"bf87e134764267d2","type":"subflow:bb718c62d1afd0f3","z":"dc25556591dc08be","name":"","env":[{"name":"echo1","type":"bool","value":"false"},{"name":"echo2","type":"bool","value":"false"},{"name":"echodot1","type":"bool","value":"false"},{"name":"echodot3","type":"bool","value":"false"},{"name":"echodot4","type":"bool","value":"false"},{"name":"echoball1","type":"bool","value":"false"},{"name":"echopop2","type":"bool","value":"false"}],"x":670,"y":140,"wires":[[],["3fe4b17b4b21fcce"]]},{"id":"0d6d2dc455173b81","type":"change","z":"dc25556591dc08be","name":"Get Voice","rules":[{"t":"set","p":"input.title","pt":"msg","to":"The Title","tot":"str"},{"t":"set","p":"input.voice","pt":"msg","to":"(\t    $e:=$globalContext('homeassistant').homeAssistant.states.'sensor.starnetatmo_indoor1_temperature'.state;\t    \"The temperature is \" & $replace($e, \",\", \" Komma \") & \" degrees celcius\";\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":140,"wires":[["bf87e134764267d2"]]},{"id":"132c240793b14eaf","type":"inject","z":"dc25556591dc08be","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":290,"y":140,"wires":[["0d6d2dc455173b81"]]},{"id":"3fe4b17b4b21fcce","type":"debug","z":"dc25556591dc08be","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":860,"y":140,"wires":[]}]

Many other solutions are also available.

Dear Biscuit,

thank you very much for your extensive reply!

I have tried it in a hurry but it didn’t work. I will a closer look tomorrow night because I am pretty busy with stuff (deadline is tomorrow) for work.

Again, thank you very much!