Mix lights and motion sensors in the same group

Hello.
I just created a group that includes the lights and the motion sensors of a room. Is this functional?
I mean, can I use it to get motion events and trigger the lights on and off?
Checking the attributes of the group I see it only has the on/off states, but it doesn’t seem to have the motion/no motion anywhere (not in attributes, not in any place).

Being able to do this will be very convenient because then I don’t have to change any automation when changing the sensors of a room, I will just need to add them to the group while keeping things tidy (no duplicated groups for the same room)

It’s weird. It will work but only if the group entities have a common set of states.

Nothing has that. The state for binary sensors is 'on' or 'off'.

It might help if you share the code you are attempting to use.

I just want to be clear on one point, you expect to put lights and motion sensors into a group and then this group will make the lights turn on whenever one of the motion sensors turns on? Is that what you expect the group to do?

there is no code, just a group:

wc_invitados:
    name: WC invitados
    entities:
        - binary_sensor.motion_2_occupancy
        - light.shellybulbduo_8xxxxxxx

Then just a node-red flow that is turning the lights on on motion detection, then turning it off on no more motion detected. Although it never worked properly (I wanted the detection of motion to reset the countdown to turn lights off, but it never worked properly)

[{"id":"5a394d0a.224e54","type":"subflow","name":"Auto off light","info":"You provide a light id and it will get turned on on any input.\nAn off delay will be triggered at the same time, and it will turn off the light after a minute","category":"","in":[{"x":50,"y":30,"wires":[{"id":"a7d14362.55862"}]}],"out":[],"env":[{"name":"light","type":"str","value":"","ui":{"icon":"font-awesome/fa-lightbulb-o","type":"input","opts":{"types":["str","env"]}}},{"name":"sensor","type":"str","value":""}],"color":"#FFCC66","icon":"font-awesome/fa-lightbulb-o","status":{"x":580,"y":360,"wires":[{"id":"eca7a043.764f5","port":0}]}},{"id":"3a774b11.81cc34","type":"api-call-service","z":"5a394d0a.224e54","name":"Turn on light","server":"244e8d39.7b4e02","version":3,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"{{payload}}","data":"{}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":60,"wires":[[]]},{"id":"2cb6384a.333aa8","type":"api-call-service","z":"5a394d0a.224e54","name":"Turn off light","server":"244e8d39.7b4e02","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"{{payload}}","data":"{}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":220,"wires":[[]]},{"id":"8809cd64.f43ea","type":"trigger","z":"5a394d0a.224e54","name":"Off delay","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"10","extend":true,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":580,"y":160,"wires":[["2cb6384a.333aa8"]]},{"id":"d28a794d.850b68","type":"debug","z":"5a394d0a.224e54","name":"Auto-off-light","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":100,"wires":[]},{"id":"eca7a043.764f5","type":"status","z":"5a394d0a.224e54","name":"","scope":null,"x":420,"y":360,"wires":[[]]},{"id":"a7d14362.55862","type":"function","z":"5a394d0a.224e54","name":"Split states","func":"const id = env.get('light')\nif(!id) {\n    node.status({\n    fill:\"red\",\n    shape:\"ring\",\n    text:\"light not provided\"\n    });\n    return null\n}\n\nnode.log(JSON.stringify(msg))\nmsg.payload = id // Required to turn on/off the proper light\n// Sent by homeassistant api-current-state\nconst isOn = msg.data.new_state.state === 'on'\nif(isOn) return [msg,null];\nreturn [null, msg]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":100,"wires":[["3a774b11.81cc34","d28a794d.850b68"],["8809cd64.f43ea","d28a794d.850b68"]],"inputLabels":["Ha state"],"outputLabels":["on","off"]},{"id":"76137ab1.8121d4","type":"server-state-changed","z":"d326cf3e.06bee","name":"WC-motion","server":"244e8d39.7b4e02","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"group.wc_invitados","entityidfiltertype":"exact","outputinitially":false,"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":90,"y":240,"wires":[["18326890.31eca7"]]},{"id":"18326890.31eca7","type":"subflow:5a394d0a.224e54","z":"d326cf3e.06bee","name":"WC auto-off","env":[{"name":"light","value":"group.wc_invitados","type":"str"},{"name":"wait","value":"61","type":"num"}],"x":290,"y":240,"wires":[]},{"id":"244e8d39.7b4e02","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

The motion sensor is aqara and the light is a shelly one

Ugh. Node red. I’m out (and moving this to the correct category).

Node red may be a terrible programming environment, but at least it is not a markup. Is what I described achievable with home assistant automations?

No,
I want to be able to query the group for motion states and trigger lights. But seems it is not capable of doing anything but merge properties. Way less capable that I expected

I get the impression you either didn’t read, or fully understand, the Group integration’s documentation before you developed your expectations. It very clearly states a group’s purpose and behavior.

If you were to create two groups, one containing motion sensors and the other containing lights (or, better yet, create a Light Group), when any of the motion sensors turns on, the group’s state becomes on (and can be used by a State Trigger to, for example, turn on the Light Group). This is a very common way of combining multiple motion sensors to behave like one and to make multiple lights behave like one.

That’s the core purpose of combining entities, with a common domain, into a group and that’s to make them appear as a single entity (and to control all of them like a single entity). If you make a group containing mixed domains (binary_sensor and light or climate and sensor) the end-result is rarely useful (especially if they don’t have common state values).

The question is about group capabilities. The fact I then use them on node-red is just meta-data