Missing „hsb of“ blockly block

Ok. Thank you. I found this function here Extending Blockly with new openHAB commands - #250 by ysc and create a own block Lib (with this tutorial: Tutorial: How To Write Block Libraries ) that backport the block for me:


uid: 360friends
tags: []
props:
  parameters: []
  parameterGroups: []
timestamp: Apr 6, 2022, 5:20:56 PM
component: BlockLibrary
config:
  name: 360friends
slots:
  blocks:
    - component: BlockType
      config:
        type: block1
        message0: hex->hsb %1
        args0:
          - type: input_value
            name: COLOR
        colour: 20
        tooltip: ""
        helpUrl: ""
        output: STRING
      slots:
        code:
          - component: BlockCodeTemplate
            config:
              template: "{{utility:hex_to_hsb}}({{input:COLOR}})"
  utilities:
    - component: UtilityFunction
      config:
        code: >-
          function hex_to_hsb(hex) {
            var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
            if (!rgb) return '';
            var r = parseInt(rgb[1], 16) / 255, g = parseInt(rgb[2], 16) / 255, b = parseInt(rgb[3], 16) / 255;
            var v = Math.max(r, g, b), n = v - Math.min(r, g, b);
            var h = n === 0 ? 0 : n && v === r ? (g - b) / n : v === g ? 2 + (b - r) / n : 4 + (r - g) / n;
            return [60 * (h < 0 ? h + 6 : h), v && (n / v) * 100, v * 100].join(',');
          }
        name: hex_to_hsb

Thank you.