Exec Binding remote command to Windows (WSL)

Tags: #<Tag:0x00007f61828b7ca8> #<Tag:0x00007f61828b7aa0> #<Tag:0x00007f61828b7988>

Hi everyone,

I am trying to press a button in openhab (on my Raspi) in order to set my Windows remote computer to sleep.

If I use the command remotely on ssh from my pi it works fine, but I am not able to get it running via Exec Binding on the same machine.

What I did:
I installed Openhabian on my Raspbian Stretch installation. The default user is pi and openhabian created a openhab user.

When I SSH into the Raspbian (with the user pi) I am able to shutdown my Remote windows computer. Therefore I set up KeyAuthentication for my user pi. Then I was able to run the command
ssh username@ip /mnt/c/Windows/System32/rundll32.exe /C powrprof.dll,SetSuspendState 0,1,0
Thats working fine because of the installed WSL on Win10.

But when I try to use the exec binding in OH with the thing
Thing exec:command:MyComputer [command=“sudo ssh username@ip /mnt/c/Windows/System32/rundll32.exe /C powrprof.dll,SetSuspendState 0,1,0”, interval=0, autorun=false]

then it is not working at all. My guess would be that exec binding is using the user openhab which does not have a key authentication to my remote machine?

Does somone have any idea how to get it running? Thanks!

Review How to solve Exec binding problems.

Almost certainly this is the problem. With an apt or yum installed openHAB, the openhab user’s home is /var/lib/openhab2. Configure it like you did for the user pi.

Thanks @rlkoshak,
that hint with the home directory helped me a lot. Finally its running.
In case someone is doing the same, take a look at This Page if you want to know how to set up key authentication for the openhab user.