you need to create a third virtual switch item to send commands to the other two:
Item:
Number PCONOFF "PC ON/OFF"
rule
when item PCONOFF received command
then
switch (receivedCommand){
case 1: {
mpcon.sendCommand(ON)
}
case 2: {
mpcoff .sendCommand(ON)
}
}
end
sitemap
Switch item=PCONOFF mappings=[1="ON",2="OFF"]
rule "MicroPc onoff"
when item MPCONOFF received command
then switch (receivedCommand)
{
case 1: { mpcon.sendCommand(ON) }
case 2: { mpcoff.sendCommand(ON) }
}
log:
2017-04-08 09:05:35.089 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at âitems/MPCONOFFâ with an invalid status value â1â.
2017-04-08 09:05:35.808 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP POST request at âitems/MPCONOFFâ with an invalid status value â2â.
fixed errors in original post(also the missing âendâ in the rule)
other than that i donât see anything obvious wrongâŠ
Maybe add some logging in the rule where appropriate, like:
rule "MicroPc on/off"
when item PCONOFF received command
then
switch (receivedCommand){
case 1: {
mpcon.sendCommand(ON)
}
case 2: {
mpcoff.sendCommand(ON)
}
}
logInfo("check.rules", "switch case 1 triggered")
end
New error int the log:
2017-04-08 10:56:26.359 [WARN ] [.rule.jvmmodel.RulesJvmModelInferrer] - Duplicate field: âmpcoffâ. Ignoring âorg.eclipse.smarthome.core.library.items.SwitchItemâ.
rule "MicroPc on/off"
when
Item PCONOFF received command
then
switch (receivedCommand){
case 1: {
mpcon.sendCommand(ON)
logInfo("check.rules", "switch case 1 triggered")
}
case 2: {
mpcoff.sendCommand(ON)
logInfo("check.rules", "switch case 2 triggered")
}
}
logInfo("check.rules", "finished rule")
end
what is in events.log if you switch mpcon and mpcoff via sitemap? the command sent then must be the same then sent via the rule.
rule "MicroPc onoff"
when Item MPCONOFF received command
then switch (receivedCommand)
{
case 1: { mpcon.sendCommand(ON) }
case 2: { mpcoff.sendCommand(ON) }
}
end
Hello SzilagyiR,
Iâm trying to use your approach. OpenHAB is sitting on the RPi 192.168.0.4 and Iâm trying to ON/OFF computer 192.168.0.2
I did install exec binding and wol binding.
Copy and past your code to correct files.
I did change user%%pass to my windows 10 login and password.
Thing is pointing to 192.168.0.2 and wol="192.168.0.2#MAC of the computer.
added Switch item=MPCONOFF mappings=[1="ON",2="OFF"]
to my sitemap
added this items in my .items file Switch mpcon "MicroPc on" { wol="192.168.1.255#D4:BE:D9:A4:38:90" } Switch mpcoff "MicroPc off" { channel="exec:command:micropcofft:run" } Number MPCONOFF "Micro Pc"
created a .rules file with this:
rule âMicroPc onoffâ
when Item MPCONOFF received command
then switch (receivedCommand)
{
case 1: { mpcon.sendCommand(ON) }
case 2: { mpcoff.sendCommand(OFF) }
}
end
and created an things file with this content: Thing exec:command:micropcofft [command="net rpc shutdown -I 192.168.1.255 -U user%%pass -f", interval=0, autorun=false]
ofcourse i changed user and pass with my windows login details
Now the WOL is working fine but nothing happens when I try to use the OFF button.