Node RED: "Get Entities" from Home Assistant - how to use?

Node Red v1.2.2
HA core v.0.116.4

No error codes, but the resulting payload isn’t what I expect.
I’m trying to get any, all and/or one specific entity attribute(s) from HA into NR. But no matter what I do, I only and always get just one and the same entity every time (or nothing at all).
Here’s my simple test flow:

[{"id":"978536f.8a4cbc8","type":"ha-get-entities","z":"3abd6ec5.999042","server":"15c5ca8b.7ac0c5","name":"","rules":[{"property":"","logic":"jsonata","value":"$entity().attributes.\"battery_level\" < 65","valueType":"jsonata"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":390,"y":400,"wires":[["ea71d5b3.f56138"]]},{"id":"ea71d5b3.f56138","type":"debug","z":"3abd6ec5.999042","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":400,"wires":[]},{"id":"eca79e1f.702b5","type":"inject","z":"3abd6ec5.999042","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":220,"y":400,"wires":[["978536f.8a4cbc8"]]},{"id":"15c5ca8b.7ac0c5","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Here’s the output I get:

[{"entity_id":"device_tracker.iphone_se","state":"not_home","attributes":{"source_type":"gps","battery_level":40,"latitude":59.91209446294224,"longitude":10.75046873679876,"gps_accuracy":65,"altitude":28.114791870117188,"vertical_accuracy":10,"friendly_name":"iPhone-SE"},"last_changed":"2020-10-22T14:52:53.192988+00:00","last_updated":"2020-10-22T14:52:53.192988+00:00","context":{"id":"43407d71147611eb8c74130d49cd53f5","parent_id":null,"user_id":null},"timeSinceChangedMs":144453187}]

I know I have several other sensors with batteries, plus 3 additional cell pones also with the “battery_level” attribute, but this is the only one I get. Always. I’ve even tried to rename this entity in HA, assuming that it was the first hit in some alphabetical order, but to no avail.

How do I get hold of any/all/some of my other entities?
Preferably, I would like to get an array with all of them, that I could work on.
Please help, anyone?

This is what I used to get all lights that are on:

1 Like

Use the property field to pick which property you’re interested, and then set the condition in the next line, like so:

[{"id":"978536f.8a4cbc8","type":"ha-get-entities","z":"f44cc346.ac631","server":"15c5ca8b.7ac0c5","name":"","rules":[{"property":"attributes.battery_level","logic":"gt","value":"0","valueType":"num"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":370,"y":200,"wires":[["ea71d5b3.f56138"]]},{"id":"ea71d5b3.f56138","type":"debug","z":"f44cc346.ac631","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":200,"wires":[]},{"id":"eca79e1f.702b5","type":"inject","z":"f44cc346.ac631","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":200,"y":200,"wires":[["978536f.8a4cbc8"]]},{"id":"15c5ca8b.7ac0c5","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

@djsv23 Thank you for helping, but regretfully - your flow gave the exact same result as I already have; A single device, and the always the same one.

@aceindy Hi and thank you - I have a distinct feeling that you are on to something. However, as far as I can see - I do not have a group like group.all_sensors
In fact, I don’t even have a group named group.all_lights so just copying your setting and running the flow gave ‘0’ (nothing, or empty) as the result.
I just want to grab hold of any device that has a battery. It doesn’t have to belong to any particular group.
Any additional assistance from you would be great :slight_smile:

The group you’ll have to create yourself :thinking:
For all that matters, I could also have made the group.all_lights_in_the_kitchen :yum: