Treating 2 hue bulbs as 1 device

Hello,

 I recently added some Hue bulbs to my setup.  Most of what I have is Insteon and though I have some Insteon bulbs I also have switches, so I can control the bulbs with the switches.

Most of my Hue bulbs are single devices which are easy to deal with, but in my pantry I have 2 bulbs that I want to control as single devices.  Right now I have them defined as Pantry 1 and Pantry 2 and that's how they show up on my sitemap.  

How would I go about changing this so Pantry 1 and Pantry 2 are still available to Alexa, but on my Classic GUI I can only show a single device called Pantry that will turn both on or off?

Clearly I’m fairly new to OpenHab as I’m sure this is a common thing to do.

Thanks
-Bob

  • Platform information:
    • Hardware: CPUArchitecture/RAM/storage Raspberry Pi 3
    • OS: what OS is used and which version OpenHabian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: The latest, I just upgraded.
  • Issue of the topic: please be detailed explaining your issue
  • Please post configurations (if applicable):
    • Items configuration related to the issue
    • Sitemap configuration related to the issue
    • Rules code related to the issue
    • Services configuration related to the issue
  • If logs where generated please post these here using code fences:

Hello,

You need a proxy item, eg:

Switch PantryLights "Pantry Lights"

and then a rule:

rule "pantry lights"
when
    Item PantryLights changed
then
    PantryLight1.sendCommand(triggeringItem.state)
    PantryLight2.sendCommand(triggeringItem.state)
end
    

Hope it helps

I would place the items in a group. Then sendCommand to that group. That way when you add more items, you only add items to that group and you won’t need to change any rule.

If you are using item files, you can combine the channel information of multiple devices into one item. Just separate them with a comma.

I did that for a some colorbulbs, because it is impossible to set them on the same color manually. (without a hassle)

Can you show me an example of how to do this? I’m confused about groups, I see several references to groups in items and sitemaps and they seem like 2 different things.

-Bob

Cool, I’ll try that right now. I didn’t know you could do that.

Thanks
-Bob

I just tried it and it works awesome.

Thanks
-Bob

For this particular solution I like LuckyMallari’s suggestion as it works really well.

However, I have another rule that I’d like to create that will turn on lights on the path to my bedroom which your solution looks ideal for.

I’ve followed your syntax and my proxy is showing up, but my rule isn’t working. I don’t see anything in the openhab2.log that’s helping me understand. I haven’t found a good way to diag rules, on my Unix machines I can give a bash script a -x so that I can watch it run, is there something similar with rules?

Thanks
-Bob

triggeringItem is new on openHAB 2.2
Are you running 2.2?

Yes, I’m running OpenHabian on a Rasberry Pi 3. I just updated last week so I’m very current.

dpkg --list | grep openhab
ii openhab2 2.2.0-1 all openhab2

Ok, I have something meaningful, but I don’t understand it.

Configuration model ‘bedtime.rules’ has errors, therefore ignoring it: [3,2]: no viable alternative at input ‘item’
[10,2]: no viable alternative at input ‘item’

Here’s my item:

Switch BedTime “Bed Time” (House,Bedroom,Light) [ “Lighting” ]

Here are my rules:

rule "Bed Time Lights On"
when
item BedTime changed from OFF to ON
then
sendCommand(PantryLights,ON)
end

rule "Bed Time Lights Off"
when
item BedTime changed from ON to OFF
then
sendCommand(PantryLights,OFF)
end

I figured I’d start simple and use the more elegant syntax once I have the basics working. My item shows up in Classic UI and I can see events.

2018-03-04 17:42:29.931 [ome.event.ItemCommandEvent] - Item ‘BedTime’ received command ON
2018-03-04 17:42:29.939 [vent.ItemStateChangedEvent] - BedTime changed from OFF to ON

So, what is going on here?

Thanks
-Bob

Nevermind, I figured it out. I didn’t realize that reserved words like Item were case sensitive.

-Bob

Happy to hear that.
To Debug rules use logging.
logInfo(“test”, value you want as string)

You should you the following syntax for sendCommand:

PantryLights.sendCommand(OFF)

This is the recommended syntax. Use the item method instead of the action.

I thought about the group solution for your first post but I personally prefer doing it in rules as it offers more flexibility without adding too many groups.

Regards