Hue bulbs and groups

Of course, you can feed it anything. The example uses a String and to achieve what you want still feeding it a String, but the String would be the name of the Group containing the Lights that should be turned ON/OFF/Dimmed plus the new state. The Gatekeeper will then parse the Group name and the command from that String and use Design Pattern: Associated Items to get the Group by name and then feed each member of the Group to the Queue to be turned ON/OFF in turn.

See the link above.

That get’s more complicated. Do they all get set to the same dimmer value or are there different dimmer values for individual lights in the same scene? If the former, it’s no big deal, and the code above handles it. If the former, you might want to look to moving to Scripted Automation and looking at using Item metadata. If you did so, there are already libraries that can handle much of this for you.

The reason Gatekeeper exists is because of (OH 1.x and OH 2.x Rules DSL only] Why have my Rules stopped running? Why Thread::sleep is a bad idea. If you are using Scripted Automation there isn’t the same limitation so a Thread sleep isn’t a problem. But if you are using Rules DSL, you run a high risk of killing your Rules when you have long running Rules.

The only thing the GK Rules do is add some time between commands in a way that doesn’t cause long running Rules. So instead of:

        case 3 : {
            // Turn on sofa lights
                gSpots_LR_Sofa.sendCommand("100")
                gSpots_LR_Sofa_CT.sendCommand("14")
                logInfo(logName, "vSpotLightScene 3 - Turn On Sofa Lights")
            } 

you would use

        case 3 : {
            // Turn on sofa lights
                LightsGatekeeper.sendCommand("gSpots_LR_Sofa#100")
                LightsGatekeeper.sendCommand("gSpots_LR_Sofa_CT#14")
                logInfo(logName, "vSpotLightScene 3 - Turn On Sofa Lights")
            } 

That Gatekeeper Rule will

import org.eclipse.smarthome.model.script.ScriptServiceUtil

...
    // Add the commands to the Queue
    val groupName = receivedCommand.split("#").get(0)
    val cmd = receivedCommand.split("#").get(1)
    val group = ScriptServiceUtil.getItemRegistry.getItem(groupName)
    group.members.forEach[ light | commands.add(light.name+"#"+cmd) ]


    // Timer
    ... 
        if(commands.peek !== null){
            val parts = commands.poll.split("#")
            sendCommand(parts.get(0), parts.get(1)
            ...

Your scene handling Rules remain the same. The only thing GK does is enforce a little bit of delay between commands to the Lights. So the only difference is instead of commanding the Groups directly, you command a special Gatekeeper Item which triggers a rule to enforce those delays.

1 Like