SmartThings Community

[WINDOWS TUTORIAL] PC On/Off (No Hardware Required)


(Nick D) #44

Strange. Mine has been fine since I set it up and works better because I don’t want to set a static IP for my PC. Maybe his router is messing up or his Wake On LAN isn’t configured correctly or reset itself.


There’s a small flaw in this method that will throw the simulated switch out of sync if the PC hangs and has to be switched off forcefully (or when there is a power failure). In this situation, @rontalley 's solution is more foolproof

(Nick D) #46

To be fair in the case of a power failure ST and an Rpi would be down as well, plus my computers never hang. Though if that is part of your situation, then an externally controlled method is favorable. Though this solution is easier and more preferable to a majority because it doesn’t rely on an extra computer to update the status as a software only setup. I personally use this because it requires no extra computer on the network to function and uses WebCoRE.

(Alwas) #47

Does anyone have a webCoRE piston that keeps the virtual PC switch in sync with the PC using the power of Smart Plug? In case the PC turns on/off manually? I’m stuck on this seemingly simple piston, I’ve tried “if power drops below 5W, and pc switch is on, turn off pc switch”, but nothing works consistently yet.

(Ron Talley) #48

Old CoRE Piston that I use for all of my PCs that use a Power Meter. Wattage is high on this because it’s connected to a 4K 65" TV.

If I was to do this in webCoRE, it would be something like:


If switch changes
–If switch is on
–Then using powermeter
–Turn on
–If switch is off
–powermeter is below x watts
–Then using powermeter
–Turn off

If powermeter drops below x watts
Switch is on
Then using switch
Wait x seconds
Turn off

If powermeter rises above x watts
Switch is off
Then using switch
Turn on

ASync all arguments. That should keep everything in sync for you.

(Chris) #50


I’ve got this to mostly work fine. The only thing that is not working is the command line running in EventGhost. If I run the command line manually, everything works perfectly.

I made a batch file with the command line in and setup EventGhost to run the .bat file. This works, so I know my triggers and the command line are ok. It’s seems that EventGhost is not running the command line.

Are there certain permissions or settings needed? I’m running Windows 10.


(Nick D) #51

It depends, I have never used Smart Plugs to determine statuses. Great idea though!

(Nick D) #52

It can be buggy sometimes, also note that EventGhost does have permission issues with cmd in Windows 10. The reason batch files work is because they have clear permissions set.

He needed to reboot a few times. See below.

(Chris) #53

Couple of reboots of the PC and all seems to be working well now.

Putting the computer to sleep turns off the switch
Waking the computer turns on the switch
Using smartthings, alexa or google home to control the switch turns on/off the PC

Everything seems to work perfect!

Quick question. The webhook URL… I assume this needs to be kept in a secret place and not used on public computers and such since it requires no authentication and provides control of smartthings?

(Hendre) #54

Thank you for the tutorial. This is an extremely useful function.

The Simulated Switch does not update when shutting the PC down in the usual manner. You mentioned that you had the same problem and solved it by running the EventGhost trigger before the PC goes to sleep (shut down in my case). How did you do that?

I have to mention that I changed the script to shut the PC down (as opposed to putting it to sleep).

I changed the script to look like this - not sure if that is how it should be:

Thanks for your assistance.

(Brandon) #55

Figured out my problem after not trying to work on it at 11:30 at night with blurry eyes. I evidently renamed my button from “PC” to “Computer” at some point. So when I pressed the button in ST to turn off the PC, the event name is now “” instead of “” Oops.

Anyway, thanks for coming up with this.

(Nick D) #56

Correct. That wakeup URL call WebCoRE to trigger the respective action. If it is ever compromised, simply pause the piston. One thing to note is that it will not control anything except what you want it to (if it’s not in a webcore piston, they have no access) The reasoning behind this is it simplifies the process and the URL only goes from your network to smartthings.

(Nick D) #57

See edit below. I have only experimented with sleep, though the little lightning symbols are actions that cause the macro to run. Suspend is called before sleep, though your problem may be that EventGhost is killed before it can send a signal to SmartThings signaling a shutdown. This is a limitation Windows causes by killing the EventGhost process. To work around this, you could use a Windows interface that will not be killed as fast. One method is here on StackOverflow that uses task scheduler to run a script before shutdown/restart. This way you use curl to send the signal and it will be far more reliable because task scheduler event will not be killed immediately on shutdown. The most reliable method though, is only possible if you have Windows Pro/Enterprise and that is using the group policy manager method here.

If what you changed works, then it’s fine! EventGhost is fine having multiple triggers for one macro. The above is only if it doesn’t work.

(Nick D) #58

Great to hear it works! That seems like a mistake I would make and never find. I would have probably just delete everything and start from scratch at that point. :joy:

(Nick D) #59

I had a problem like that at the beginning. My MSI motherboard just wouldn’t listen to WoL packets until I restarted a few times, haven’t had a problem since. I believe the biggest hurdle with this project is the variation between WoL implementations and reliability between PCs. On some GIGABYTE boards you may have to restart once after a power outage or extended time after being unplugged, but that may have had more to do with the network environment I set it up in than the computer.

(Hendre) #60

Thanks for the further info @nickd. I’ll look into that.
It works fine with the Shut Down function on 5 of my PC’s. On 3 of them, I can’t get to wake-up, but I’m sure it is a driver/NIC issue.

For others trying this, a few things I learned (apart from what others have already mentioned above):

  • Make sure that the “”-command contains the exact same reference/name as what you had named your Virtual Switch, i.e. the part in bold is a reference to you Virtual Device name. I.e. if the Virtual Switch created for your PC is called “Media Server PC”, the command would look like this: "HTTP.ST.Media Server
  • Wait until you have created the Virtual Switch and installed Event Ghost on the PC before creating the Event Ghost Smart app in the Mobile App. (I installed this on 5 PC’s and with 3 of them, it only started working after deleting and re-creating the Mobile app. With the last PC, I created the Mobile App last and it immediately worked.
  • Restart the PC after installing Event Ghost.
  • Create separate instances of the Event Ghost Smart app for each PC’s.

(Hendre) #61

@nickd, I have Windows Pro, but I’m not sure what the command should be that will be executed when Windows shuts down.
I tried the second method and added the “curl -X POST _the url_emphasized text___pc-off” command as the script to run during shutdown. That does however not seem to work.
To test the curl command, I tried running it at a command prompt, but doing that called Event Ghost and shuts the PC down.
Edit: Some more information and strange behaviour: Just realised that executing the pc-off command (highlighting the “IFTTT” section and choosing “Execute Command”, shuts down all my PC’s. (And interestingly enough, updates all virtual switches to off") Why would that be? Surely that should not happen? Or does this happen because all the PC Virtual switches are updated to Off which causes the PC’s to shut down. But still, why would individually executing the IFTTT command of 1 of the PC’s in Ghost Event, cause all the switches to turn off at the same time?

Edit 2: I think I have worked this one out. Each of the PC’s should (in the piston) have a different value here:

Obviously, this value should be accordingly changed in respect of the Ghost Event command.

(Nick D) #62

Sorry I saw your post late. Also, yes! You do need to separate your PC URLs so that WebCoRE and EventGhost don’t see all of your PCs as the same signal. It’s almost like if you had two TVs next to each other and when you hit the power button on one remote, they both shut off.

As for your command line shutdown, that’s exactly what you want. You faked a signal from your computer saying that it was shutting down, but because it wasn’t, EventGhost saw the switch turn off and went ahead and executed the shutdown. I am not sure how to get around the issue of sending a signal out. It might be that your network/the connection to ST isn’t fast enough and the PC shuts down before the webhook is called. It could also be that your PC shuts down very fast. I will look into this, but a temporary workaround is to make a shortcut on your desktop to that pc_off URL, so that when it is run, it will update the switch and that will make EventGhost shut down your PC.

(Hendre) #63

Thank you once again Nick.

(Gilberto Gonzalez) #64

hi this is great information!!! i been trying to get this right for the past 2 days, i can use ST to wol and sleep my pc correctly, the problem is that i dont understand how to update those states, i need help with update pc to on and update pc to off, thanks!!!