SzilagyiR
(Szilagyi R)
April 4, 2017, 6:36am
1
Hi!
I’m trying to shotdown my Pc with exec bindig, but the following code not working:
pc.items:
Switch micropc "MicroPc" { wol="192.168.0.255#D0:50:99:35:6E:BB",
exec=">[OFF:net rpc shutdown -I 192.168.0.100 -U user%pass]" }
If I run command on terminal it works fine, so the problem is in the exec binding.
Can someone help me?
Thanks!
Maybe the user “openhab” has no permission to use/execute rpc?!
SzilagyiR
(Szilagyi R)
April 4, 2017, 6:54am
3
How can I give it permission?
First I would verify is that actually is your problem.
Try:
sudo -u openhab net rpc shutdown -I 192.168.0.100 -U user%pass
To see if the command works for the user openhab.
SzilagyiR
(Szilagyi R)
April 4, 2017, 8:02am
5
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 …
SzilagyiR
(Szilagyi R)
April 4, 2017, 1:37pm
7
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
Can someone rewrite my code?
Thanks!
SzilagyiR
(Szilagyi R)
April 5, 2017, 6:38am
8
I trying to write exec bindig 2.0 code, but it not wok, can someone help correct it?
pc.things
Thing exec:command:micropc [command="net rpc shutdown -I 192.168.0.100 -U user%pass"]
pc.items
Switch micropc "MicroPc" { wol="192.168.0.255#D0:50:99:35:6E:BB",
channel="OFF:exec:command:micropc:run" }
The wol works, but the exec (power off) not.
Thanks!
dermitschi
(Michael Zeißner)
April 5, 2017, 7:16am
9
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
SzilagyiR
(Szilagyi R)
April 5, 2017, 8:38am
10
Thanks for the hint, but not working
items
String micp "MicroPcofftest" { channel="OFF:exec:command:micropc:run" }
sitemap
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”.
SzilagyiR
(Szilagyi R)
April 5, 2017, 6:22pm
12
Thanks! The user%%pass version works!
Now when I turn on the Pc, it immediately turns off
SzilagyiR
(Szilagyi R)
April 6, 2017, 5:55am
13
If this code present, the pc turn off immediately after turning on.
pc.things
Thing exec:command:micropcoff [command="net rpc shutdown -I 192.168.0.100 -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.
pc.items
Switch micropc "MicroPc" { wol="192.168.0.255#D0:50:99:35:6E:BB" }
How can I controll it with switch?
SzilagyiR
(Szilagyi R)
April 6, 2017, 6:33am
14
I found this topic, so the automatic run solved, but switch not working…
pc.things
Thing exec:command:micropcoff [command="net rpc shutdown -I 192.168.0.100 -U user%%pass -f", interval=0, autorun=false]
SzilagyiR
(Szilagyi R)
April 6, 2017, 7:00am
15
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="192.168.0.255#D0:50:99:35:6E:BB" }
Switch mpcoff "MicroPc Off" { channel="exec:command:micropcoff:run" }
How can I put it together in one swich item, ON and OFF state?
dermitschi
(Michael Zeißner)
April 6, 2017, 10:41am
16
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
SzilagyiR
(Szilagyi R)
April 6, 2017, 12:41pm
17
Yes, it is possible:
Switch mpc "MicroPc" { wol="192.168.0.255#D0:50:99:35:6E:BB", channel="exec:command:micropcoff:run" }
wol turn on the Pc, than exec turns it off immediately.
melissagirl
(Melissa LeBlanc-Williams)
September 20, 2018, 6:19am
20
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.