Action Node JSONATA not sending Telegram messages

Hi all,

Since Nov 8 my Node Red Telegram action node is not sending messages anymore. I checked everything and it looks like the format is not excepted anymore or has changed somehow. I did not got the memo and search all over the web and here but cannot find any information. I hope someone here can help me out.

This is my original code:

{
  "message": "Vandaag de laagste prijs 📉❗€ {{ states('sensor.zonneplan_lowest_price_today') | round(2) }}. De boiler zal van {{ states('sensor.tesy_current_temperature') }}°C naar 75°C stijgen 🌡️🚀",
  "title": "Laagste Prijs 💲"
}

I use this code in a action node that is configured to send telegram messages. From what I can find the problem lies in the {{ states function. Removing this and the message will send but without the states.

The sensors are working and alive in Home Assistant with exactly the same names.

I hope someone can lead me in the right direction to fix this :slight_smile:

This has been reported.

https://community.home-assistant.io/t/node-red-function-node-no-longer-working/783788/4?u=biscuit

Whilst this may have been within the J: expression as JSONata, your data object contains Jinja templating, and until recently this was being forwarded exactly as you have written it to Home Assistant, where it was being processed by the HA template engine within the notification action. This feature (Jinja templating in notifications) has apparently been removed.

At no point does JSONata deal with {{ mustache templates }}, however from within the Action node it is possible to use a JSONata function to obtain entity state values.

"Vandaag de laagste prijs 📉❗€ " &
$round($number($entities('sensor.zonneplan_lowest_price_today').state),2) &
". De boiler zal van " &
$entities('sensor.tesy_current_temperature').state &
"°C naar 75°C stijgen 🌡️🚀"

I can’t test this exactly, but $entities(‘sensor.zonneplan_lowest_price_today’).state returns the entity state value, probably as a string, hence the need to use $number() and then $round(). The ‘&’ is the JSONata string concatenation operator.

If it looks too messy in one long string, then it is possible to use a code block and variables to build the message in parts. The ~> is the JSONata function chaining operator, which also helps with visual clarity.

(
    $price:=$entities('sensor.zonneplan_lowest_price_today').state ~> $number() ~> $round(2);
    $temp:= $entities('sensor.tesy_current_temperature').state;

    {
        "message": "Vandaag de laagste prijs 📉❗€ " & $price & ". De boiler zal van " & $temp & "°C naar 75°C stijgen 🌡️🚀",
        "title": "Laagste Prijs 💲"
    }

)
1 Like

Thank you for the quick en detailed explanation! I checked the fora but could find any information regarding this problem. But now with the detailed explanation I will continue using these formats for the next action telegram nodes.

(
    $price:=$entities('sensor.zonneplan_lowest_price_today').state ~> $number() ~> $round(2);
    $temp:= $entities('sensor.tesy_current_temperature').state;

    {
        "message": "Vandaag de laagste prijs 📉❗€ " & $price & ". De boiler zal van " & $temp & "°C naar 75°C stijgen 🌡️🚀",
        "title": "Laagste Prijs 💲"
    }

)

This code is working perfectly :wink: