Elegant way to define contact

I want to define a contact item for every door/window.

I don’t get the state directly though, I use Nikobus and I get a switch command (to ON via binding) when the door is opened and another switch command (to ON via binding) when door is closed.

My current config works but I define 2 switches and 1 contact and 2 rules to basically define one door/window contact

I’m wondering, is there a smarter way to define the contact, for example by directly linking the Nikobus binding to the contact (similar as the usual MQTT binding links with contact)

This is my current configuration
items:

Switch BI_1_Close_DeurKeuken {nikobus="#N2792A6"}
Switch BI_1_Open_DeurKeuken {nikobus="#N6792A6"}
Contact ContactDeurKeuken "Deur keuken"

Rule:

rule "Keuken deur dicht" when Item BI_1_Close_DeurKeuken received update ON then postUpdate(ContactDeurKeuken,CLOSED) end
rule "Keuken deur open" when Item BI_1_Open_DeurKeuken received update ON then postUpdate(ContactDeurKeuken, OPEN) end

I just would like to make my code a bit more elegant :slight_smile:

I don’t think so. I didn’t see any way to transform the data from Nikobus without using a Rule either so I think what you have might be about as good as it gets.

OK, thanks, good to know. As said it’s working fine but when I see some of the OH community member writing impressive pieces of code often very efficient and condensed I always want to learn :slight_smile: