To be able to use the rolling code receiver in my OpenHAB, the first thing we need to enable the GPIO binding in the OpenHAB. There is a fairly good documentation of it in the OpenHAB wiki:
https://github.com/openhab/openhab/wiki/GPIO-Binding
I mostly done, what is in it, but some modifications were needed.
1. Install the native JNA library:
apt-get install libjna-java
2. Modify /opt/openhab/start.sh
Add -Djna.boot.library.path=/usr/lib/jni into the list of java command line parameters
3. Modifiy the /etc/init.d/openhab
Add -Djna.boot.library.path=/usr/lib/jni into the DAEMON_ARGS parameters
and add the commands to unexport the gpio pins on stopping the daemon
4. From the previously downloaded distribution-1.8.1-addons.zip (part of the OpenHAB downloads) expand the following files:
org.openhab.io.gpio org.openhab.binding.gpiointo the /opt/openhab/addons directory
5. Restart openhab:
/etc/init.d/openhab restart
Now the OpenHAB is ready to handle the GPIO. We need to make the configuration changes, to be able to use it.
6. Add the required items
The GPIO inputs can be represented by Contacts in the OpenHAB, so edit one of the files in the /opt/openhab/configurations/items directory (I already dropped the demo config from here, so I've the config of my house) and add the following:
Contact KeeLoq_Remote_A "Remote A [MAP(en.map:%s]" (<ID of your Group>, Windows) { gpio="pin:66"}
Contact KeeLoq_Remote_B "Remote B [MAP(en.map:%s]" (<ID of your Group>, Windows) { gpio="pin:67"}
Contact KeeLoq_Remote_C "Remote C [MAP(en.map:%s]" (<ID of your Group>, Windows) { gpio="pin:69"}
Contact KeeLoq_Remote_D "Remote D [MAP(en.map:%s]" (<ID of your Group>, Windows) { gpio="pin:68"}
When everything is fine you should see the following after the OpenHAB reload the configuration:
And when you push a button on the remote, the closed text change to open, and back when you release.
7. For the lighting it will not be enough
We need to keep the status of the light, as it switched on or off. So I added a Switch into the items config:
Switch Garage_Light "Garage Light" (<ID of your Group>, Lights)
This is only a regular switch, so if you want to control it from the remote you need some rules. You can add it to a rules file in the /opt/openhab/configurations/rules folder:
rule "GarageLightToggle" when Item KeeLoq_Remote_B changed from CLOSED to OPEN then if(Garage_Light.state == ON) { sendCommand(Garage_Light, OFF) } else { sendCommand(Garage_Light, ON) } endAfter this, when you push the B button on the remote, it will switch the web control, on and off
This still not change the physical light. I have to create/buy some actor for this.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.