Using targets as conditions?

I have been working on that for the last day and I think I finally found a working solution. This seems to work as a condition that checks if any of the lights in the target group are on:

# making the input variable usable in the condition
variables:
  lights: !input "light_target"
...
- "{{ expand(lights.entity_id) | selectattr('state', '==', 'on') | list | count > 0 }}"

This is not very flexible (yet) though as I assume if you pick groups or devices instead of entities they would not be in the “entity_id” attribute. It would be really awesome to have a built-in condition for things like this