I recently started using OH2, by first trying to setup RFXCom binding and control several ClickOnClickOff switches connected to lights and a roller shutter. I control everything (for now) using Paper UI Control section, and I managed to make the first functional .rules file using simple time/cron-based commands.
I purchased a double COCO manual switch (type AWST-8802), with the intention to control lights both manually, as well as through OH2.
I used Paper UI to discover the two channels (left and right button) for the AWST-8802 through the Inbox, and added both as Things to Paper UI. Next, I need to add Items, when I declare Items of type Switch, I see in the Paper UI Control window that I can switch to the two positions, on and off.
But how should I link the freshly made AWST-8802 manual switch to the light I want to control?
Do I need to make another .rules file? I did several simple attempts, such as below, but neither of them seem to work.
// left switch
Item KAKU_AWST_8802_L received command ON
// left switch
Item KAKU_AWST_8802_L received command OFF
Could somebody provide me with an example .rules file how to link a COCO manual switch (=sensor) to a COCO light switch (=actuator)?
First, please use code fences when posting code in the forum
No, just another rule, it can be in the same file as before but I recommend that you separate the rules files according to function. for example: heating.rules, network.rules, presence.rules, lighting.rules…
Have you tried:
// left switch
Item KAKU_AWST_8802_L changed
if (KAKU_AWST_8802_L.state == UNDEF) return; // Do nothing
Thanks, I will try to remember to use code fences next time!
Unfortunately, your suggestion did not give the results I hoped for.
In the case I tested, both Items KAKU_AWST8802_L (=manual RF switch ) and KAKU_AGDR_3500 (=outdoor RF plug connected to a lamp) were of Item type “Switch”. The Thing for the manual switch has its Command linked to item KAKU_AWST8802_L, the Thing for the lamp has its Command linked to item KAKU_AGDR_3500.
User the Paper UI Control panel, the state of the manual switch changes from ON to OFF when I push the manual switch. Also, I can switch on and off the lamp from the Control panel by moving the switch slider left/right.
So when I use your .rules file, pushing the manual switch results in both switch sliders to left/right. But the problem is that the lamp stays off at all time. However, when I move the lamp switch slider left/right in the UI, the lamp does go off/on!
I don’t understand why a use-case as simple as this does not seem to work properly.
I also defined the manual switch as Contact (i.o. Switch), using OPEN/CLOSE (i.o ON/OFF), adapted the .rules file to this, but got no working results either…
So I am open to any other suggestions. The sendCommand seems to work in terms of updating the UI. Or should I use postUpdate to tell the Binding to switch on the lamp as well?