Problems with permissions (Apparently)

  • Platform information:
    • Hardware: Raspberry Ppi 3 B+
    • OS: Raspbian GNU/Linux 10 (buster) / Linux raspberrypi 4.19.66-v7+
    • Java Runtime Environment: build 11.0.3+7-post-Raspbian-5
    • openHAB version: 2.4.0-1

My story

I wanted to control my Air Conditioner via LIRC and then connect it to OpenHAB, I had several problems since my AC is quite new so the information it sends is quite complex to interpret with irsend. Looking for an alternative I found http://abyz.me.uk/rpi/pigpio/examples.html#Python_irrp_py
where there is a script called " IR Record and Playback" that works first recording the control and then playing the same command. I run my AC with this program, so I decided to implement it to my openhab.
First I created a script called “auto24on.sh” that executed python

#!/bin/sh
./irrp.py -p -g23 -f Auto24 on

Where


./irrp.py, It's the script that allows me to turn on and off my AC

23, the GPIO

Auto24, the code that contain on and off sequence that allows me to turn on the air in this case.

Then in openhab

Demo.items

Switch Habitacion_Aire "Aire Acondicionado"

Demo.rules

rule "Aire On"
when
    Item Habitacion_Aire received command ON
then
    val String results = executeCommandLine("/etc/openhab2/scripts/auto24on.sh", 5000)
logInfo("Exec2", results)
end

rule "Aire On1"
when
    Item Habitacion_Aire received command ON
then
    executeCommandLine("/etc/openhab2/scripts/auto24on.sh")
end

I created two rules, one to execute the command and the other to see the error with more detail, with what I got…

[2019-09-17 01:51:31.027 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/etc/openhab2/scripts/auto24on.sh'

2019-09-17 01:51:31.270 [INFO ] [eclipse.smarthome.model.script.Exec2] - Can't open: Auto24]

I tried to modify and add privileges but there are no results

Any ideas?

Please be free to ask if anything is missing

That’s what the execution of the script returns
Where is auto24on.sh located?
What does the script say when executed from command line?

Hi!

/etc/openhab2/scripts

06

The script runs fine when I enter your location, not when I want to do it from another folder, look…

I think there’s the problem but I don’t know how to follow the resolution.

How about:

#!/bin/sh
./irrp.py -p -g23 -f /etc/openhab2/scripts/Auto24 on

Hi!

Change that and now I can run the script from another location but it still doesn’t run via openhab

2019-09-17 09:30:56.527 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'demo.rules'

2019-09-17 09:31:29.589 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/etc/openhab2/scripts/auto24on.sh'

2019-09-17 09:31:29.960 [INFO ] [eclipse.smarthome.model.script.Exec2] -

When OH kicks off a script, it runs as openhab; can you verify the permissions on the file?

-rwxr-xr-x 1 pi pi 83 sep 17 09:28 /etc/openhab2/scripts/auto24on.sh

I think that openHAB executed the script. When I look at your example where you ran it successfully from the command line it doesn’t give any output either. Hence, openHAB logs an empty line.

The following is actually a better solution:

#!/bin/sh
cd /etc/openhab2/scripts
./irrp.py -p -g23 -f Auto24 on

The /etc/openhab/scripts directory is actually not meant for normal shell scripts. It is meant for scripts written using the rules DSL if I’m not mistaken.

1 Like

I made the changes but nothing.
Also, I changed the permissions for irrp.py, Auto24 and auto24on.sh to 777 but nothing.

Well… “the cure is worse than the disease”…

I had created 2 rules, one to see the result of the execution of the rule and another the rule that only executed the script. It seems that the rules overlapped and there was the problem. I just left the script execution rule and it works.

rule "Aire On"
when
    Item Habitacion_Aire received command ON
then
    executeCommandLine("/etc/openhab2/scripts/auto24on.sh")
end

Thank you very much for your time.

3 Likes