Group binding

Hi everybody,

I am looking for a way to not only group items to a group but to bind this group to mqtt messages, the way I can do it for single items.
EG: Openhab receives a certain mqtt command and therefor switch off the whole group.

Group Wohnzimmer_Lampen "Lampen im Wohnzimmer" <light> {mqtt="<[mosquitto:home/433toMQTT:command:ON:5755916],<[mosquitto:home/433toMQTT:command:OFF:5755907]"}

This leads to the following error:

01:54:56.095 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'Wohnzimmer_Lampen' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: cannot process unknown item type Group
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.getOpenHABItem(BindingConfigReaderDelegate.java:84)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.getOpenHABItem(BindingConfigReaderDelegate.java:56)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.validateItemType(BindingConfigReaderDelegate.java:37)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:311)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:284)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:167)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:347)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:207)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:120)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:270)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.access$1(FolderObserver.java:264)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver$WatchQueueReader.processWatchEvent(FolderObserver.java:145)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.core.service.AbstractWatchQueueReader.run(AbstractWatchQueueReader.java:122)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]

Any Idea what I’m doing wrong or how to deal with that issue?

No ideas? Anyone?

What are you trying to save as the item state? The ON/OFF received from the MQTT topic or the number provided in your item definition file?

You can try to add the item type as a subparameter of the group definition, like this:

Group:Number Wohnzimmer_Lampen "Lampen im Wohnzimmer" <light> {mqtt="<[mosquitto:home/433toMQTT:command:ON:5755916],<[mosquitto:home/433toMQTT:command:OFF:5755907]"}

or

Group:Switch Wohnzimmer_Lampen "Lampen im Wohnzimmer" <light> {mqtt="<[mosquitto:home/433toMQTT:command:ON:5755916],<[mosquitto:home/433toMQTT:command:OFF:5755907]"}

if you are trying to save the ON/OFF state received from the MQTT message.

I’m not sure if its going to work, but you can try :wink:

Best regards,

Aitor

Hi Aitor,

thanks for your comment, but when I change the entry as proposed I get (in both cases) the following error:

15:04:14.842 [ERROR] [arthome.core.items.dto.ItemDTOMapper] - Group function 'AND' requires two arguments. Using Equality instead.
15:04:14.843 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'Wohnzimmer_Lampen' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: cannot process unknown item type Group
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.getOpenHABItem(BindingConfigReaderDelegate.java:84)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.getOpenHABItem(BindingConfigReaderDelegate.java:56)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.validateItemType(BindingConfigReaderDelegate.java:37)[267:org.openhab.core.compat1x:2.0.0.201701032212]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:311)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:284)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:167)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:347)[121:org.eclipse.smarthome.model.item:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:207)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:120)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:270)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.access$1(FolderObserver.java:264)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver$WatchQueueReader.processWatchEvent(FolderObserver.java:145)[120:org.eclipse.smarthome.model.core:0.9.0.201612221226]
	at org.eclipse.smarthome.core.service.AbstractWatchQueueReader.run(AbstractWatchQueueReader.java:122)[96:org.eclipse.smarthome.core:0.9.0.201612221226]
	at java.lang.Thread.run(Thread.java:745)[:1.8.0_112]
15:04:14.896 [ERROR] [arthome.core.items.dto.ItemDTOMapper] - Group function 'AND' requires two arguments. Using Equality instead.

There seems to be something wrong with the syntax. Any ideas what’s wrong?
And btw: Yes, I want to use this group as a switch to switch on and off a group of lights. Without using a binding this is working pretty well, but not with a binding. And I can’t find anything to adding a binding to a group in the documentation, so may be this isn’t supported - though it would IMHO make a lot of sense.

regards,
Stephan

Stephan,

You can’t bind a Group Item to a thing, rather you associate discrete items with a group, as is indicated with the (Wohnzimmer__Lampen) following each Switch Item’s label.

Group:Switch:OR(ON,OFF) Wohnzimmer_Lampen "Lampen im Wohnzimmer" <light>

Switch  Wonhzimmer_Lampe01 "Erste Wohnzimmer Lampe"   (Wohnzimmer_Lampen)  {mqtt="<[mosquitto:home/433toMQTT:command:5755916:ON],<[mosquitto:home/433toMQTT:command:5755907:OFF]"}
Switch  Wonhzimmer_Lampe02 "Zweite Wohhnzimmer Lampe" (Wohnzimmer_Lampen)  {mqtt="<[mosquitto:home/433toMQTT:command:5755917:ON],<[mosquitto:home/433toMQTT:command:5755908:OFF]"}

Also, I think you need to swap the 7-digit integer with the string, which I did in the made-up living room lamp items here. You will also need to add MQTT output specifications for your items if you want to control them from OH.

I don’t have a 433 MHz to MQTT device, so I can’t certify that these items are correctly formed, but I think this should help get you going in the right direction.

SK

Hi Scott,

the mqtt strings are ok, I’ve copied them from a already working item definition.
Now I worked out another solution which works perfect for me: I defined an additional switch item with a name similar to the groupname and assign the binding I want the group to have to it:

Switch Wohnzimmer_Lampen_Remote "Lampen im Wohnzimmer" <light> {mqtt="<[mosquitto:home/433toMQTT:command:ON:5755916],<[mosquitto:home/433toMQTT:command:OFF:5755907]"}

This item is not shown on the sitemap but I define a rule which reacts when it’s binding is triggered:

rule "Wohnzimmer_Lampen_Remote triggered"
when
    Item Wohnzimmer_Lampen_Remote received update
then
    if (Wohnzimmer_Lampen_Remote.state == ON){
	Wohnzimmer_Lampen.sendCommand(ON);
    }
    else if (Wohnzimmer_Lampen_Remote.state == OFF) {
	Wohnzimmer_Lampen.sendCommand(OFF);
    }
end

This way I can switch on/off the items individually (with their indivitual bindings) as well as the whole group with this rule.

regards,
Stephan