Alexa controlled wol and exec shutdown

Hey Guys,

im looking for a solution for an Alexa controlled shutdown/wol. EXEC and WoL are installed but when im trying to set up my button for Alexa to find it isnt shown on “my devices”

Switch PC_P “PC” [ “Switchable” ] { wol=“IP#MAC, exec=”>[OFF:net rpc shutdown -I TARGET -U USER%%PASSWORD]" }

No Things and Rules are defined.

Tried diferrent approaches but nothing seems to work. Im new to openHAB and appreciate every kind of help.

Thanks in advance!

1 Like

Missing quote after MAC. And wrong quotes hopefully a copy paste problem.
Thin about using VS Code with openhab Exstension it helps a lot with syntax problems.

Seems like openhab 1 syntax to me. Either install the legacy bindings for openhab containing exec1 or have a closer look to the documentation for exec 2.

Its a bit more to set up.


Thing exec:command:pcOff [
            command="net rpc shutdown -I TARGET -U USER%%PASSWORD",


Switch PC_P "PC" [ "Switchable" ] { wol="IP#MAC", channel="exec:command:remote-send:run"  }

Just typed it from my brain not tested, but somehow like this should be the setup.


thanks for the Quick response! God, the missing quote was my mistake, thanks, now after i did it the way you described it somehow the switch only works with the “alexa turn on PC” for both ways (WoL and Shutdown), the OFF switch is out of order. Seems like there is an issue with the switch and 2 commands for on and off (or maybe only with exec for the 2nd command)

do you have another idea about it ?

@Nin it wont work like, sorry my mistake. If you switch on you triger both on. You will need to use a rule to and mutliple items to get what you want to achive.


Thing exec:command:PcOff [
            command="net rpc shutdown -I TARGET -U USER%%PASSWORD",
            autorun=false ]


Switch WolSwitch  { wol="IP#MAC" }
Switch ExecSwitch { channel="exec:command:PcOff:run" }
Switch PC_P "Pc"


rule "PC OnOff"
    Item PC_P received command
    switch receivedCommand {
	case ON  : WolSwitch.sendCommand(ON)  
        case OFF : ExecSwitch.sendCommand(ON)

Only the PC_P switch will be place into your sitemap. (besides what es needed else to make it a sitemap.)

Switch item=PC_P

I did not test this but it should work like that, besides typos.

indeed theres a loooooooooot to watch took me til 10min ago to figure out how to control the switch with 2 different commands “on/off”, didnt had the time to update a the post. Sorry! But now that i have 2 rules set (1 for my TV too) only one is useable in the rules file. If i outcomment my TV the PC is working but if i uncomment my TV nothings working anymore… this is more complicated than i anticipated :frowning: Is there a Way to use both of those rules in the same file for different items, or should openhab2 use both of those rules alltogether?

rule "TV_OF"
when Item TV_OF received command
then switch (receivedComman)
        case ON: { TV_O.sendCommand(ON) }
        case OFF: { TV_F.sendCommand(ON)}
rule "PC_OF"
when Item PC_OF received command
then switch (receivedCommand)
        case ON: { PC_O.sendCommand(ON) }
        case OFF: { PC_F.sendCommand(ON) }
Switch TV_O "TV1"   { wol="IP#MAC" }
Switch TV_F "TV2"   { channel="PowerOFF_CMD"  }
Switch TV_OF "TV" [ "Switchable" ] // <---- WEBOS TV from LG
Switch PC_O "Ding1" { wol="IP#MAC" }
Switch PC_F "Ding2" { channel="exec:command:remote-send:run" }
Switch PC_OF "PC" [ "Switchable" ]

please use code fences. use the buttons over the writing area.

your code goes here

\o/ that cleared out the problem. God 6h of coding and trying really blinds it out now the PC Rule is ready to work! I put your coding from up above as solution! Thanks a lot for your help here, now im going to fix the WebOS Problem (OFF/ON) not working.

Greetings Patrick