Openhab2 exec bindig shotdown


I’m trying to shotdown my Pc with exec bindig, but the following code not working:


Switch micropc "MicroPc" { wol="",
			  exec=">[OFF:net rpc shutdown -I -U user%pass]" }

If I run command on terminal it works fine, so the problem is in the exec binding.
Can someone help me?


Maybe the user “openhab” has no permission to use/execute rpc?!

How can I give it permission?

First I would verify is that actually is your problem.


sudo -u openhab net rpc shutdown -I -U user%pass

To see if the command works for the user openhab.

I tried, it works the Pc is Off!

mkdir failed on directory /var/cache/samba/lck: Permission denied

Shutdown of remote machine succeeded

So the problem is somewhere else … :thinking:

I found the probem!

My cod is working with exec bindig v1.x but now exec bindig 2.0 is active. I saw the readme, but it’s too difficult for me now, I am newbie :frowning:

Can someone rewrite my code?


I trying to write exec bindig 2.0 code, but it not wok, can someone help correct it?


Thing exec:command:micropc [command="net rpc shutdown -I -U user%pass"]


Switch micropc "MicroPc" { wol="",
			  channel="OFF:exec:command:micropc:run" }

The wol works, but the exec (power off) not.


Had the same Issue.

The Problem seems, that the Exec 2.0 Binding cannot handle Switches.
Could you try the following:

    String micropc "MicroPc" { channel="OFF:exec:command:micropc:run" }

On your Sitemap you can use a Switch.

If this works, then you can try to make a Rule with WOL and Exec.

Greetings Michael

Thanks for the hint, but not working :frowning:


String micp "MicroPcofftest" { channel="OFF:exec:command:micropc:run" }


Switch item=micp

Maybe the “%” in “user%pass” is causing the problem.

But I do not know how you need to change chat.
Try “user%%pass” or “user%pass”.

Thanks! The user%%pass version works!

Now when I turn on the Pc, it immediately turns off :grinning:

If this code present, the pc turn off immediately after turning on.


Thing exec:command:micropcoff [command="net rpc shutdown -I -U user%%pass -f"]

I modified the items code, but nothing change, the pc turns off. It means the command in the things automaticly runs.


Switch micropc "MicroPc" { wol="" }

How can I controll it with switch?

I found this topic, so the automatic run solved, but switch not working…


Thing exec:command:micropcoff [command="net rpc shutdown -I -U user%%pass -f", interval=0, autorun=false]

Now turn on works with wol binding, and turn off works with exec binding, but now only with two switch.

Switch mpcon "MicroPc On" { wol="" }
Switch mpcoff "MicroPc Off" { channel="exec:command:micropcoff:run" }

How can I put it together in one swich item, ON and OFF state?

By the way,

is it possible to combine Commands?

Like tapping a Switch causes WOL and then Executes a Script?

I have a problem with executing a Python script. In the script i do a WOL but this never works when executed by openhab. Permissions are set correctly.

Any suggestions?

Greetings Michael

Yes, it is possible:

Switch mpc "MicroPc" { wol="", channel="exec:command:micropcoff:run" }

wol turn on the Pc, than exec turns it off immediately.:slight_smile:

Thank You.

I’ll give it a try!

Greetings Michael

That worked pretty good, but instead of Number, I used Switch and the values OFF and ON so that Alexa could control turning on and off the computer.