How to controll RGB led strip by HSV values in esphome device?

Hello,
I’m redesigning my bedroom lights, changing it from mysensors to esphome platform.
In one device there are two separate cw/ww lights (left and right side of the bed), and one rgb strip, controlled by two rotary encoders. I’ve already realized cw/ww lights and control, but struggled with RGB.
My goal is to control hue, saturation and brightness by rotary encoder, switching between controlled parameters by clicking rotary encoder (much more intuitive than controlling RGB values). Seems easy, but there is no HSV control over rgb light. So, I probably need external variables for HSV and convert it to RGB to set light (and vice versa in case of RGB light changed by HA api).
Has anyone realized such an conversion? Or maybe there is better method to control RGB light trough HSV values?

ESPHome has a function to convert HSV to RGB.

Here’s some code that shows how to use it: Butterfly LED Panel

Thank you very much @zenzay42, that function looks exactly what I need :slightly_smiling_face:
I will try to use it and share the final code if it will work.