Use a Contact together with a Group of Switch

I have many Switch items together in a group called groupOfSwitches.
Now I need to add a Contact because this is what I get when I want to know if a network device is online in my Fritz!Box Network.
The documentation gives this:

Contact test04 "Presence (Wifi) [MAP(presence.map):%s]"    <presence>       {fritzboxtr064="maconline:11-22-33-44-55-66"}

But I want this Contact to behave like a Switch. I don’t get it done and have many errors. Here is a simplified example:

default.items:

Group:Switch:AND(OFF,ON) groupOfSwitches
Switch test01 (groupOfSwitches) {channel="network:pingdevice:192_168_0_1:online"}
Switch test02 (groupOfSwitches) {channel="network:pingdevice:192_168_0_2:online"}
Switch test03 (groupOfSwitches) {channel="network:pingdevice:192_168_0_3:online"}
Contact test04 (groupOfSwitches) {fritzboxtr064="maconline:AA-BB-CC-DD-EE-FF", autoupdate="false"}

default.sitemap

sitemap default label="Default"
{
Switch test01 
Switch test02 
Switch test03 
Switch test04
}

I also tried with a transform (Map Transformation transformation-map - 2.5.2) but didn’t get rid of the errors.

The switches are used in a very complicated scenario. But I’m just using the item groupOfSwitches.

I get errors like:

[ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null
java.lang.NullPointerException: null
    at org.openhab.binding.network.internal.handler.NetworkHandler.refreshValue(NetworkHandler.java:75) ~[?:?]
    at org.openhab.binding.network.internal.handler.NetworkHandler.handleCommand(NetworkHandler.java:110) ~[?:?]
    at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]
    at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_241]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_241]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_241]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_241]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_241]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_241]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241]

And from the addon this errors:

[ERROR] [ing.fritzboxtr064.internal.Tr064Comm] - Error constructing request SOAP msg for setting parameter. local part cannot be "null" when creating a QName
[ERROR] [ing.fritzboxtr064.internal.Tr064Comm] - Could not determine data to be sent to FritzBox!
  • Hardware: Synology NAS DS716+ with Paketinstallation for OpenHAB and Mosquitto
  • Java Runtime Environment: Java 8 1.8.0_241
  • openHAB version: 2.5.2
  • FritzBox AddOns: Fritzbox TR064 Binding (binding-fritzboxtr0641 - 1.14.0)

Can anyone help me?

It cannot.
Maybe this helps, depends what very complicated scenario is about

Otherwise, you can create a dummy virtual Switch Item, and have a rule update its state from the Contact Item.

Never going to work, this only affects display, not actual Item state.

The errors mentioned don’t really seem to relate to your Group issue, but maybe you are sending commands via Group which Contact Items cannot handle.

1 Like

Thanks a lot @rossko57 I will use this idea which helped me a lot:

Your are right @rossko57. I think it is the following line of code in my rules:

gPresencesTotal.members.forEach[ SwitchItem s | s.sendCommand(OFF)]

The Item looks like:

Group:Number:SUM gPresencesTotal

gPresencesTotal consists of Switch and Contact Elements. Can I change my rule so the s.sendComman(OFF) is only active for the Switch Elements? So can I filter them somehow?

Yes. Expand the forEach code block and test the Item type before sending commands.Example of this kind of thing

1 Like