Linking additional wallswitch to Intertechno remote controlled plug

I have an Intertechno remote control plug which I use with RFXCom and the following items:

Switch plug_1a "Lampe 1" <light> {channel="rfxcom:lighting4:abc:command"}
Switch plug_1b "Lampe 2" <light> {channel="rfxcom:lighting4:def:command"}
Switch plug_1c "Lampe 3" <light> {channel="rfxcom:lighting4:hij:command"}
Switch plug_1d "Lampe 4" <light> {channel="rfxcom:lighting4:klm:command"}

I can now switch the plugs/lights both with the original remote control and OpenHAB. I now have added another cheap 433 Mhz device, a wallmounted switch with two ON/OFF buttons, which I want to use to switch groups of these plugs/lights.

Switch wallswitch_1a "Wandschalter 1a" <switch> {channel="rfxcom:lighting2:uvw:command"}
Switch wallswitch_1b "Wandschalter 1b" <switch> {channel="rfxcom:lighting2:xyz:command"}

Usually this switch has to be paired to some device, I didn’t do that, as my idea would be to simply receive the command the switch sends and then make OpenHAB act accordingly. As this 433 Mhz stuff has no feedback, I think this should be no problem. I created the following rule to process the wallswitch’s ON/OFF commands.

rule "wallswitch 1a"
when
Item wallswitch_1a received update	
then
val current_ws_1a = wallswitch_1a.state.toString
val current_p_1a = plug_1a.state.toString
val current_p_1b = plug_1b.state.toString
val current_p_1c = plug_1c.state.toString
if (current_p_1a != current_ws_1a) {
	plug_1a.sendCommand(current_ws_1a)
}
if (current_p_1b != current_ws_1a) {
	plug_1b.sendCommand(current_ws_1a)
}
if (current_ws_1a == OFF) { 
	if (current_p_1c != OFF) {
		plug_1c.sendCommand(current_ws_1a)
	}
}
end
rule "wallswitch 1b"
when
    Item wallswitch_1b received update
then
    val current_ws_1b = wallswitch_1b.state.toString
val current_p_1d = plug_1d.state.toString
if (current_p_1d != current_ws_1b) {
	plug_1d.sendCommand(current_ws_1b)
}	
end

The idea is to use “wallswitch 1a” to turn on “plug_1a” and “plug_1b” at once. When switched off, “plug_1c” should be turned off in addition to the other two items. “wallswitch 1b” simply should switch “plug_1d”.

This kind of works. However, OpenHAB seems to try to be smarter than the 433 Mhz protocol as it gets confused when I use the original remote control of the plugs and the new wallswitch alternatively. OpenHAB seems to remember the current state (or what it thinks is the current state) of the devices and therefore not always processes the presses of the wallswitch correctly (that’s my interpretation).

I tried to work around that by making the above rule complex (as you can see), but it somehow does not work 100%. Also, the icon and the switch symbol in the sitemap seem to get out of touch very often (e.g. switch says on and icon says off or something like that).

Above all, the rule seems to be not very elegant. I have a faint idea that linking the channels might also be a better solution, however I don’t really have an idea how to make this “right”.

Any help appreciated!

OH isn’t trying to be smarter. OH only knows what it knows. Once an Item is given a state it keeps that state until it is given another state.

If you use the original remote control then you need to update all the Items involved to reflect their current state or else OH’s state will get out of sync with the real state of the lights.

If these are all OH 2.x bindings, you can use the follow Profile perhaps to keep them in sync but really you don’t provide enough details to really help. We need to know which Items change when you use the 433 switch compared to which Items change when you use the original remote and which Items end up out of sync.

Well, all items involved in the situation are quoted in the OP :wink: . It’s simple, dumb 433 Mhz stuff without back channel, fire and forget the command.

If I use the original Intertechno remote, the items plug_xx change.
If I use the additional 433 Mhz switch the item wallswitch_xx changes.

No additional changes, no interdependencies.

I already discovered this “follow” stuff in the docs, however, I didn’t really grasp the concept. I would appreciate an example.

The follow profile is wire simple. You have two or more channels linked to a single item. When one of the channels change, the other channel gets a command to match the change.

I think what you are saying is that you can use the remote to change the lights, and there is no possible way for openHAB to have any knowledge of what was done?
I can’t reconcile that with

I know it all seems obvious from your end, but it isn’t from here. You have openHAB listening to the remote, perhaps?

Well, probably you can see it this way, as the pyhsical switchable plugs themselves just react to the remote and do not actively send anything. I guess for this Intertechno stuff there is no other way to handle it.

So plug_xx listens to the original remote and sends the original remote’s commands. The (physical) plugs just react to this - whether OpenHAB or the original remote send the signal.
wallswitch_xx listens to the commands the wallswitch sends, This commands do not really have any special meaning and are paired to nothing, I want OpenHAB to receive the commands and then operate the plug_xx items to have an additional switch for the plugs.

And now, if I alternately use the original remote and the wallswitch, the situation is like this:
The original remote always works, it just sends the commands.
If I e.g. turned lights off with the original remote and want to turn them on with the wallswitch, I have to toggle off/on the wallswitch, as if OpenHAB’s wallswitch item thinks the plug is already on and there is no need to send the command.

openHAB’s wallswitch Item does not think anything. Your rules that you have shown us make the decision about sending commands based on state.

Maybe you could show us event.log snippets, of good behaviour and bad behaviour, like a demo of using the remote and a demo of using wallswitch?

I’ll look into this “follow” stuff fist.