Color change automation - Group vs single light - HELP

Hello,
Please help, I’ve created an automation for sonoff switch to control smart bulb.
This works fine on a single light but not for the light group. any suggestions?

 - alias: Change kitchen light color when on
  trigger:
   - platform: state
     entity_id: sensor.sonoff_kitchen_toggle
     to: 'TOGGLE'
  condition:
    condition: state
    entity_id: group.kitchen_lights
    state: 'on'
  action:
     service: light.turn_on
     data_template:
      entity_id: group.kitchen_lights
      rgb_color:  >
        {% if states.group.kitchen_lights.attributes.rgb_color == (255,0,0) %} [0,255,0]
          {% elif states.group.kitchen_lights.attributes.rgb_color == (0,255,0) %} [0,0,255]
            {% else %} [255,0,0]
        {% endif %}