Exec Binding remote command to Windows (WSL)

remote
windows
remotecontrol
Tags: #<Tag:0x00007f1e5bf87408> #<Tag:0x00007f1e5bf872a0> #<Tag:0x00007f1e5bf87098>
(Daniel Quantil) #1

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!

0 Likes

(Rich Koshak) #2

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.

0 Likes

(Daniel Quantil) #3

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.
Dan

0 Likes