Examples for using the new Get Entities node

With the release of version 0.5.0 of node-red-contrib-home-assistant-websocket a new node was introduced.

Here are three examples of how one might use the new get entities node.

Example #1

You have a presence detection of some sort running in Home Assistant and you want to get a notification when you leave if any doors or windows are left open.

Using the get entities node here to get a possible list of entity ids [binary_sensor.front_door, binary_sensor.back_door, binary_sensor.front_window, binary_sensor.back_window] if their state is equal to open. The entities are returned with the output Split. This means that a message is sent for each valid entity. We then are using a template node to format the payload into the entity friendly name and joining them back into one payload using the join node.

[{"id":"22439fca.156c1","type":"trigger-state","z":"74ddc16c.19655","name":"Left Home","server":"351c96ee.9dc3aa","entityid":"device_tracker.jason","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"9i2c9sz7d3e","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"home"},{"id":"3h3lghs8xsm","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"not_home"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":102,"y":928,"wires":[["24ecbd00.7147a4"],[]]},{"id":"24ecbd00.7147a4","type":"ha-get-entities","z":"74ddc16c.19655","server":"351c96ee.9dc3aa","name":"","rules":[{"property":"entity_id","logic":"includes","value":"binary_sensor.front_door,binary_sensor.back_door,binary_sensor.front_window,binary_sensor.back_window","valueType":"str"},{"property":"state","logic":"is","value":"open","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":268,"y":928,"wires":[["2fe88645.50ce3a"]]},{"id":"2fe88645.50ce3a","type":"template","z":"74ddc16c.19655","name":"Format Friendly Name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":472,"y":928,"wires":[["792cffb3.55b65"]]},{"id":"792cffb3.55b65","type":"join","z":"74ddc16c.19655","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":642,"y":928,"wires":[["c829053e.128658"]]},{"id":"c829053e.128658","type":"api-call-service","z":"74ddc16c.19655","name":"Notify","server":"351c96ee.9dc3aa","service_domain":"notify","service":"push_jason","data":"{\"message\": \"The {{payload}} are open.\",\"title\": \"Left Open\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":770,"y":928,"wires":[[]]}]

Example #2

Sort of a Vacation or Away script to randomly turn on some lights around your home.

Using an inject node here but you could use your own preference of timer node. The get entities node is randomly choosing one entity from the criteria where entity_id starts with light..

[{"id":"66c50c00.a3c8c4","type":"inject","z":"74ddc16c.19655","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":112,"y":1056,"wires":[["87111b5d.423eb8"]]},{"id":"87111b5d.423eb8","type":"ha-get-entities","z":"74ddc16c.19655","server":"351c96ee.9dc3aa","name":"","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"}],"output_type":"random","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":262,"y":1056,"wires":[["f1234263.eed69"]]},{"id":"541ec87b.02a788","type":"delay","z":"74ddc16c.19655","name":"","pauseType":"random","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"20","randomLast":"30","randomUnits":"minutes","drop":false,"x":592,"y":1056,"wires":[["5cec6ee6.cfa5a"]]},{"id":"f1234263.eed69","type":"api-call-service","z":"74ddc16c.19655","name":"Turn on Light","server":"351c96ee.9dc3aa","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"","output_location_type":"none","x":422,"y":1056,"wires":[["541ec87b.02a788"]]},{"id":"5cec6ee6.cfa5a","type":"api-call-service","z":"74ddc16c.19655","name":"Turn off Light","server":"351c96ee.9dc3aa","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":758,"y":1056,"wires":[[]]}]

Example #3

On Reddit the other day a user posted this How can I join 1 to 4 pre-defined messages together based on 4 separate entity states? (Their solution can be found in the post)

Here’s my take on it using the get entities and a function node. Using the Array output option here.

