Switch Toggle from Double press

This seems really simple but i can’t seem to get my head around it.

I have an RGB Controller with a Button.

When the button is pressed it toggles the LED.

What i want is that a Double Press will toggle a Switch to enable sleep mode. I have created the switch, and the Binary Sensor, but the Switch won’t stay on. Do i need to declare a Global Variable?

  - platform: gpio
      number: GPIO0
      inverted: True
    name: button
      min_length: 50ms
      max_length: 350ms
        - light.toggle:
            id: me
 #   on_double_click:
#      min_length: 50ms
#      max_length: 350ms
#      then:
#        - switch.toggle: 
#            id: id_stu_sleep_mode
  - platform: template
    name: "Stu Sleep Mode"
    id: id_stu_sleep_mode

  - platform: esp8266_pwm
    id: output_red 
    pin: GPIO4
  - platform: esp8266_pwm
    id: output_green 
    pin: GPIO12
  - platform: esp8266_pwm
    id: output_blue 
    pin: GPIO14


I would belive that it should work.

What does it say in the log output?

Argh… I had to put optimistic: True

It now stays on.