OpenHAB Exec Binding explained in detail on 433MHz radio transmitter example

Looks interesting, but I already done the http part in my bash scripts.
I feel that the polling bit is the only thing lacking from the exec2 binding, but it can perhaps be achieved with the use of a timer and a post-update into the virtual switch.

Then you have multiple options.

  1. set up a thing with Intervall for each value you want to update.
  2. set up a rule with a cron expression. And trigger the updates in the rule.

But i still think your solution has more overhead then doing it with the http binding.

1 Like

so after reading and going through a lot of sites and this page here I was not really able to get it happening but I think I’m close to to where I wanted to be but please I need some more help, I would like if someone can point me to the right path for setting up my 433MHZ door sensor. I have installed 433UTILS into my Pi since I find it easier to deal with, please tell me where I went wrong, here is what my items, rules and things look like :
RULES : rule "DOORSENSOR"
when
Item DOORSENSOR chaned to OPEN
then
postUpdate (433Utils/RPi_utils.state == OPEN){
}

if(receivedCommand == 14756833){ postUpdate DOORSENSOR.statusCommand =(“OPEN”) }else{ if DOORSENSOR.stateCommand =(“CLOSE”) postUpdate (433Utils/RPi_utils.state == CLOSE) }

end

ITEMS : Switch DOORSENSOR { channel=“exec:command:./RFSniffer:run” }
String DOORSENSOR { channel=“exec:command:./RFSinffer:input” }

THINGS :Thing exec:command:./RFSniffer [
command="/home/pi/433Utils/RPi_utils/./RFSniffer 14756833",
interval=2,
autorun=true]

I need statues for OPEN/CLOSE for door sensor to appear on habpanel. Using Raspberry Pi 3 with OH2

@ramy_rutu please use code fences to make you code readable.
Use the buttons at the top row of the text box. Or use the trippel quotation mark.

```
your code goes here
```

Please edit you previous post, thank you.

First I dont think using “.” and “/” in the thing name is a good idea.
Second you have two items called DOORSENSOR one Switch and one String, how schould openhab know which you want to control?
Third typos “chaned” is not “changed”

I will add some comment to your code:
.things

THINGS :Thing exec:command:./RFSniffer [ /* dot and slash are pretty bad in names */
command="/home/pi/433Utils/RPi_utils/./RFSniffer 14756833", /* does RFSniffer work like this ?*/
interval=2, 
autorun=true]
/* as the sniffer usually sniff continously the first execution will never stop, untill someone stops it*/

.items

/* two items with the same name, this won´t work */
Switch DOORSENSOR { channel=“exec:command:./RFSniffer:run” } /* with this switch connected to the Thing run channel you can start the execution when toggleing to on */
String DOORSENSOR { channel=“exec:command:./RFSinffer:input” } /* this is the channel where you can input some data to the thing, not what the thing will answer back to you */

/* no output channel so if the command line gets executed we will never know what the result was.*/

.rules

rule "DOORSENSOR"
   when Item DOORSENSOR chaned /*changed*/ to OPEN
then
   postUpdate (433Utils/RPi_utils.state == OPEN){} 
  /*? Where is this item defined? And "/" in a name is a no go.*/
  /* this is a mix if a postUpdate and if clause ? */
   
   if(receivedCommand == 14756833){ /* probably should be compared with a string "14756833" if i asume DOORSENSOR  is the string item. */
     postUpdate DOORSENSOR.statusCommand =(“OPEN”) 
   /* postUpdate(DOORSENSOR, OPEN)  DOORSENSOR.postUpdate(OPEN) or When i asume DOORSENSO is the switch but who knows */
   }else{ 
     if DOORSENSOR.stateCommand =(“CLOSE”)  
       postUpdate (433Utils/RPi_utils.state == CLOSE) 
   }
  /* else if (DOORSENSOR.state == CLOSED){ postUpdate(DOORSENSOR, CLOSE ) } ,  and here is the best thing posting to the same item the allready known state. You have to give each item an unique name.*/
end