[{"id":"531d586f.103188","type":"server-state-changed","z":"74ddc16c.19655","name":"","server":"351c96ee.9dc3aa","entityidfilter":"binary_sensor.button_bedroom","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":196,"y":752,"wires":[["27db4cc4.71e694"]]},{"id":"27db4cc4.71e694","type":"ha-get-entities","z":"74ddc16c.19655","server":"351c96ee.9dc3aa","name":"","rules":[{"property":"entity_id","logic":"includes","value":"sensor.phon_charging,sensor.watch_charging,sensor.kaylas_phone_charging,lock.lock","valueType":"str"},{"property":"state","logic":"includes","value":"no,unlocked","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":470,"y":752,"wires":[["f3fe6e2f.35266"]]},{"id":"f3fe6e2f.35266","type":"function","z":"74ddc16c.19655","name":"","func":"let lockFD = null;\nlet PC = false;\nlet WC = false;\nlet KP = false;\nlet FD = false;\n\nmsg.payload.forEach(entity => {\n    switch(entity.entity_id) {\n        case \"sensor.phone_charging\":\n            PC = true;\n            break;\n        case \"sensor.watch_charging\":\n            WC = true;\n            break;\n        case \"sensor.kaylas_phone_charging\":\n            KP = true;\n            break;\n        case \"lock.lock\":\n            FD = true;\n            lockFD = { payload: true };\n            break;\n    }\n    \n});\n\nlet message = \"Goodnight.\";\nif(PC && WC) {\n    message = `${message} Don’t forget to charge your phone and watch.`;\n} else {\n    message = `${message} Don’t forget to charge your ${PC ? 'phone' : 'watch'}.`\n}\nif(KP) {\n    message = `${message} Remind Kayla to charge her phone${PC ? ' too':''}.`;\n}\nif(FD) {\n    message = `${message} The door is now locked.`\n}\nmsg.payload = message;\nreturn [msg, lockFD];\n","outputs":2,"noerr":0,"x":610,"y":752,"wires":[["d0e80507.2ac3c8"],["52de5e56.e74c6"]]},{"id":"d0e80507.2ac3c8","type":"cast-to-client","z":"74ddc16c.19655","name":"","url":"","contentType":"","message":"","language":"en","ip":"192.168.1.29","port":"","volume":"40","x":770,"y":752,"wires":[[]]},{"id":"52de5e56.e74c6","type":"api-call-service","z":"74ddc16c.19655","name":"lock door","server":"351c96ee.9dc3aa","service_domain":"scene","service":"turn_on","data":"{\"entity_id\":\"scene.lock_door\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":780,"y":800,"wires":[[]]}]

Disclaimer: All these examples are untested but should give you a general idea on how to use it.

16 Likes

Is there any way to use this with HA groups? i.e. Could I add every door/window I want to be monitored for open status on departure to a group in Home Assistant and iterate over that group with “get entities”?

3 Likes

Not in the current form but I do have it on my todo list to add a logical operator for in group. So you’ll be able to do something like entity_id in_group 'group.door_sensors'. I’ll try to get that in the next release.

For now you can use a function node like in the example below.

[{"id":"fe60cae4.d55af8","type":"trigger-state","z":"205cadf1.ca0312","name":"Left Home","server":"2dad33ee.42bf5c","entityid":"device_tracker.jason","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"m6cll5xe1fk","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"home"},{"id":"hfeih6cive","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"not_home"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":486,"y":384,"wires":[["aaa8c425.d64d28"],[]]},{"id":"cb45441.cc544b8","type":"debug","z":"205cadf1.ca0312","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":770,"y":384,"wires":[]},{"id":"aaa8c425.d64d28","type":"function","z":"205cadf1.ca0312","name":"","func":"const globalHomeAssistant = global.get('homeassistant');\nconst ha = globalHomeAssistant.homeAssistant;\nconst groupEntity = ha.states['group.door_sensors'];\n\nconst entities = Object.values(ha.states).filter(entity => {\n    return groupEntity.attributes.entity_id.includes(entity.entity_id) &&\n    entity.state == 'open';\n    });\n\nmsg.payload = entities;\n  \nreturn msg;","outputs":1,"noerr":0,"x":642,"y":384,"wires":[["cb45441.cc544b8"]]}]
1 Like

It’s actually probably more efficient for this particular case to use this in the function node.

const globalHomeAssistant = global.get('homeassistant');
const ha = globalHomeAssistant.homeAssistant;
const groupEntity = ha.states['group.door_sensors'];
let entities = [];

groupEntity.attributes.entity_id.forEach(i => {
    if(ha.states[i].state === 'open') {
        entities.push(ha.states[i]);
    }
});

msg.payload = entities;
  
return msg;
4 Likes

Is anyone else having problems with Example #2? The get entities works great, but I can’t figure out how to get the “Turn on Light” to work. Leaving the field blank doesn’t seem to cause it to use the entity_id from the “get entities” node. I get an “Error calling service, home assistant api error”

In example #2 I didn’t check the checkbox Render templates in Data in the call-service node. I’ll fix it up above.

Thanks. Now that checkbox name makes sense.

This is a very useful node. I just started working on this but I’ve created a sort of manual circadian/flux flow, since the HA component doesn’t work great with my RGB lights.

[{"id":"420604f1.0ed46c","type":"server-state-changed","z":"48464aa2.86ff64","name":"Lights On","server":"6a99bb32.7b2f04","entityidfilter":"light.","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"","halt_if_compare":"is","outputs":2,"x":80,"y":340,"wires":[["30304d9a.50d522"],[]]},{"id":"30304d9a.50d522","type":"switch","z":"48464aa2.86ff64","name":"Only RGB","property":"data.new_state.attributes.rgb_color","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":240,"y":340,"wires":[["d82b8458.f45fe"]]},{"id":"981e9f37.a47168","type":"time-range-switch","z":"48464aa2.86ff64","name":"Sunset - Night","lat":"37.8085","lon":"-122.2668","startTime":"sunsetStart","endTime":"night","startOffset":0,"endOffset":0,"x":680,"y":360,"wires":[["ce5e06b0.5a5c4"],[]]},{"id":"edc7fb03.6d5cb8","type":"time-range-switch","z":"48464aa2.86ff64","name":"Noon - Sunset","lat":"37.8085","lon":"-122.2668","startTime":"12:00","endTime":"sunsetStart","startOffset":0,"endOffset":0,"x":680,"y":300,"wires":[["420ce53.802e61c"],[]]},{"id":"bfd36d3b.5e23c8","type":"time-range-switch","z":"48464aa2.86ff64","name":"Dawn - Noon","lat":"37.8085","lon":"-122.2668","startTime":"dawn","endTime":"12:00","startOffset":0,"endOffset":0,"x":670,"y":240,"wires":[["5d2db410.660874"],[]]},{"id":"af4aa4.d483956","type":"time-range-switch","z":"48464aa2.86ff64","name":"Night - Dawn","lat":"37.8085","lon":"-122.2668","startTime":"night","endTime":"dawn","startOffset":0,"endOffset":0,"x":670,"y":420,"wires":[["631ec929.a0888"],[]]},{"id":"5d2db410.660874","type":"change","z":"48464aa2.86ff64","name":"White","rules":[{"t":"set","p":"payload","pt":"msg","to":"[255,255,255]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":240,"wires":[["e2f588fb.bd258"]]},{"id":"e6f7ffa7.fd0aa8","type":"api-call-service","z":"48464aa2.86ff64","name":"Adjust Light","server":"6a99bb32.7b2f04","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"{}\"}","render_data":false,"mergecontext":"","output_location":"","output_location_type":"none","x":1330,"y":340,"wires":[[]]},{"id":"e2f588fb.bd258","type":"function","z":"48464aa2.86ff64","name":"Set Data","func":"newmsg = {};\n\nnewmsg.payload = { data: { 'rgb_color':msg.payload,'entity_id':msg.topic } };\n\nreturn newmsg;","outputs":1,"noerr":0,"x":1140,"y":340,"wires":[["e6f7ffa7.fd0aa8"]]},{"id":"420ce53.802e61c","type":"change","z":"48464aa2.86ff64","name":"Warm White","rules":[{"t":"set","p":"payload","pt":"msg","to":"[255,180,0]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":300,"wires":[["e2f588fb.bd258"]]},{"id":"ce5e06b0.5a5c4","type":"change","z":"48464aa2.86ff64","name":"Warm","rules":[{"t":"set","p":"payload","pt":"msg","to":"[255,120,0]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":360,"wires":[["e2f588fb.bd258"]]},{"id":"631ec929.a0888","type":"change","z":"48464aa2.86ff64","name":"Orange","rules":[{"t":"set","p":"payload","pt":"msg","to":"[255,60,0]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":420,"wires":[["e2f588fb.bd258"]]},{"id":"a92a7424.1ff1b8","type":"ha-get-entities","z":"48464aa2.86ff64","server":"6a99bb32.7b2f04","name":"Get Lights","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"},{"property":"attributes.supported_features","logic":"gt","value":"1","valueType":"num"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":270,"y":180,"wires":[["a16c4145.c4c5c8"]]},{"id":"c733ed18.adfa88","type":"inject","z":"48464aa2.86ff64","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":180,"wires":[["a92a7424.1ff1b8"]]},{"id":"d82b8458.f45fe","type":"switch","z":"48464aa2.86ff64","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":340,"wires":[["bfd36d3b.5e23c8","edc7fb03.6d5cb8","981e9f37.a47168","af4aa4.d483956"]]},{"id":"a16c4145.c4c5c8","type":"change","z":"48464aa2.86ff64","name":"Set Topic","rules":[{"t":"move","p":"payload.entity_id","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":260,"wires":[["d82b8458.f45fe"]]},{"id":"6a99bb32.7b2f04","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true}]

Every minute it will update the RGB value, or immediately when a light is turned, only for bulbs that support RGB.

2 Likes

@Kermit I have another question for you… Sorry for the bombardment.

In Example #3 you used in the Get Entries comparative operator the “in” query. For the uninitiated, how is that different from “is”?

You could read it as ‘in list’ and ‘not in list’ where the value next to it is a comma separated list to check against.

Thank you… And the fog dissipates

I’m trying to use example #3 as a starting point, but I’m getting an error “TypeError: msg.payload.forEach is not a function”

I’m using it the same way you were as far as I can tell.

msg.payload.forEach(entity => {
  stuff inside
});

I would confirm that msg.payload is an array.

thanks, i wasn’t outputting from the get entities node as an array.

1 Like

Thanks – Here’s a little example of saving the state of all lights and switches with the get entities node. I’m using this when restarting Home Assistant.

[{"id":"4086598f.c74238","type":"comment","z":"20661f8a.532c4","name":"Save Light/Switch State","info":"","x":2340,"y":2300,"wires":[]},{"id":"b059016b.d8e43","type":"api-call-service","z":"20661f8a.532c4","name":"Turn on","server":"e2a02faf.48099","service_domain":"{{payload.domain}}","service":"turn_on","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"","output_location_type":"none","x":3260,"y":2340,"wires":[[]]},{"id":"e7e5ae25.663d1","type":"ha-get-entities","z":"20661f8a.532c4","server":"e2a02faf.48099","name":"All Lights","rules":[{"property":"entity_id","logic":"starts_with","value":"light.","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":2560,"y":2340,"wires":[["eb77106b.e82bf"]]},{"id":"3296d4cb.2209ec","type":"ha-get-entities","z":"20661f8a.532c4","server":"e2a02faf.48099","name":"All Switches","rules":[{"property":"entity_id","logic":"starts_with","value":"switch.","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":2570,"y":2420,"wires":[["884da93b.b75588"]]},{"id":"71139d49.500684","type":"switch","z":"20661f8a.532c4","name":"On / Off","property":"payload.state","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":3100,"y":2380,"wires":[["b059016b.d8e43"],["8d7ad19e.71f8b"]]},{"id":"8d7ad19e.71f8b","type":"api-call-service","z":"20661f8a.532c4","name":"Turn off","server":"e2a02faf.48099","service_domain":"{{payload.domain}}","service":"turn_off","data":"{\"entity_id\":\"{{payload.entity_id}}\"}","render_data":true,"mergecontext":"","output_location":"","output_location_type":"none","x":3260,"y":2420,"wires":[[]]},{"id":"b24bac9c.92f1","type":"traffic","z":"20661f8a.532c4","name":"Hold messages","property_allow":"payload","filter_allow":"green","ignore_case_allow":false,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"red","ignore_case_stop":false,"negate_stop":false,"send_stop":false,"default_start":false,"differ":true,"x":2920,"y":2380,"wires":[["203bcc86.a9dd64","71139d49.500684"]]},{"id":"203bcc86.a9dd64","type":"delay","z":"20661f8a.532c4","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2900,"y":2440,"wires":[["fea5621c.1870d"]]},{"id":"fea5621c.1870d","type":"change","z":"20661f8a.532c4","name":"Reset hold","rules":[{"t":"set","p":"payload","pt":"msg","to":"red","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2910,"y":2480,"wires":[["b24bac9c.92f1"]]},{"id":"eb77106b.e82bf","type":"change","z":"20661f8a.532c4","name":"Light","rules":[{"t":"set","p":"payload.domain","pt":"msg","to":"light","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2710,"y":2340,"wires":[["b24bac9c.92f1"]]},{"id":"884da93b.b75588","type":"change","z":"20661f8a.532c4","name":"Switch","rules":[{"t":"set","p":"payload.domain","pt":"msg","to":"switch","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2710,"y":2420,"wires":[["b24bac9c.92f1"]]},{"id":"b8d6eea.3f0a01","type":"delay","z":"20661f8a.532c4","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2570,"y":2300,"wires":[["6b35402b.b9571"]]},{"id":"6b35402b.b9571","type":"change","z":"20661f8a.532c4","name":"Turn off hold","rules":[{"t":"set","p":"payload","pt":"msg","to":"green","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":2770,"y":2300,"wires":[["b24bac9c.92f1"]]},{"id":"a32e981e.64cbb8","type":"inject","z":"20661f8a.532c4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2313,"y":2367,"wires":[["b8d6eea.3f0a01","e7e5ae25.663d1","3296d4cb.2209ec"]]},{"id":"e2a02faf.48099","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open"}]

1 Like

Can this node be used to get entities using an attribute? I’m trying to find entities that are related to a zwave device/event using the node_id…

I’m using attributes.node_id and have tried using a string or number for the comparison and neither work…

[{"id":"89b5cd19.78034","type":"ha-get-entities","z":"43c35ce1.b8b444","server":"9dc49131.b4a4e","name":"Get Entities","rules":[{"property":"attributes.node_id","logic":"is","value":"msg.payload.event.node_id","valueType":"num"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"test","output_results_count":1,"x":720,"y":160,"wires":[["9c83d385.beaea"]]},{"id":"9dc49131.b4a4e","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

You currently can’t use msg objects within the get-entities node but it’s something that should probably be added.

Currently you could use a function node to accomplish what you’re trying to do for now.

[{"id":"6b9518de.f4b438","type":"inject","z":"5eb3594f.d294b8","name":"","topic":"","payload":"{\"event\":{\"node_id\":2}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":800,"wires":[["cdba7a0a.309bf8"]]},{"id":"a2d02d68.273d7","type":"debug","z":"5eb3594f.d294b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":502,"y":800,"wires":[]},{"id":"cdba7a0a.309bf8","type":"function","z":"5eb3594f.d294b8","name":"","func":"const globalStates = global.get('homeassistant').homeAssistant.states;\n\nmsg.payload = Object.values(globalStates).filter(entity => {\n    return !!entity.attributes && entity.attributes.node_id === msg.payload.event.node_id\n});\n\n\nreturn msg;","outputs":1,"noerr":0,"x":354,"y":800,"wires":[["a2d02d68.273d7"]]}]
2 Likes

Thanks, your window example is exactly what I was trying to replicate from a YAML automation I’d done earlier!

Thanx for the input. I tried example 1, but I did not get it going. Is it really working ?
I mean, I receive entities, thats fine. But the flow doesnt format the name.

I just tested example #1 and it’s outputting the friendly_name concatenated together with commas.