Xiaomi gateway - Can't adjust rgb color with light.toggle action

Hi all,
I want to set a specific rgb color for my Xiaomi gateway when double press through a Xiaomi smart switch. Problem is that rgb_color is working only if I use homeassistant.turn_on service. If I change to homeassistant_toggle or light.toggle, the light returns to default white. Only brightness is recognized.
With what I have now is working fine, but I want to toggle the light, not just turn it on.
The code:

- alias: Night mode
  trigger:
  - platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.switch_1
      click_type: double
  - platform: event
    event_type: xiaomi_aqara.click
    event_data:
      entity_id: binary_sensor.wall_switch_light_bedroom
      click_type: double
  action:
    - service: homeassistant.turn_on
      data:
        entity_id: light.gateway_light
        brightness: 25
        rgb_color: [255,99,0]
    - service: homeassistant.turn_off
      entity_id: light.kids
    - service: homeassistant.turn_off
      entity_id: switch.sonoff_kitchen
    - service: homeassistant.toggle
      entity_id: switch.blitzwolf

Thanks in advance!

Try light.turn_on instead of homeassistant.turn_on.

It’s working either with homeassistant.turn_on or with light.turn_on but the problem is that I want also to be able to turn it off (with the same process if possible) just like toggle.
But with light.toggle, rgb_color setting is not working. Returns back to default white.

Aah, ok. I missed that part.

I think that I have to make an other one automation that reads the state of the light and turn it off?

Yes, I was just going to suggest that. Make a condition if the light is on, turn it off, and if the light is off, set the color and do a light.turn_on.

Sounds strange that I have to make two different automations just for on-off on specific color.
Isn’t there any other workaround?

use a service_template based on the current state of your lights

Ok this sounds good. How can I use it according to my needs? I read the tutorial but it’s complicated.
Is this going to work?

service_template: >
  {% if states('light.gateway_light') %}
    switch.turn_on
  {% else %}
    switch.turn_off
  {% endif %}
entity_id: switch.1

Edit:
Still trying to figure out how. Till now I have this but it’s not working:

  action:
    - service: homeassistant.turn_off
      entity_id: light.bedroom
    - service: homeassistant.turn_off
      entity_id: switch.sonoff_kitchen
    - service: homeassistant.turn_off
      entity_id: light.kids
    - service: homeassistant.toggle
      entity_id: switch.blitzwolf
    - service_template: "script.hallway_turn_{{ 'on' if is_state('light.gateway_light_hallway','off') else 'off' }}"

And in scripts.yaml:

hallway_turn_on:
    sequence: 
      - service: light.turn_on
        data:
          entity_id: light.gateway_light_hallway
          brightness: 20
          rgb_color: [255.99.0]
hallway_turn_off:
    sequence: 
      - service: light.turn_off
        data:
          entity_id: light.gateway_light_hallway