Please start over again, read carefully try some simple things for which you find Tutorials and first try to reproduce them and understand how everything works. Don´t rush fast. For Openhab there is a lot which has to be learned.

But, to answer your question:“This does not work at all”.
If RFSniffer would only listen to the given code and returns the recieved command, it wont stop.
So starting a RFSniffer every 2 second is not a good idea, besides the Reciever is allready in use by the first Sniffer.
imagine you would like to lsiten to multiple contacts, but if the one Thing you allready block the receiver.

You don’t want to regularly trigger something, you want to continously wait for an event like a received contact status.

Thus you will need to set up somthing like a MQTT server, which will wait for incomming data and forwards it to the Openhab MQTT Binding client.
And you will need a process which listens to the receiver and publish the data to the MQTT Server.
Have a look here, here and here for more info.

Or at least something like that.

rule "Wohnzimmer"
   when Item Wohnzimmer changed to OPEN
then
   postUpdate (Wohnzimmer.state == OPEN){}
   if(receivedCommand == 14756833){
     postUpdate(DOORSENSOR, OPEN)
   }else{
     if Wohnzimmer.stateCommand =(“FALSE”)
       (Wohnzimmer_Out.state == CLOSED)
   }
end

Group Licht_EG "Licht"

Switch Wohnzimmer

Switch Remote_Send { channel="exec:command:remote-send:run" }
String Remote_Send_Args { channel="exec:command:remote-send:input"}
String Remote_Send_Out { channel="exec:command:remote-send:output" }

