[SOLVED] Rule for a group but triggering back to it's initial state

Hello,

I’m having an issue with a group of lightbulb I created in items.

    Group:Color:OR(ON, OFF) HLR_Lights_Color "Color Lights of Living Room" <colorwheel> (Hall, LivingRoom)

    Color Bulb_Kitchen_Colorpicker "Kitchen Bulb Colorpicker via rules" <dimmablelight> (HLR_Lights_Color, LivingRoom)
    Color Bulb_Hall_Colorpicker "Hall Bulb Colorpicker via rules" <dimmablelight> (HLR_Lights_Color, Hall)
    Color Bulb_LivingRoom1_Colorpicker "LivingRoom1 Bulb Colorpicker via rules" <dimmablelight> (HLR_Lights_Color, LivingRoom)
    Color Bulb_LivingRoom2_Colorpicker "LivingRoom2 Bulb Colorpicker via rules" <dimmablelight> (HLR_Lights_Color, LivingRoom)

The thing is I manage to control my group through sitemap. But it gets more complicated when i want to do it with rules :

var hsbHue = (HLR_Lights_Color.state as HSBType).hue.intValue;
var hsbSat = (HLR_Lights_Color.state as HSBType).saturation.intValue;
var hsbBrt = (HLR_Lights_Color.state as HSBType).brightness.intValue;
if (xc_current_mode == "hue") {
	hsbHue -= 20
	if (hsbHue < 0)
		hsbHue = 360		
} else if (xc_current_mode == "saturation") {
	hsbSat -= 10
	if (hsbSat < 0)
		hsbSat = 0		
} else if (xc_current_mode == "brightness") {
	hsbBrt -= 10
	if (hsbBrt < 0)
		hsbBrt = 0		
} else {
	hsbBrt -= 10
	if (hsbBrt < 0)
		hsbBrt = 0		
}
val color = hsbHue+","+hsbSat+","+hsbBrt;
logInfo("Color", "Retrieving HSB info -> " + color)

//HLR_Lights_Color.sendCommand(color)
HLR_Lights_Color.postUpdate(color)
Bulb_Hall_Colorpicker.sendCommand(color)
Bulb_Kitchen_Colorpicker.sendCommand(color)
Bulb_LivingRoom1_Colorpicker.sendCommand(color)
Bulb_LivingRoom2_Colorpicker.sendCommand(color)

My command is originally sent correctly to the group, but then reverted back from one element of the group :

==> /var/log/openhab2/events.log <==
2020-01-12 18:25:09.239 [ome.event.ItemCommandEvent] - Item ‘Bulb_Hall_Colorpicker’ received command 0,0,90
2020-01-12 18:25:09.239 [ome.event.ItemCommandEvent] - Item ‘Bulb_Kitchen_Colorpicker’ received command 0,0,90
2020-01-12 18:25:09.239 [ome.event.ItemCommandEvent] - Item ‘Bulb_LivingRoom1_Colorpicker’ received command 0,0,90
2020-01-12 18:25:09.239 [ome.event.ItemCommandEvent] - Item ‘Bulb_LivingRoom2_Colorpicker’ received command 0,0,90
2020-01-12 18:25:09.240 [GroupItemStateChangedEvent] - HLR_Lights_Color changed from 0,0,90 to 0,0,100 through Bulb_Kitchen_Colorpicker

Is there anything i’m doing wrong ? At first I used “HLR_Lights_Color.sendCommand(color)” as an only sending command one, but as my problem started appearing, I tried different things.

Thanks in advance.

What state do you want your Group to take?
You’ve made it a Color type, so it cannot go to ON or OFF states.
When your aggregation function ORs the colours into an on-off state, it “won’t fit” and it makes an approximation.

Would it work better for you with group type Switch ?

In this example, i want to change the value of my color (0,0,100) to 0,0,90, then 0,0,80 etc. but it automatically reverts back to 0,0,100 after the command is sent, picking the value from an item of the group.

I think i should probably remove the OR from my group. Thank you for your precisions.

Edit : It is now working as intended. I probably need to do some adjustments, but thank you rossko for your enlightment.

Perhaps you want to use MAX or AVG aggregation functions if you want your group state related to your member’s state. I don’t know how well those work with Color types.