Two rules create a infinite loop of item state

Hi everyone,
i created 2 rules of convert HSB (Google Home) to 3ch RGB and viceversa, but when started, the rule1 call rule 2 and viceversa.
It’s possibile to create one rules with a if else?
Please help me…

rule "RGB Studio HSB-RGB"
when
    Item HSBStudio received command
then
    val red = (receivedCommand as HSBType).red
    val green = (receivedCommand as HSBType).green
    val blue = (receivedCommand as HSBType).blue

    gOffice_RossoLedStudio.sendCommand(red)
    gOffice_VerdeLedStudio.sendCommand(green)
    gOffice_BluLedStudio.sendCommand(blue)
end

rule "RGB Studio RGB-HSB"
when
    Item gOffice_RossoLedStudio  or 
    Item gOffice_VerdeLedStudio  or 
    Item gOffice_BluLedStudio 
then
    Thread::sleep(2000)
    var red1 = ((gOffice_RossoLedStudio.state as Number)*2.55).intValue
    var green1 = ((gOffice_VerdeLedStudio.state as Number)*2.55).intValue
    var blue1 = ((gOffice_BluLedStudio.state as Number)*2.55).intValue
    logInfo("RGBStudio1.rules", "R " + red1 + ", G " + green1 + ", B " + blue1)
    Thread::sleep(2000)
    var HSBType hsb = HSBType.fromRGB(red1, green1, blue1)
    logInfo("RGBStudio1.rules", "Input Conversion: hsb: " + hsb)
    HSBStudio.sendCommand(hsb)
  
end

Quite likely. But what are you trying to do, exactly? Have you just muddled commands and states?

Hi have 4 item:
1- gOffice_RossoLedStudio - Red channel of RGB stripled MQTT
2- gOffice_VerdeLedStudio - Green channel of RGB stripled MQTT
3- gOffice_BluLedStudio - Blue channel of RGB stripled MQTT
4- HSBStudio - Color proxy of RGB, and we integrated in Google Home

I want this:
Rule 1, if i control the HSB via Google Home or Web browser i command the rgb and we workly correctly.
Rule2, if i control the rgb via keypad mqtt → update the HSB item.

I’m still not sure exactly what you need, but let me draw an analogy.

People often get into trouble with endless loops when trying to set up rules to link two switches to “follow” each other and work as a pair.
The key to avoiding that is to choose rule triggers carefully.
Trigger from state changed, not from command.

Also -

I’m not at all sure what trigger you get when you forget to specify any trigger at all. I’m surprised it does anything.

One fairly obvious change to make is to do exactly what you describe
i.e. don’t do this

do that
HSBStudio.postUpdate(hsb)

It’s important to understand the difference between command and state