I try to collect active items from a todo list.
I use the call service node.
calling in HA is possible:
But nothing is collected. What amI doing wrong?
Thanks
I try to collect active items from a todo list.
I use the call service node.
calling in HA is possible:
But nothing is collected. What amI doing wrong?
Thanks
You need to set an output property.
At the bottom of the Call Service node,
Where it says ‘Output properties’
Click +Add
Set this to msg.payload (or whatever you want) = ‘results’.
This puts the results (of the service call) into the message field you defined.
Works for me!
Thanks that works!
Now I only needs to know how to create a list out of the array
An array is a list. I guess you want a string with all the summary items?
Try using a Change node after the Call service node, and set msg.payload to J: JSONata expression, then use
$join(payload.*.items.summary,", ");
This should give you a string, with each found summary separated by ', ’
At the moment I don’t think we have a $results() function for the WebSocket nodes, so we have to process any service call results in a following Change node.
Hope this helps!
Thanks again!!
I did create a function node:
var aantal = msg.aantal;
var temp = 0;
var nr = 1;
var TempLijst ="";
for (var i = 0; i < aantal; i++)
{
TempLijst += '\n '+ nr + ' ' + msg.payload["todo.boodschappen"].items[temp].summary;
if ((msg.payload["todo.boodschappen"].items[temp].description != undefined) ) {
TempLijst += ':\n ' + msg.payload["todo.boodschappen"].items[temp].description;
}
temp+=1;
nr+=1;
}
flow.set('Lijst', TempLijst);
return msg;
Creating:
string[199]
1 Fruit: mango, sinasappel
2 Vaatwasreiniger
3 Koek
4 vuilniszakken
5 kaas
6 Eten:
Kipcorn, ijsbergsla, rode ui, avocado, wraps, parmezaanse kaas
honingmosterd saus
7 verf:
Die mooie blauwe
JSONata in a change node
payload.*.items#$i.($i+1 & " " & $.summary & ($exists($.description) ? ": \n " & $.description))~>$join(" \n ")
Which does almost exactly the same, but avoids the use of ‘var’ which will cause memory leakage over time. You really do need to use ‘let’ or ‘const’ in JS!
Thanks again for your advise!