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!