Linking commands to a group of lights

Trying to create a rule for a Group called “Office”. If either gets an command, then the other follows.

Here’s my VSC:

176 rule “Office Lights ON”
177 when
178 Member of Group Office received command ON
179 then
180 Group Office.sendCommand(ON)
181 end

183 rule “Office Lights OFF”
184 when
185 Member of Group Office received command OFF
186 then
187 Group Office.sendCommand(OFF)
188 end

I’m getting the following error in my openhab.log:

2020-08-15 18:45:35.662 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘621Erica.rules’ has errors, therefore ignoring it: [178,5]: no viable alternative at input ‘Office’
[185,5]: no viable alternative at input ‘Office’

I’m assuming there’s a syntax error. I added the row numbers to text above to help explain the error.


This syntax is not shown in any examples.
The correct syntax would be
Member of Office received command ON

A Group is an Item.
You send it a command like any other Item.

I don’t think you have thought this through.
When any one of the Items in a Group receives a command ON, your rule will trigger and send a command ON to the Group.
The Group will automatically propagate the command to each member Item.
So each member Item will get a command ON.
When any one of the Items in a Group receives a command ON, your rule will trigger and send a command ON to the Group.
The Group will automatically propagate the command to each member Item.
So each member Item will get a command ON.
When any one of the Items in a Group receives a command ON, your rule will trigger and send a command ON to the Group.

I think your system will collapse in a second or two, under the weight of thousands of commands.

Where does your command originate? A UI or other rule - why not command the Group to begin with?

I’m trying to setup a link between a Martin Jerry wall switch and a Gosund plug. When the wall switch is sent an ON command then the Gosund plug would follow the same command.

I tried this without a group but kept getting the same input error in the log.

Can’t see your “input error” so can’t comment on it.

If there’s only two Items and a one-way slaving, then just copy the command.

rule "testing"
   Item myMartinJerry received command

Are you sure this Martin Jerry wall switch makes commands in openHAB, though? It’s unusual for a device, but depends how it is configured. Look in your events.log to find out

I think you can do this without a rule altogether, using a follow profile for an item. I don’t use this, but you should be able to find a few examples scattered around the forum…


One of the most overlooked features in the doc’s. :upside_down_face: Maybe it should also be mentioned in the rules section.

1 Like

I flashed the MJ switch with Tasmota. Your rule above worked. I had a very similar rule at first for both ON and OFF, and could not get it to work last night. This morning I removed the group rule and went back to my ON and OFF rule at it worked…

I changed my rule to match your suggestion as your solution is simplier.

Just for the sake of testing and understanding the follow profile try commenting out the rule and use the follow profile to see if you get the same result. :wink:

The follow profile works with incoming state updates from devices, the OP has some secret configuration that results in his incoming messages presenting as commands it seems.

Only issue I have with the profile command is all my items were created in paperUI. I’m assuming this option would need to be configured in the text files, not paperUI.

Nope, Profiles can be set through Paper UI. If you are using Simple Mode ON, then turn it off just to adjust the profiles, then to Paper UI -> Configuration -> Items -> search the Item -> change its settings.

Running OpenHAB 2.5.7, my “Simple Mode” is off. I looked throughout the items and channels and never saw any options for profiles.

Profiles are associated with the link between an Item and a channel.

I found the ability to change the profile. I must be really dense, how do I link it to the item I want to follow?

I should repeat, I don’t think this is going to help you because your wall switch appears to be configured to produce commands. I’m not sure, because your configuration is still secret.
If you’ve left autoupdate default on your wall switch Item (so that state follows commands) it ought to work out.

Here’s how follow profile is intended for use.
Say you have LampA and LampB configured in an ordinary way, whether that’s zwave or MQTT or whatever doesn’t matter.
Both can be commanded on/off via channels to binding.
Both report their state to openHAB via channels from binding.

If we want LampB to follow LampA, we make an extra link from LampB’s channel to the LampA Item, and apply the follow profile to that link. (so LampA has two links to different channels now)

The effect of this is that when LampA Item state turns on (for whatever reason), its new state in openHAB gets passed to the follow profile - but the profile transforms it into a command and passes that to LampB channel.
LampB channel then does it usually does with commands, and it passes via binding to the LampB real device.

Thanks for the help.

I have two Insteon devices, (A) one wall switch 2466, (B) one plug-in switch module 2635. I want switch B to follow switch A. I set them up per the linking instructions above. I could only get this to work if I had each switch follow each other. Both things had one default profile link and one follow link. I’m OK with that behavior but not what I intended.

The follow setup works fine when controlling via Basic UI or my iOS app.

I cannot get the logic to work when physically switching the wall switch. In fact, I have a couple Insteon wall switches and neither send commands beyond the physical switch, i.e. nothing in the event log, but switch the light as expected.

I wonder if this lack of outbound communication is preventing the logic from firing.

If your devices are not configured to update Item states, there is nothing for a follow profile to follow.

Understood but I have a Martin Jerry switch via MQTT that reports changes from manual changes. I don’t recall seeing a configuration option for reporting changes on any devices I have configured, Insteon or MQTT.

For an MQTT binding channel, you set up a stateTopic, yes? When some remote device publishes to that topic it will result in a state update to a linked openHAB Item. That’s how this binding works.
Of course, whether any remote device actually publishes anything to that topic, or when, is beyond openHABs knowledge and control. In this case, that’s about however this Martin Jerry thingy is designed and set up.

I don’t know anything about Insteon. If you’re using one of the Insteon bindings, and you think you’re missing updates from your devices, someone can help. But we’re now at post 19 in this thread and no-one else has any idea how you’ve configured this stuff.

That is correct. I guess I didn’t realize it at the time. I’m still learning by reading as much documentation and community posts as possible. My last resort is posting my own thread.

I’m making progress now by cross linking the Insteon devices to each other and to the PLM. This seems to have corrected my issue with the devices not providing state changes back to OH2. The PLM was originally configured with another automation platform (Home Control Assistant). Cross linking wasn’t necessary for my simple setup then but I’m slowly climbing the OH learning curve.

Thanks for your help.