exec-Binding: no execution

execbinding
executecommandline
Tags: #<Tag:0x00007f1e6dc92b78> #<Tag:0x00007f1e6dc928f8>
(Klaus Alt) #1

I am a absolute beginner in openhab2 and linux;
tried to find out a solution for 2 days, but no success.

My setup is:
one raspberry pi with openhabian
one additional raspberry pi as testmaschine. On this maschine I can run a python-script, which turns (via a relais and gpio) a lamp on and off.
My plan is, to switch the light via openhab.

I tried 2 different ways:

  1. via exec-Binding:

    Sitemap-File:
    sitemap lamptest1 label=“TestSitemap1 (Exec)”
    {
    Switch item=Light_Buro label=“Test-Light” icon=“light”
    }

    Items-File:
    // Path and File /etc/openhab2/items/lamptest1.items
    Switch Light_Buro “Test_Light” { channel=“exec:command:testlight:run” }

    Things-File:
    Thing exec:command:testlight [ command=“ssh pi@192.168.178.71 sudo python /home/pi/an.py %2$s”, interval=0, autorun=true ]

  2. via executeCommandline:

    Sitemap-File:
    sitemap lamptest2 label=“TestSitemap2 (executeCommand)”
    {
    Switch item=Light_in_buro label=“Buro Testlight”
    }

    Items-File:
    Switch Light_in_buro

    Rules-File:
    rule "Testrule"
    when
    Item Light_in_buro received command
    then
    executeCommandLine(“ssh pi@192.168.178.71 python /home/pi/an.py”)
    end

I can run the script successfull from the commandline of the openhabien-pi via “ssh piⓐ192.168.178.71 python /home/pi/an.py” (and also via commandline on the testmaschine itself):
The light goes on/off as intended.

But no result, when I try to switch it via iPhone/Basic UI.
Via Basic UI comes a message: “Offline: waiting for connection to become available”

openhab-Log-File looks good for me:
events-log:
2017-08-22 14:40:25.530 [ItemCommandEvent ] - Item ‘Light_Buro’ received command ON
2017-08-22 14:40:25.543 [ItemStateChangedEvent ] - Light_Buro changed from OFF to ON
2017-08-22 14:40:27.807 [ItemCommandEvent ] - Item ‘Light_Buro’ received command OFF
2017-08-22 14:40:27.817 [ItemStateChangedEvent ] - Light_Buro changed from ON to OFF
2017-08-22 14:40:33.502 [ItemCommandEvent ] - Item ‘Light_in_buro’ received command ON
2017-08-22 14:40:33.514 [ItemStateChangedEvent ] - Light_in_buro changed from OFF to ON
2017-08-22 14:40:35.592 [ItemCommandEvent ] - Item ‘Light_in_buro’ received command OFF
2017-08-22 14:40:35.610 [ItemStateChangedEvent ] - Light_in_buro changed from ON to OFF
2017-08-22 14:40:42.967 [ItemStateChangedEvent ] - network_device_192_168_178_63_time changed from 11.644148 to 4.520493
2017-08-22 14:40:43.647 [ItemStateChangedEvent ] - network_device_192_168_178_52_time changed from 7.822609 to 5.116114

openhab-log:
2017-08-22 14:40:33.588 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine 'ssh piⓐ192.168.178.71 python /home/pi/an.py’
2017-08-22 14:40:35.629 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘ssh piⓐ192.168.178.71 python /home/pi/an.py’

Any idea?
Thanks a lot in advance!

Klaus

0 Likes

(Angelos) #2

Just a note that the openHAB process runs as user openhab. Check if you can run the ssh commandline using this user from your shell.

0 Likes

(Klaus Alt) #3

Thanks a lot for your help.
I will go through your post step by step in the next days.
Regards
Klaus

0 Likes