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
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 π²"
}
)
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 π²"
}
)