Count array length

hi guys
i'm using homeassistant and node red.

i used a get-entities node to get an array of windows/doors left open.

i'm trying to create a function node that counts the array length and join the friendly name attributes into a string. if anyone could help, thanks so much.

var count = msg.payload.length
var array = join(payload.attributes.friendly_name, ", ")
return [count, array];

hmm i figured the first one out:

var newMsg = { payload: msg.payload.length };
return [newMsg, msg];

will give me the length of the array.

but not sure how to join the array together to make a string.

maybe the javascript join function ?

thanks for the suggestion!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.