Control milight and homekit

Hello everyone,
I need to write a rule to control my light bulbs from homekit. Let me explain in a better way.
I have set my items file and everything work correctly

`//This is the Items File

//Lights
Color MilightrgbLed0color “Tutte le luci” [ “Lighting” ] {channe$
Color MilightrgbLed1color “Scrivania” [ “Lighting” ] {channel="m$
Color MilightrgbLed2color “Divano” [ “Lighting” ] {channel="mili$
Color MilightrgbLed3color “Sinistra” [ “Lighting” ] {channel="mi$
Color MilightrgbLed4color “Destra” [ “Lighting” ] {channel="mili$
`

sitemap home label=“The Cave”
{
Frame label=“Lights”
{
Switch item=MilightrgbLed0color label=“Luci” icon="light"
Slider item=MilightrgbLed0color label=“Brightness” icon="dimmabl$
Colorpicker item= MilightrgbLed0color label=“Color” icon=“rgb”

           Switch item=MilightrgbLed1color label="Scrivania" icon="light"
           Slider item=MilightrgbLed1color label="Brightness" icon="dimmabl$
           Colorpicker item= MilightrgbLed1color label="Color" icon="rgb"

           Switch item=MilightrgbLed2color label="Divano" icon="light"
           Slider item=MilightrgbLed2color label="Brightness" icon="dimmabl$
           Colorpicker item= MilightrgbLed2color label="Color" icon="rgb"

           Switch item=MilightrgbLed3color label="Sinistra" icon="light"
           Slider item=MilightrgbLed3color label="Brightness" icon="dimmabl$
           Colorpicker item= MilightrgbLed3color label="Color" icon="rgb"
    }

}

I need a rule that let me control the status of lights 1, 2, 3, 4 with the toggles of 0 that group all the lights. For example I want that when I switch ON “0”, the switches on the sitemap and in home app of 1, 2, 3, 4 turn ON. Same thing for color change and dimmer.

Another question is: when I use home app and I want to change a color of a light bulb, why it’s easy to switch from red to blue, to green and when I switch from a color to white and from white to a color I can’t do that? I must change the saturation or the color on the sitemap.

Last question: is it possible to add a blank space in the sitemap?

Sorry for my poor english.

Hope someone can help me. Thanks

Assuming you really mean just updating the state of the Item and not sending the new state out to the devices as a command:

  • put your Lights all in the same Group (I’ll call it gLights)
  • in your Rule use
gLights.members.forEach[light| light.postUpdate(MilightrgbLed0color.state)] 

If you actually want to control the actual lights from the one switch, define the Group as:

Group:Color gLights

Put gLights on your sitemap as the Switch and ColorPicker and Slider and any command sent to gLights will also be sent to all the members of gLights. No Rule required.

Not that I’m aware of.

Item file:
//Group lights
Group gLights

//Lights
Color MilightrgbLed0color “Tutte le luci” (gLights) [ “Lighting” $
Color MilightrgbLed1color “Scrivania” (gLights) [ “Lighting” ] {$
Color MilightrgbLed2color “Divano” (gLights) [ “Lighting” ] {ch$
Color MilightrgbLed3color “Sinistra” (gLights) [ “Lighting” ] {c$
Color MilightrgbLed4color “Destra” (gLights) [ “Lighting” ] {cha$

Rules

rule "Change all states"
when
Item gLights received command
then
gLights.members.forEach[light| light.postUpdate(MilightrgbLed0color.state)]

Is it correct?

Using a small g in front of Group names is a naming convention I and others use. It is not a requirement.

You are missing the “end” for your Rule.

The rule doesn’t make sense.

If you send a command to gLights, all the members of gLights will also receive that command. There is no need for a rule.

Also adding “end” to the rule nothing has changed.
Why the rule has no sense?
Please can you help me in the simplest way?
I’m feeling really stupid not understanding my mistakes
:joy:

I’ve said it twice now:

Just put gLights on your sitemap as you would the lights. Anything you do to gLights on your sitemap will be sent to all members of gLights automatically. You don’t need a Rule.

The Rule doesn’t make sense because:

  • you send a command to gLights
  • OH forwards the command to all of its members
  • the rule triggers
  • the rule tries to update the state of all the members of gLights but doesn’t need to because they have already received the command

Oh ok. I will try with the sitemap. Thanks

Perfect, when I give a command all items trigger the same command, but switches or brightness’ sliders in the sitemap have no change.

Solved this problem

rule "Change all states"
when
Item MilightrgbLed0color changed
then
MilightrgbLed0color.members.forEach[light| light.postUpdate(MilightrgbLed$
end

And grouped all light with MilightrgbLed0color

I’m only having a problem with the home app. Do you know why I’m not capable of turning my lights from color to white without using my sitemap?

I know nothing about the Home app nor MiLights

Ok thanks for the previous help