Get entities in group not working

I’ve been trying to update some flows and want to get a count of entities in a group whose state is currently ‘Home’. When I try and use the in group property it’s not finding any results.
image

If I remove state is Home then I get zero results. If I remove entity_id in group group.home_mode_poeple then I get an accurate count of the entities who are currently set to ‘Home’. My group.home_mode_people is a segment of everyone who could be set as home so I only want to look at them.

Any ideas on what I’m doing wrong?

Can you post your code please? OR…

If you have your home zone setup properly - you could just query the state of your Home zone - which outputs a count of entities currently in that zone.

So first thing I’d say is I highly doubt any device tracker or people entities have state Home. Device trackers and people entities have state home (note the lowercase ‘h’) a lot but they never have state Home (capital ‘H’) unless you are doing something quite strange.

Make sure you are viewing the actual state of your entities by going to Developer Tools → States. Not simply looking at them in a dashboard, the history panel or a more info pop-up. That localizes and capitalizes things to present them more nicely in the UI, it doesn’t always show the actual state.

1 Like

So I can’t use home zone as the contents of the group.home_mode_people is all input_text sensors. Reason for that is I’ve expanded location detection to include things like driving, just arrived home, ect. I’m also tracking people with different techniques so I need more flexibility.

Here is the full flow.

[{"id":"c7eb480c895880cf","type":"comment","z":"b22a85d2.2d8ae8","name":"Home / Away Logic","info":"","x":130,"y":1280,"wires":[]},{"id":"ddfc9f4838682891","type":"server-state-changed","z":"b22a85d2.2d8ae8","name":"C Home?","server":"3413715.387508e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_text.c","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":1400,"wires":[["c7f591beb59b4c1e"]]},{"id":"53de2281d932c0e5","type":"server-state-changed","z":"b22a85d2.2d8ae8","name":"M Home?","server":"3413715.387508e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_text.m","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":122,"y":1465,"wires":[["c7f591beb59b4c1e"]]},{"id":"c10d299a131b963b","type":"server-state-changed","z":"b22a85d2.2d8ae8","name":"E Home?","server":"3413715.387508e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_text.e","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":122,"y":1525,"wires":[["c7f591beb59b4c1e"]]},{"id":"847f8d21140e51c1","type":"api-call-service","z":"b22a85d2.2d8ae8","name":"Home Mode: Home","server":"3413715.387508e","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["input_select.home_mode"],"data":"{\"option\":\"Home\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":630,"y":1400,"wires":[[]]},{"id":"b018afcce83c6621","type":"api-call-service","z":"b22a85d2.2d8ae8","name":"Home Mode: Away","server":"3413715.387508e","version":5,"debugenabled":false,"domain":"input_select","service":"select_option","areaId":[],"deviceId":[],"entityId":["input_select.home_mode"],"data":"{\"option\":\"Away\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":1500,"wires":[[]]},{"id":"4ecc85656f4e9cf7","type":"api-current-state","z":"b22a85d2.2d8ae8","name":"No Guests?","server":"3413715.387508e","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.house_guests","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":612,"y":1505,"wires":[["980031a0aa3b7d0d"],[]]},{"id":"c7f591beb59b4c1e","type":"switch","z":"b22a85d2.2d8ae8","name":"(Just Arrived) Home","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Home","vt":"str"},{"t":"eq","v":"Just Arrived Home","vt":"str"},{"t":"eq","v":"payload","vt":"msg"}],"checkall":"false","repair":false,"outputs":3,"x":400,"y":1420,"wires":[["847f8d21140e51c1"],["847f8d21140e51c1"],["4ecc85656f4e9cf7"]]},{"id":"99b14109e828e455","type":"server-state-changed","z":"b22a85d2.2d8ae8","name":"T Home?","server":"3413715.387508e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_text.t","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":1340,"wires":[["c7f591beb59b4c1e"]]},{"id":"980031a0aa3b7d0d","type":"ha-get-entities","z":"b22a85d2.2d8ae8","name":"Count Home in Home Mode People","server":"3413715.387508e","version":0,"rules":[{"property":"state","logic":"includes","value":"Just Arrived Home, Home","valueType":"str"},{"property":"entity_id","logic":"in_group","value":"group.home_mode_people","valueType":"str"}],"output_type":"array","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":840,"y":1500,"wires":[["58b33d4434bc4faa"]]},{"id":"58b33d4434bc4faa","type":"switch","z":"b22a85d2.2d8ae8","name":"is 0?","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1050,"y":1500,"wires":[["b018afcce83c6621"]]},{"id":"3413715.387508e","type":"server","name":"Home Assistant ACME","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Even if I try and do a count for just the entity_id in group group.home_mode_people I get no results even though there are entities in that group.

If I go more simplistic… using get_entities to return the contents of a group in an array returns nothing, even if the group has items in it. I feel like I’m missing something basic, but I’m not sure what I’m doing wrong.


[{"id":"e82747f6cdc56af1","type":"ha-get-entities","z":"b22a85d2.2d8ae8","name":"Group zwave batteries","server":"3413715.387508e","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"group.zwave_batteries","valueType":"str"}],"output_type":"array","output_empty_results":true,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":1820,"y":1440,"wires":[["330847a41cc84c1f"]]},{"id":"d69c28d98b3f753d","type":"inject","z":"b22a85d2.2d8ae8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1640,"y":1440,"wires":[["e82747f6cdc56af1"]]},{"id":"330847a41cc84c1f","type":"debug","z":"b22a85d2.2d8ae8","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2000,"y":1440,"wires":[]},{"id":"3413715.387508e","type":"server","name":"Home Assistant ACME","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

Nevermind, it’s now working. Looks like an update to Node-RED companion and it’s now working as expected. My usage of it was spot on.