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"
Item HSBStudio received command
val red = (receivedCommand as HSBType).red
val green = (receivedCommand as HSBType).green
val blue = (receivedCommand as HSBType).blue
rule "RGB Studio RGB-HSB"
Item gOffice_RossoLedStudio or
Item gOffice_VerdeLedStudio or
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)
var HSBType hsb = HSBType.fromRGB(red1, green1, blue1)
logInfo("RGBStudio1.rules", "Input Conversion: hsb: " + hsb)
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.
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
It’s important to understand the difference between command and state