Get rgb values from front end and assign to a global variable

Hello Board,

i wanted to control color of single rgb LED (2812) for which im currently using following code,
id(LED0).turn_on().set_rgb(id(off_red), id(off_green), id(off_blue)).set_brightness(id(off_brightness)).set_transition_length(10).perform();
The rgb values are assigned in global variables in the code, hence when above line of code executes the value of RGB will get extracted from globals and the color is set to particular LED accordingly.

now i have to change the color from front end of Home Assistant. so that i can assign any custom color based on my mood.
which mean i need to get the RGB values from color pallet and store it in variables. so that the color changes automatically on particular action.

Please suggest me with any available example.
Thanks in advance.

Your code makes no sense. It might if you posted yaml

Here is my Code

globals:
  - id: on_red
    type: float
    restore_value: true
    initial_value: '0.0'

  - id: on_green
    type: float
    restore_value: true
    initial_value: '1.0'

  - id: on_blue
    type: float
    restore_value: true
    initial_value: '0.0'
script:
  - id: update_led_color
    then:
      - if:
          condition:
            switch.is_off: rly_1
          then:
            - switch.turn_off: rly_1
            - lambda: |-
                id(off_brightness) = id(brightness_slider);
                id(LED0).turn_on().set_rgb(id(off_red), id(off_green), id(off_blue)).set_brightness(id(off_brightness)).set_transition_length(10).perform();
                return;

Now by changing global values i could be able to change the color,

what im expecting is

  1. There should be a color picker in frontend
  2. once i pick a color in front end it has to assign rgb values to the following variables
    for eg.
light:
  - platform: rgb
    name: "LED color picker"
      then:
        - lambda:  |-
            id(on_red) = red;
            id(on_green) = green;
            id(on_blue) = blue;

or other option

light:
  - platform: rgb
    name: "LED color picker"
    id(on_red) = red;
    id(on_green) = green;
    id(on_blue) = blue;

Appreciate if you could give us an example code that would get the rgb values from color picker UI and assign the float value to the global so that when i execute the script the color auto updates.

Thank you.

Any solution for my problem.?

Hello board
Any hints?