Multiway switching

Hello,

I would like to ask, how can I use multiple switches(It is not connected physically to each others) as a multiway switching.
I have 2 keemple switches and I wrote a small rules:

rule "Switch"
when Item switch1 changed
  or Item switch2 changed
then
   if (triggeringItem.state != switch1.state) {
     switch1.sendCommand(triggeringItem.state.toString)
   } else if  (triggeringItem.state != switch2.state) {
     switch2.sendCommand(triggeringItem.state.toString)
   }
end

It works perfectly when I switch from paper ui.

But when I’m trying the wall switch, strange things are happening:

  1. I turn on wall switch 1: the switch 2 will also be on
  2. I turn off wall switch 1: the switch 2 will also be off

  1. I turn on wall switch 2: the switch 1 will be off (!)
  2. I turn off wall switch 2: the switch 1 remains off

  1. I turn on wall switch 2: the switch 1 will be on
  2. I turn off wall switch 2: the switch 1 will be off

  1. I turn on wall switch 1: the switch 2 will also be off (!)
  2. I turn off wall switch 1: the switch 2 remains off

  1. turn on wall switch 1: the switch 2 will also be on
  2. I turn off wall switch 1: the switch 2 will also be off

You have some ideas, what is difference between “physical” and “logical” switching?

Thank you

Show us the events.log corresponding to your actions. Maybe your devices simply don’t “tell” openHAB when you operate them by hand.
What type of Items are these, any Dimmers involved?

Thank you. I found the problem. Use case:

  1. Switch state is OFF
  2. I call switch.sendCommand(ON)
  3. Switch state will be ON
  4. I clicked the switch on the wall. The switch led state is off, but don’t fire any event
  5. I clicked again the switch. Switch is on, but don’t fire any event
  6. I clicked again the switch. Switch is off and fire event

So sendCommand “break” the switch.

This is the type of switch: https://keemple.com/products/smart-lights-and-switches/

Have you got any idea what is wrong?

Why do you say that? It seems your switch doesn’t report status changes to openHAB. If openHAB cannot know what state the switch is in, your rule won’t work properly.

Not familiar with that switch.
How do you send it commands, which binding?

I remove all rules.

Then I tried to switch on/off on the wall:

09:31:24.671 [INFO ] [smarthome.event.ItemStateChangedEvent] - switch1 changed from OFF to ON
09:31:29.108 [INFO ] [smarthome.event.ItemStateChangedEvent] - switch1 changed from ON to OFF

Then I tried to switch on/off on the paper ui/control menu:

09:31:44.512 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'switch1' received command ON
09:31:44.520 [INFO ] [arthome.event.ItemStatePredictedEvent] - switch1 predicted to become ON
09:31:44.551 [INFO ] [smarthome.event.ItemStateChangedEvent] - switch1 changed from OFF to ON

09:31:51.690 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'switch1' received command OFF
09:31:51.699 [INFO ] [arthome.event.ItemStatePredictedEvent] - switch1 predicted to become OFF
09:31:51.727 [INFO ] [smarthome.event.ItemStateChangedEvent] - switch1 changed from ON to OFF

Then I tried again to switch on/off on the wall: not received any event.

I linked switch item to thing’s channel.

You’re right, that is weird.

If your binding and Thing/channel configuration were not a secret, someone might be able to offer some diagnostic advice.

You could set autoupdate “false” on your test switch1 Item - which would remove those predictions and allow you to see if there is any real response from the device to openHAB commands.

I try this. Same result. After that I tried Domoticz. Exactly same as openhab.
Therefore I think, the problem may be somewhere around the control unit. I used aeotec z-stick gen5.
The switches worked perfectly under zigbee.