I tried, it works the Pc is Off!
mkdir failed on directory /var/cache/samba/lck: Permission denied
Shutdown of remote machine succeeded
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 …
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!
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!
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
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”.
Thanks! The user%%pass version works!
Now when I turn on the Pc, it immediately turns off
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?
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]
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?
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="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.
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.
Thanks for this inspiration, I adopted this to control my WIndows 10 PC, with Melissa’s idea for ON/OFF.
But I fould that something lacked, when power on or off PC by hand, Openhab did not update the status of it.
So to make it complete, I added a Switch checking presence of PC via Pingdevice, and a rule to check if the status changed “outside” of OH2. So the solution looks like this:
Thing:
Thing exec:command:holgerpcoff [command="net rpc shutdown -f -I 192.168.75.112 -U HOSTNAME/USER%%PASSWORD", interval=0, autorun=false]
Items:
Switch Presence_Holger_PC "Holger PC" <network> {channel="network:pingdevice:192_168_75_112:online" }
Switch Holger_PC_ON_OFF "Holger PC" <network> ["Switchable"]
Switch Holger_PC_ON "Holger PC ON" { wol="192.168.75.255#08:62:66:29:5A:F2" }
Switch Holger_PC_OFF "Holger PC OFF" { channel="exec:command:holgerpcoff:run" }
Rules:
rule "Holger PC onoff"
when Item Holger_PC_ON_OFF received command
then switch (receivedCommand)
{
case ON: { Holger_PC_ON.sendCommand(ON) }
case OFF: { Holger_PC_OFF.sendCommand(ON) }
}
end
rule "Holger PC State"
when Item Presence_Holger_PC changed
then
if (Holger_PC_ON_OFF.state != Presence_Holger_PC.state)
Holger_PC_ON_OFF.postUpdate(Presence_Holger_PC.state)
end
Sitemap:
Switch item=Holger_PC_ON_OFF label="Holger PC"
With this solution, you can Power on/Shutdown PC with OH2, plus it shows correct state if you started it or shut down manually.
Hi!
I tried your code, but the state not working.
Can you help me, what is wrong with my code?
Items:
Switch Presence_Micro_PC “MicroPc2” {channel=“network:pingdevice:192_168_0_xxx:online” }
Switch Micro_PC_ON_OFF “MicroPc2” [“Switchable”]
Switch Micro_PC_ON “MicroPc2 ON” { wol=“192.168.0.255#xx:xx:xx:xx:xx:xx” }
Switch Micro_PC_OFF “MicroPc2 OFF” { channel=“exec:command:micropcoff2:run” }
Rules:
rule "MicroPc on/off" when Item Micro_PC_ON_OFF received command then switch (receivedCommand) { case ON: { Micro_PC_ON.sendCommand(ON) } case OFF: { Micro_PC_OFF.sendCommand(ON) } } end rule "MicroPC State" when Item Presence_Micro_PC changed then if (Micro_PC_ON_OFF.state != Presence_Micro_PC.state) Micro_PC_ON_OFF.postUpdate(Presence_Micro_PC.state) end
Hi!
I found the error in items:
Switch Presence_Micro_PC “MicroPc2” {channel=“network:pingdevice:192_168_0_xxx:online” }
The working code is:
Switch Presence_Micro_PC “MicroPc2” {channel=“network:device:192_168_0_xxx:online” }
Thanks for working solution, I got this up and running, one thing you mist is Thing configuration of your 192_168_75_112…