SmartThings Community

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

eventghost
desktop
project_power
webcore

(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.

EDIT:
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 “HTTP.ST.PC.switch.off”-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 PC.switch.off.
  • 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.
Thanks
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!!!


(Gilberto Gonzalez) #65

i think now i get the IFTTT makes the udpdate happen but cant program that to webcore becuase i dont undertant what is it, i could not find it under physical devices, really lost here :disappointed_relieved:_


(Nick D) #66

It won;t be under physical devices, look closely at the guide and there are special instructions for the status system.


(Seth Daniel) #67

I have everything setup as you said. The PC properly responds to turning the switch on and off, so EventGhost is getting the calls from the network and putting the PC to sleep. I have curl installed for all users, I checked the firewall, and whitelisted EventGhost. EventGhost shows the trigger and the action happening when the pc turns on or off, but the switch is not getting updated when the computer is turned on or off outside of using the switch.

If I copy and paste the command from the EventGhost action into a command prompt, it updates the switch properly. However, if I press the execute item button in EventGhost, it does not update the switch. I’m not sure what EventGhost is doing wrong here. Is there a place to view the logs of an attempted EventGhost action? Or any ideas what could be causing this behavior?


(Nick D) #68

Is EventGhost running as admin?Do you have the “Ru as Admin” ox checked for he command?


(Seth Daniel) #69

EventGhost was not running as admin. I did not have the Run as Admin box checked.

I just restarted EventGhost as admin, and now it’s working, though. Not sure why it has to be admin, but that’s ok.

I also had the same problem with wake up as njschwartz had, so I added a 5s wait after wake up and now everything is working.

Thanks for the setup! This is super helpful.


(Justin Ide) #70

So i’m trying to find a solution to if I ever need to shut down or reboot my PC remotely from a public IP. Can I achieve that using this?


#71

Where can I get the webcore script and the eventghost tree needed for this. They don’t seem to be downloadable from this thread. All I can see is the pictures.


(Nick D) #72

Strange. The download link still works for me. try it from another device and PM me if you still need them.


(Nick D) #73

I am not sure what you mean. inside or outside of the SmartThings ecosystem? As long as your ST Hub is on the same PRIVATE network, you can do it from anywhere. Also, you can let WebCoRE be invoked by webhooks (ex: IFTTT triggers, POST requests)


(Mike Coscia) #74

Nick, this is fantastic. Thank you so much!


(Alwas) #76

I noticed last night the PC didn’t shut down with the Goodnight routine as usual. Saw yesterday that the PC downloaded and installed some Windows updates, which deleted my Eventghost configurations! So had to reconfigure EventGhost, turn on at System Startup and minimize to system tray on close, and added back the EventGhost Tree Template. and I’m back up and running. Using a Windows 8.1, I guess I have to turn off “Install updates automatically”.