Custom addressable LED ws2812b config

Good day.
I have a working Python script which controls my addressable LED strip ws2812 connected to RPi.

Two topics are used
“myhome/bathroom/led/set” with different payloads is used to control the LED (on/off, RGB and brightness)
“myhome/bathroom/led/status” send the current status in format {"color": {"r": 36, "b": 255, "g": 36}, "state": "OFF", "effect": "none", "brightness": 138}

Possible payloads to control On/off, brightness and colors are:

  • {"state:“ON”}, {"state:“OFF”} -to turn on/off the strip
  • {“state”:“ON”,“brightness”:0-255} to adjust brightness - the script will not change the brightness if the key “state”:ON is missing.
  • {“state”:“ON”,“color”:{“r”:0-255,“g”:0-255,“b”:0-255}} - the same as for brightness, it should contain “state”:on also.

Could anyone please advise me with the integration - how should I integrate in most proper way (end easiest as well).

solved first put with the yaml below

light:
- platform: mqtt
    name: bathroom.smartmirror.led
    schema: template
    command_topic: "myhome/smartmirror/led/set"
    state_topic: "myhome/smartmirror/led/status"
    command_on_template: >
      {"state": "ON"
      {%- if brightness is defined -%}
      , "brightness": {{ brightness }}
      {%- endif -%}
      {%- if red is defined and green is defined and blue is defined -%}
      , "color": {"r":{{ red }},"g":{{ green }},"b": {{ blue }} }
      {%- endif -%}}
    command_off_template: '{"state": "OFF"}'
    state_template: '{{ value_json.state }}'
    brightness_template: '{{ value_json.brightness }}'
    red_template: '{{ value_json.color[0] }}'
    green_template: '{{ value_json.color[1] }}'
    blue_template: '{{ value_json.color[2] }}'
    optimistic: false
    qos: 0

but can’t get correct state.
I am getting state in format
{"color": {"r": 36, "b": 255, "g": 36}, "state": "OFF", "effect": "none", "brightness": 138}