How to combine two items into one item?

You don’t need a rule for that:

Contact LED "Lamp status"       {modbus="slave1:5"}
Switch  BTN "Button"   	<light> {modbus="slave2:5"}
sitemap default label="Lamp" {
    Frame label="Lamp remote control" {
        Switch item=BTN label="On" visibility=[LED==OPEN]
        Switch item=BTN label="Off" visibility=[LED!=OPEN]
    }
}

In fact, you don’t need two items either:

Switch  BTN "Light"   	<light> {modbus=">[slave2:5],<[slave1:5]", autoupdate=false""}

The virtual “binding” autoupdate="false" will cause openHAB not to update the state through a sendCommand(), so, the state is only set by received messages or postUpdate().

Now this sitemap should suffice:

sitemap default label="Lamp" {
    Frame label="Lamp remote control" {
        Switch item=BTN
    }
}
2 Likes