```php
sitemap funklicht label="Erdgeschoss" {
    Frame label="Licht" {
        Switch item=Wohnzimmer icon="light"
        }
}

Thing exec:command:Wohnzimmer [
command="/home/pi/433Utils/RPi_utils/Wohnzimmer_decke.sh %2$s",
interval=0,
autorun=false




I have tried everything  on this page and I don't  know what als I should do ... I am only looking to get a states from my 433mhz door sensor to show on my openhab2 at habpanel for door open / door close. I am not expert for using python and Linux but I'm trying my best . if anyone here will post the right scripts for this project I would really appreciate it. I know most of the scripts in this page is for sending code but for my project its receiving code to give a status for open or close

@Josar you were absolutely right!
I ended up using the http binding with cache.
One GET returns multiple parameters.
Here are my items for picking out single values from the cache string:

ret=OK,pow=1,mode=4,adv=,stemp=24.0,shum=0,dt1=25.0,dt2=M,dt3=25.0,dt4=24.0,dt5=24.0,dt7=25.0,dh1=AUTO,dh2=50,dh3=0,dh4=0,dh5=0,dh7=AUTO,dhh=50,b_mode=4,b_stemp=24.0,b_shum=0,alert=255,f_rate=A,f_dir=0,b_f_rate=A,b_f_dir=0,dfr1=5,dfr2=5,dfr3=5,dfr4=A,dfr5=A,dfr6=5,dfr7=5,dfrh=5,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd6=0,dfd7=0,dfdh=0

http.cfg:

# configuration of the first cache item
ACcache.url=http://192.168.1.8/aircon/get_control_info?
ACcache.updateInterval=10000
# configuration of the second cache item  
ACsensorCache.url=http://192.168.1.8/aircon/get_sensor_info?
ACsensorCache.updateInterval=60000

.items

// http items
String ACpowerState                                               {http="<[ACcache:6000:REGEX(.*?pow=.*?([0-9]*).*)]"}
String ACsetTemp                                                  {http="<[ACcache:1000:REGEX(.*?stemp=.*?([0-9\\.0-9]*).*)]"}
String ACmode                                                     {http="<[ACcache:1000:REGEX(.*?mode=.*?([0-9]*).*)]"}
String ACfanRate                                                  {http="<[ACcache:1000:REGEX(.*?f_rate=.*?([AB34567]*).*)]"}
String ACfanDir                                                   {http="<[ACcache:1000:REGEX(.*?f_dir=.*?([0-9\\.0-9]*).*)]"}
String ACinDoorTemp "Inside temperature [%s °C]" <temperature>    {http="<[ACsensorCache:1000:REGEX(.*?htemp=.*?([0-9\\.0-9]*).*)]"}
String ACoutDoorTemp "Outside temperature [%s °C]" <temperature>  {http="<[ACsensorCache:1000:REGEX(.*?otemp=.*?([0-9\\.0-9]*).*)]"}

@OMR glad i could help.

@ramy_rutu first off all, what you wan´t is not achieve very fast. And note at all trivial.

Second watching your code, i think you miss proper undestanding for programming. Your code is full of erros.

Third i posted the basics of how you will get this done, you schould have followed them and make your solution.

Fourth it seems also you miss the propper manners as you expect us to do everything for you and call it support.

But you are lucky as a wanted to do a little coding exercise so i will post a solution in a seperate thread.

All good Josar. I have not missed anything for manner or respect . I have said that I don’t know how to code and I’m new, I am trying to learn small stuff and if I wanna fix my code than I need to study and study to understand what’s going on and I got no time not a lot… I thought someone here could just take my code and fix to help me and help others in this community . After all I do understand what you trying to say

Peace

@ramy_rutu as stated before with your approach what you want to do is not possible.

So please try to do something which is possible, then it will make sense to correkt your code.

Maybe try to read out the temperatures of your RPI.

Hey @ramy_rutu here you go.

Hey there.
At the moment I try to implement the 433MHz sender. When I fire up the send command from root it is working fine:

/opt/SourceCode/raspberry-remote# ./send 100001 1 1
using pin 0
sending systemCode[100001] unitCode[1] command[1]

When I try to send the same command as the openhab user I get the following error:

/opt/SourceCode/raspberry-remote# sudo -u openhab ./send 100001 1 1
using pin 0
wiringPiSetup: Must be root. (Did you forget sudo?)

I installed openhabian on a fresh debian installation with the setup wizard, because it’s a BananaPi (first edition, Dualcore, 1GB RAM)

I had to create the “gpio” group manually, it wasn’t created during the openhabian setup. Maybe there’s a fault. I tried a lot of things I’ve found in the forums but nothing worked.

Maybe someone have a clue what’s going wrong on my installation.

If you need more informations please tell me what to do :slight_smile:

Thanks a lot!
kovu94

What I’ve tested until now:

sudo visudo:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
openhab ALL=(ALL) NOPASSWD: ALL
www-data ALL=(ALL) NOPASSWD: ALL
openhabian ALL=(ALL) NOPASSWD: ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
%sudo   ALL=(ALL:ALL) ALL
openhab ALL=(ALL) NOPASSWD: ALL
www-data ALL=(ALL) NOPASSWD: ALL
openhabian ALL=(ALL) NOPASSWD: ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

  • chmod 777 for the send file
  • several right things I’ve found in the forums
  • several things in the openhab files (things, items, sitemap, etc.) - but I think it wont work until it works from command line
  • exec binding is installed (several attempts, first with habmin, after it through paperUI)

Details for the bananapi:

login as: root
 ____                                  ____  _
| __ )  __ _ _ __   __ _ _ __   __ _  |  _ \(_)
|  _ \ / _` | '_ \ / _` | '_ \ / _` | | |_) | |
| |_) | (_| | | | | (_| | | | | (_| | |  __/| |
|____/ \__,_|_| |_|\__,_|_| |_|\__,_| |_|   |_|


Welcome to ARMBIAN 5.38 stable Debian GNU/Linux 9 (stretch) 4.14.18-sunxi
System load:   0.45 0.36 0.40   Up time:       20 min
Memory usage:  23 % of 998MB    IP:            192.168.178.5
CPU temp:      36°C
Usage of /:    16% of 15G

Is it possible that we can check that the “gpio” group has the correct bindings in the system. I’m not a linux crack but I think there are some permissions I’ve to give to the group after creating it.

The point of the gpio group is that the files that represent the GPIO pins have permission to read/write for the group gpio.

Taken from a raspberry pi

rich@cerberos:~   ls -l /sys/class/gpio/
total 0
-rwxrwx--- 1 root gpio 4096 Jan 29 16:17 export*
lrwxrwxrwx 1 root gpio    0 Jan 29 16:17 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0/
lrwxrwxrwx 1 root gpio    0 Jan 29 16:17 gpiochip100 -> ../../devices/gpiochip2/gpio/gpiochip100/
lrwxrwxrwx 1 root gpio    0 Jan 29 16:17 gpiochip128 -> ../../devices/gpiochip1/gpio/gpiochip128/
-rwxrwx--- 1 root gpio 4096 Jan 29 16:17 unexport*

When I look on my Banana Pi I see that those files only have permissions for root.

rich@chiron:~   ls -l /sys/class/gpio/
total 0
--w------- 1 root root 4096 Feb 12 11:50 export
lrwxrwxrwx 1 root root    0 Feb 12 11:50 gpiochip0 -> ../../devices/platform/soc/1c20800.pinctrl/gpio/gpiochip0/
lrwxrwxrwx 1 root root    0 Feb 12 11:50 gpiochip352 -> ../../devices/platform/soc/1f02c00.pinctrl/gpio/gpiochip352/
--w------- 1 root root 4096 Feb 12 11:50 unexport

Since sys is a tmpfs directory (meaning it gets created and populated on system boot) I don’t know how one would change the permissions on these files and have them stick through a reboot.

So I’m guessing you cannot access the GPIO on a Banana Pi as any user other than root.

@kovu94 and @rlkoshak i never did it myself but i think this could help to get it work.

and be aware that the udev rule has to be adapted from

/sys/devices/platform/soc/*.gpio/gpio

to

/sys/devices/platform/soc/*.pinctrl/gpio

or maybe

/sys/devices/platform/soc/*/gpio

or use

1 Like

I’m sure I tested this last weekend but I’ll try it again tomorrow because I’m not sure I made the dist-upgrade.

If it will not work I have to switch to a original raspberry, as @rikoshak mentioned. Maybe it’s by design for the banana pi.

Many thanks for you pointing me in the right direction. I’m back tomorrow evening with the results.

Good night :slight_smile:

Sorry. It doesn’t seem to work.

The udev rule is edited this way:

# /etc/udev/rules.d/80-gpio-noroot.rules
# Acces to GPIO without root
#
#  Change group
SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chown -R root:gpio /sys/devices/platform/soc@01c00000/1c20800.pinctrl/gpio'"
# set acces permission
SUBSYSTEM=="gpio", PROGRAM="/bin/sh -c '/bin/chmod -R ug+rw /sys/devices/platform/soc@01c00000/1c20800.pinctrl/gpio'"

Because that’s the only “soc” in the folder:

[15:27:15] root@bananapi:/sys/devices/platform/soc@01c00000/1c20800.pinctrl/gpio# ls -la
total 0
drwxrwxr-x 3 root gpio 0 Feb 13 15:24 .
drwxr-xr-x 5 root root 0 Feb 13 15:26 ..
drwxrwxr-x 3 root gpio 0 Feb 13 15:24 gpiochip0
[15:27:17] root@bananapi:/sys/devices/platform/soc@01c00000/1c20800.pinctrl/gpio#

I use this version of WiringPi at the moment, the one you suggested doesn’t work.

Error with your Version:

Unable to determine hardware version. I see: Hardware   : Allwinner sun7i (A20) Family
,
 - expecting BCM2708, BCM2709 or BCM2835.
If this is a genuine Raspberry Pi then please report this
to projects@drogon.net. If this is not a Raspberry Pi then you
are on your own as wiringPi is designed to support the
Raspberry Pi ONLY.

It seems to work:

[15:31:46] root@bananapi:/opt/SourceCode/WiringBP# gpio readall
 +-----+-----+---------+------+---+--Banana Pro--+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT5 | 0 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 | ALT5 | 0 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT2 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 0 | IN   | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT5 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT5 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT5 | 0 | 23 || 24 | 0 | ALT5 | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 0 | ALT5 | CE1     | 11  | 7   |
 |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
 |   5 |  21 | GPIO.21 |   IN | 0 | 29 || 30 |   |      | 0v      |     |     |
 |   6 |  22 | GPIO.22 | ALT4 | 0 | 31 || 32 | 0 | ALT4 | GPIO.26 | 26  | 12  |
 |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
 |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
 |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+--Banana Pro--+---+------+---------+-----+-----+
[15:31:49] root@bananapi:/opt/SourceCode/WiringBP#

@rlkoshak - when I use “ls -l /sys/class/gpio” now it looks good:

[15:31:49] root@bananapi:/opt/SourceCode/WiringBP# ls -l /sys/class/gpio/
total 0
-rw-rw---- 1 root gpio 4096 Feb 13 15:25 export
lrwxrwxrwx 1 root gpio    0 Feb 13 15:25 gpiochip0 -> ../../devices/platform/soc@01c00000/1c20800.pinctrl/gpio/gpiochip0
lrwxrwxrwx 1 root gpio    0 Feb 13 15:25 gpiochip413 -> ../../devices/platform/soc@01c00000/1c2ac00.i2c/i2c-0/0-0034/axp20x-gpio/gpio/gpiochip413
-rw-rw---- 1 root gpio 4096 Feb 13 15:25 unexport
[15:32:30] root@bananapi:/opt/SourceCode/WiringBP#

But still this damn error:

[15:33:42] root@bananapi:/opt/433Utils/RPi_utils# sudo -u openhab ./codesend 9385235
wiringPiSetup: Must be root. (Did you forget sudo?)
[15:33:50] root@bananapi:/opt/433Utils/RPi_utils#

I think I’m going for an original RPi3 soon…

@kovu94 How are the permissions of

pi@raspberrypi:~ $ ls -l /sys/class/gpio/
total 0
-rwxrwx--- 1 root gpio 4096 Feb 13 23:02 export
lrwxrwxrwx 1 root gpio    0 Feb 13 00:07 gpio27 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio27
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip100 -> ../../devices/gpiochip2/gpio/gpiochip100
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip128 -> ../../devices/gpiochip1/gpio/gpiochip128
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 unexport

Maybe add a udevrule to adjust this permissions, additionally. And also for the folders where the links show to.
As the gpiochipxxx files created when configuring the pins i think. So could you try to set up a pin as output and then list the folder to see the permission for it when the pin is actually there?

So my setup looks as follows:

pi@raspberrypi:/sys/class/gpio $ ls -l
total 0
-rwxrwx--- 1 root gpio 4096 Feb 13 23:02 export
lrwxrwxrwx 1 root gpio    0 Feb 13 00:07 gpio27 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio27
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip100 -> ../../devices/gpiochip2/gpio/gpiochip100
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 gpiochip128 -> ../../devices/gpiochip1/gpio/gpiochip128
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 unexport

pi@raspberrypi:/sys/class/gpio $ ls -l ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio27
total 0
-rwxrwx--- 1 root gpio 4096 Feb 13 00:07 active_low
lrwxrwxrwx 1 root gpio    0 Feb 13 00:07 device -> ../../../gpiochip0
-rwxrwx--- 1 root gpio 4096 Feb 13 23:02 direction
-rwxrwx--- 1 pi   pi   4096 Feb 13 23:02 edge
drwxrwx--- 2 root gpio    0 Feb 13 00:07 power
lrwxrwxrwx 1 root gpio    0 Feb 13 00:07 subsystem -> ../../../../../../../class/gpio
-rwxrwx--- 1 root gpio 4096 Feb 13 00:07 uevent
-rwxrwx--- 1 pi   pi   4096 Feb 13 00:07 value

pi@raspberrypi:/sys/class/gpio $ ls -l ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
total 0
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 base
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 device -> ../../../3f200000.gpio
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 label
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 ngpio
drwxrwx--- 2 root gpio    0 Feb 12 12:46 power
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 subsystem -> ../../../../../../class/gpio
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 uevent

pi@raspberrypi:/sys/class/gpio $ ls -l ../../devices/gpiochip2/gpio/
total 0
drwxrwx--- 3 root gpio 0 Feb 12 12:46 gpiochip100

pi@raspberrypi:/sys/class/gpio $ ls -l ../../devices/gpiochip2/gpio/gpiochip100
total 0
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 base
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 device -> ../../../gpiochip2
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 label
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 ngpio
drwxrwx--- 2 root gpio    0 Feb 12 12:46 power
lrwxrwxrwx 1 root gpio    0 Feb 12 12:46 subsystem -> ../../../../class/gpio
-rwxrwx--- 1 root gpio 4096 Feb 12 12:46 uevent

Please post how your files look like when a pin is configured.

And somehow your path is different to what @rlkoshak posted. You have an /soc@ does the normal folder not exist?

Is the user openhab added to the group gpio.

pi@raspberrypi:~ $ sudo -u openhab groups
openhab video gpio

Did you reboot ? This is sometimes neccessary. :smile:

@Josar - Thanks for trying to help. I tried the last days a lot to get the GPIOs working. In the end I gave up. I ordered a RPi3 and today I migrated my configuration.
Then in the second try the GPIO is working and finally I’m able to switch my powerplugs.
It definitely has something to do with this damn BananaPi. Now he’s retired and maybe used again in future as a proxy or something.

BTW - for my cheap plugs I’ve used this tutorial which is working fine with GPIO:

Again - thank you very much for your help!
Have a nice weekend.

@Josar Thanks for putting this tutorial together. I am using nearly 99% RF outlets and a rooted Wink Hub 1 that also uses exec binding, so this helps a lot. However, I followed what you had very closely and am getting the following error during the testing:

Cannot convert ‘5330371’ to a command type which item ‘Outlet_Power_Args’ accepts: [OnOffType, RefreshType].

Here are my files, simple for now as I am trying to figure this all out.

exec.things

Thing exec:command:outlet-power [ 
           command="/home/pi/python_scripts/automation/v2/codesend %2$s",
           interval=0,
           autorun=true]

rf_outlets.items

Switch rf_plug_LR_lamp <poweroutlet>

Switch Outlet_Power         { channel="exec:command:outlet-power:run"       }
Switch Outlet_Power_Args    { channel="exec:command:outlet-power:input"     }
Switch Outlet_Power_Out     { channel="exec:command:outlet-power:output"    }

rf_outlets.sitemap (Probably less important)

sitemap rf_outlets label="RF Outlets"
{
    Frame label="RF Outlets"
    {
        Switch item=rf_plug_LR_lamp label="Living Room Lamp"
    }
}

rf_outlets.rules

rule "Living Room Lamp"
    when
        Item rf_plug_LR_lamp received command
    then
        // wait for transmitter to be free
        // state will be NULL if not used before or ON while command is executed
        while(Outlet_Power.state == ON){
            Thread::sleep(500)
        }

        if(receivedCommand == ON){
            Outlet_Power_Args.sendCommand("5330371")
        } else {
            Outlet_Power_Args.sendCommand("5330380")
        }

        // wait for the command to complete
        while(Outlet_Power.state != OFF){
            Thread::sleep(500)
        }

        logInfo("RF Outlets","Result:" + Outlet_Power_Out.state)
end

Essentially, the same exact thing that you did, by my code isn’t in 3 parts, only 1 but don’t know why this would matter. Any ideas what is happening and what I can do to correct it? Thanks!

**EDIT: Totally figured out what I missed (guess I didn’t follow as closely as I thought).

Instead of

Switch Outlet_Power_Args    { channel="exec:command:outlet-power:input"     }
Switch Outlet_Power_Out     { channel="exec:command:outlet-power:output"    }

in my items file, it should be:

String Outlet_Power_Args    { channel="exec:command:outlet-power:input"     }
String Outlet_Power_Out     { channel="exec:command:outlet-power:output"    }

The command isn’t actually executing like I would expect, but the error is gone now. On to figure out why it isn’t executing.