Many thanks for the info, Rich. You’re so helpful!
The following code works:
var HSBType = Java.type('org.openhab.core.library.types.HSBType');
var HSB = HSBType.fromRGB(Math.round(red), Math.round(green), Math.round(blue));
logger.info("{} kelvin converted to red: {}, green: {}, blue: {}.", triggeringItem.state, red, green, blue);
logger.info("RGB values converted to hsb: {}.", HSB);
items.getItem("LightTableColour1_Color").sendCommand(HSB.toString());
I’d copied an RGB to HSB function from somewhere while I was stuck with the HSBType problem but now I can remove that function to tidy the code up a bit.