WTH can't I easily target devices by their state in automations

I want to change the colour temperature of all lights that are on when the sun sets

I want to dim all lights that are on when it’s bed time

I want to change the colour temperature of only the bulbs that have colour temperature control

Currently achieved with templates that took me hours to build.

service: light.turn_on
data:
  color_temp: "{{states(\"sensor.sun_colour_temp\")}}"
  transition: 5
target:
  entity_id: >-
    {{states.light | selectattr('state','eq','on') |
    selectattr('attributes.supported_color_modes','eq',states.light.living_room_light.attributes.supported_color_modes)
    |map(attribute='entity_id') | list }}