Change color of tradfri bulb only if it is on

I have a few tradfri bulbs set up and I currently have this script to set them all the same color.

everyday:
   alias: Neutral
   sequence:
   - data:
       color_temp: '370'
       transition: '10000'
       entity_id: 
        - light.bed
        - light.desk
        - light.corner
        - light.nightlight
     service: light.turn_on

my question is, is there a way to only the script change the color if the bulb is on? Right now it will change the color of all the lights even iff they are off.

Place that condition in the automation that is triggering them being set to the same color.