0Connect SmartThings to Windows PC’s and Kodi

I have sev­er­al win­dows PCs in my house that run Kodi. I wanted to con­nect them to SmartTh­ings for a range of pur­poses. There are vari­ous things that can be done depend­ing on the func­tion­al­ity you want.


Firstly I wanted to be able to put my PCs to sleep and wake them up again via a but­ton in SmartTh­ings. I have achieved this, although the pro­cess is quite a long one to set up. I’ll detail it below.

Next I wanted to be able to con­trol Kodi remotely via smartth­ings. This is reas­on­ably straight-for­ward to set up, again I detail how below

Lastly, I wanted to get the status of a PC in SmartTh­ings. This is so that when a PC goes to sleep I can use a routine in smartth­ings to turn off a power adapter with the home cinema amp­li­fi­ers plugged in. I ori­gin­ally looked at doing this with an energy sav­ing “smart” sock­et, but most of these have been dis­con­tin­ued and the reviews of them are mixed at best. Using SmartTh­ings seemed a more reli­able way to achieve the same thing, with the added bene­fit that I can over­ride the beha­viour at any time from the con­veni­ent of my phone.

PART A: Controlling sleep of a PC

I fol­lowed the (not in depth) art­icle on the SmartTh­ings for­um writ­ten by ront­al­ley. This took a bit of time to fig­ure out as many of the things required I hadn’t used before, but it wasn’t as tricky as I’d expect. I’ll give a more detailed ver­sion below.

Note — you will need the tar­get PC to have a fixed loc­al IP address (usu­ally in the format 192.168.x.x) and you will also need to know the MAC address of the net­work con­nec­tion it uses. If you don’t know how to find these then you’re not really the kind of user this guide is aimed at — you do need a bit of tech­nic­al know­ledge to do this kind of tinker­ing with SmartTh­ings.

1. Configure the PC with WOL

  • Hold the win­dows key and R to open the run menu
  • Type in devmgmt.msc and press enter
  • Expand ‘net­work adapters’
  • Double click on the net­work adapter yo use to con­nect to your net­work — this will need to be either a wired eth­er­net con­nec­tion or a wire­less card built in (not a USB WiFi card). In my case this was “Real­tek PCIe GB Eth­er­net Con­nec­tion” on 1 PC and “Intel Eth­er­net Con­nec­tion” on anoth­er
  • Click on the “Power Man­age­ment” tab
  • Make sure all 3 boxes are ticked, then click OK and close device man­ager

2. Install Event Ghost on the PC you want to control

  • Down­load Event­Ghost
  • Install Event­Ghost on the PC you want to con­trol. The default set­tings are all ok to use. At the end of setup run Event­Ghost
  • Cre­ate a new file (the white file but­ton at the top left) and then use “File, Save As” to save it some­where con­veni­ent (prob­ably in My doc­u­ments)
  • Right Click on “Auto­Start” and select “Add Plu­gin”
  • Scroll to the bot­tom of the list and select “Web­Serv­er” and click OK
  • Change the Event Pre­fix to ST. Do not cre­ate a user­name or pass­word
  • I changed the port as I already had some­thing run­ning on Port 80. You can change the port or leave it, but if you change it make a note of what you changed it to.
  • Click OK, and then when the Win­dows Fire­wall prompt appears, click Allow.
  • Click Can­cel to reject the offer to add the “Con­fig­ur­a­tion Tree” actions
  • Right click on “Auto­Start” again, this time select “Cre­ate Macro”
  • Expand “sys­tem” and then “power man­age­ment”
  • Select “Stand By” (or “Hibern­ate Com­puter” if that is what you prefer your PC to do)
  • Click OK, and Click OK again on the next prompt (without choos­ing force close all pro­grams)
  • Now resave the file. We’re nearly (but not quite) fin­ished with it
  • Go to File, Options
  • Tick the first 2 options (run on star­tup and min­im­ise to tray) and click OK
  • Leave Event­Ghost for now and go on to the next stage.

3. Install the Custom SmartThings Smart App “Send Events to EventGhost” in the SmartThings IDE

  • Login to the SmartTh­ings IDE USA or EU & UK
  • Click on “My SmartApps”
  • Click on the green but­ton “+ New SmartApp”
  • Click on “From Code”
  • Open a new browser tab and go to the Git­Hub code for Send-Events-to-Event­Ghost
  • Click on the “Raw” but­ton to view the raw code
  • Copy and paste the code into the SmartApp cre­ation form on the oth­er tab you still have open
  • Click “Cre­ate”
  • Then Click “Save”, and finally “Pub­lish”.

4. Create a virtual switch in SmartThings IDE

  • Still in the SmartTh­ings IDE (from the pre­vi­ous step) click on “My Devices”
  • Click the Green “+ New Device”
  • Give your device a sens­ible name and label — I used the same for each — using the name and loc­a­tion for the PC I wanted to con­trol
  • Change the type to “Vir­tu­al Switch”
  • Give your device a unique net­work name — I used the format “vs-###” where ### was the com­puter name
  • Select your Home loc­a­tion for Loc­a­tion and select your SmartTh­ings Hub (most of us only have 1) that you want to con­trol the switch from for the Hub
  • Make sure ver­sion is set to pub­lished
  • Leave group and zig­bee ID blank
  • Click “Cre­ate”

5. Set the switch to send the “off” signal to event ghost via the Smart App

  • Open the SmartTh­ings app on your mobile device
  • Go to Auto­ma­tion and click on “+ Add a SmartApp”
  • Scroll down to “My Apps” at the bot­tom of the list
  • Select “Send Events to Event­Ghost”
  • Enter the IP address of the PC you wanted to con­trol (it should have a fixed IP)
  • Change the port from 80 if you changed the port in the Event­Ghost web­serv­er cre­ation earli­er, oth­er­wise leave it at 80
  • Click on the “Switches” option and select the name of the vir­tu­al switch you cre­ated and then press “Done”
  • Click “Save” and you should see “Suc­cess­fully added…” shown in green
  • Switch back to “My Home” in the SmartTh­ings app and toggle the switch that you cre­ated on and off
  • Go back to the PC you wish to con­trol and look at the “log” on the left hand side of “Event­Ghost”. You should see a couple of entries that show your switch toggle activ­ity in SmartTh­ings — mine were lis­ted as “ST.ST.CompName.switch.off []” and “ST.ST.CompName.switch.on []”
  • We want to put the PC to sleep when we toggle the switch to off, so we need the entry “ST.ST.CompName.switch.off []”
  • Drag and drop the “ST.ST.CompName.switch.off []” from the log onto the “Stand By” entry in the main pan­el
  • Save the Event­Ghost file again
  • Now try the but­ton in SmartTh­ings on your mobile device. When you toggle the switch to “off” the PC should go to sleep! You’ve com­pleted the first part of the oper­a­tion. The rest will be easy from here.

6. Setup webCoRE for your SmartThings

  • I have based this on the offi­cial guide which is well worth look­ing at if you have any prob­lems
  • You will need a Git­Hub account (free) so if you don’t already have one then head over to Git­Hub and cre­ate one, it only takes a few seconds
  • If (like me) you are in the EU or UK then yo uneed to activ­ate Git­Hub integ­ra­tion for your SmartTh­ings IDE.
    Go to this link and fol­low the instruc­tions to link your Git­Hub account to SmartTh­ings
  • Once you are done (or if it’s already set up) log into the SmartTh­ings IDE USA or EU & UK
  • Click on “My SmartApps”
  • Click on “Set­tings” and then click on “Add new repos­it­ory” in the win­dow that appears
  • Use the fol­low­ing details for the repos­it­ory: Own­er= ady624; Name= web­CoRE; Branch= mas­ter
  • Click “save”
  • Next click the but­ton “Update from Repo” and select “web­CoRE (mas­ter)”
  • Tick ONLY the “web­CoRE” option (not the oth­er 3 options), and tick the “pub­lish” but­ton and click “Execute Update”
  • Click on “Update from Repo” again, and select “web­CoRE (mas­ter)” again
  • Tick the remain­ing 3, tick “pub­lish” again, and click “Execute Update” again
  • Click on the “edit prop­er­ties” but­ton (the right of the 2 but­tons) next to the web­CoRE smart app in the list
  • Scroll down and click on “OAu­th” to expand the OAu­th options
  • Click on “Enable OAu­th in Smart App” and then click “Update”
  • Now go to the SmartTh­ings app on your mobile device
  • Click on “Mar­ket­Place” at the bot­tom and then select “Smart Apps” at the top
  • Scroll down to “My Apps” and select “web­CoRE” (not the dash­board, stor­age or pis­ton)
  • Fol­low the setup wiz­ard, includ­ing choos­ing a pass­word
  • Give web­CoRE access to the vir­tu­al switch you cre­ated earli­er when you get to the devices to con­trol choices.
    You can also select any oth­er devices you might want to con­trol web web­CoRE
  • Now click on the “Auto­ma­tion” tab in the SmartTh­ings App
  • Scroll down until you find web­CoRE and click on “Dash­board”
  • Enter the pass­word you cre­ated in the web­CoRE setup
  • To make web­CoRE easi­er to use we are going to access it via the browser on your PC…
  • In the auto­ma­tion tab click on web­CoRE again, but this time select “Register a browser”
  • On your PC open dashboard.webcore.co and enter the code shown on your SmartTh­ings App
  • Now you have web­CoRE set up we can use it to send a WOL sig­nal

7. Create a webCoRE piston to send a WOL signal when the switch it toggled to “on”

  • In the web­CoRE Dash­board, at the left hand side, click on “+ New Pis­ton”
  • Select “Cre­ate a blank pis­ton”
  • Set your Author Name, and give the pis­ton a sens­ible name (e.g. WOL) and click “Cre­ate”
  • In the code view win­dow click on “+ add a new state­ment”
  • Click on “Add an if” and select “Add a Con­di­tion”
  • Change “what to com­pare” to “phys­ic­al device” and then change “noth­ing selec­ted” to the name of the vir­tu­al switch you cre­ated earli­er. Change the final box to “switch”
  • Leave the next box set to “any inter­ac­tion”
  • Set the box “what kind of com­par­is­on” to “changes to” and set the value to “on”
  • Click the “add” but­ton. You will see a little bit of code has been added.
  • Next, click on the sec­tion of code that says “then” and click on “Add an action”
  • Leave the “devices” box set to “loc­a­tion” and click “add a task”
  • in the “Do” list, scroll down and select the “Wake a LAN device” option
  • In the “value” field enter the MAC address of the PC you want to con­trol. Use the format xx:xx:xx:xx:xx:xx:xx:xx
  • Click the “Add” but­ton
  • Now click the “Save” but­ton at the top right of the web­CoRE Dash­board to save your code
  • You should now be able to use the switch in your SmartTh­ings app to wake your PC from sleep mode as well as put­ting it to sleep. We finally have the basic func­tion­al­ity we wanted! Try put­ting the PC to sleep and wak­ing it up with the switch. Wait 20+ seconds between each oper­a­tion to give the PC chance to respond or the but­ton can get out of sync with the real state of the PC. We’ll do some more work next to keep the but­ton always in sync with the status of the PC.

8. Install HostPinger on an always-on PC

  • To keep the switch always in sync with the real con­di­tion of the PC we ‘ping’ the PC from anoth­er device which needs to be always on. I have a serv­er which I have used for this pur­pose, but you could use a Rasp­berry Pi. This guide will focus on using a Win­dows PC, but you can use the guide by the STHost­Pinger app author to do this with oth­er devices.
  • Down­load STHostPinger.exe from Git­Hub (EXE V2.zip) and extract it to a con­veni­ent loc­a­tion on the “always on” PC
  • Modi­fy the config.config file that comes with STHostPinger.exe to include the IP address of the PC that your vir­tu­al switch con­trols
  • Change the check inter­val if you wish — I changed mine to 10 seconds from the default of 30
  • Keep the con­fig file open as we need 3 more set­tings for it once we have set up the smartapp
  • Login to the SmartTh­ings IDE USA or EU & UK and click on “My SmartApps”
  • Click on “Set­tings” and then click on “Add new repos­it­ory” in the win­dow that appears
  • Use the fol­low­ing details for the repos­it­ory: Own­er= jebbett; Name= STHost­Pinger; Branch= mas­ter
  • Click “save”
  • Next click the but­ton “Update from Repo” and select “STHost­Pinger (mas­ter)”
  • Tick the only option, and tick the “pub­lish” but­ton and click “Execute Update”
  • Click on the “edit prop­er­ties” but­ton (the right of the 2 but­tons) next to the STHost­Pinger smart app in the list
  • Scroll down and click on “OAu­th” to expand the OAu­th options
  • Click on “Enable OAu­th in Smart App” and then click “Update”
  • Now click on “My Device Hand­lers”
  • Next click the but­ton “Update from Repo” and select “STHost­Pinger (mas­ter)”
  • Tick the only option, and tick the “pub­lish” but­ton and click “Execute Update”
  • Go to the SmartTh­ings app on your mobile device
  • Click on Auto­ma­tion at the bot­tom right, and then scroll down and select “Add a SmartApp”
  • Scroll down and choose “My Apps”
  • Choose Host­Pinger, enter the name of the PC you want to mon­it­or, the IP address of the PC you want to mon­it­or,
    change the “Turn this device on/off with status” and select the vir­tu­al switch you cre­ated earli­er. For the delay I’ve found I needed to change the default to 30 seconds to avoid rebooted PCs going straight to sleep. Once set click “Save”
  • Open the Host­Pinger smartapp from the auto­ma­tion menu, scroll down and turn on debug log­ging and click Save to close the smartapp
  • Switch back to the SmartTh­ings IDE and select the “live log­ging” menu
  • Reopen the Host­Pinger smartapp on your mobile device
  • Switch back to the IDE and you should see that sev­er­al events have appeared in the live log. These will include some inform­a­tion called “AppId”, “access­Token” and the IDE entity (US or EU). You need this inform­a­tion
  • In the config.config file that you were edit­ing earli­er you need to enter the 3 bits of inform­a­tion from the live log. The IDE entity will look some­thing like this: “https://graph-eu01-euwest1.api.smartthings.com”. The oth­er 2 entries will be in the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  • Copy these entries into your config.config file and save it. Now run the STHostPinger.exe and you should see a com­mand prompt style win­dow. It should dis­play the status of the PC you want to mon­it­or as either online or off­line, and hope­fully this will match what the PC is actu­ally doing.
  • Your vir­tu­al switch should now accur­ately show the status of your PC, no mat­ter how it was switched on or off. You can test this by turn­ing the PC and mak­ing sure it shows as “on” on the switch in the SmartTh­ings App. Now go to the PC and turn it fully off (turn it off at the wall). Now, use the switch in the SmartTh­ings App to turn the PC on. Of course the PC can’t turn on because it is off at the wall. The switch should say “turn­ing on” for 10–15 seconds, and after­wards should go back to say­ing “off”. If this works the pinger ser­vice has turned the but­ton back to off cor­rectly.

PART B: Controlling Kodi

I tried a couple of dif­fer­ent Smart Apps for SmartTh­ings, but found one was easi­er to set up and did what I needed. Again, I fol­lowed a guide on the SmartTh­ings for­um, this time writ­ten by the author of the smartapp called “Kodi for SmartTh­ings Beta”.

1. Install smart app and device handler in the SmartThings IDE

Use the same prin­ciples as for the first stage, add the cus­tom smart app and device hand­ler and then con­fig­ure.

  • Login to the SmartTh­ings IDE USA or EU & UK and click on “My SmartApps”
  • Click on “Set­tings” and then click on “Add new repos­it­ory” in the win­dow that appears
  • Use the fol­low­ing details for the repos­it­ory: Own­er= iamcanadian2222; Name= ST-Kodi; Branch= mas­ter
  • Click “save”
  • Next click the but­ton “Update from Repo” and select “ST-Kodi (mas­ter)”
  • Tick the only option, and tick the “pub­lish” but­ton and click “Execute Update”
  • Now click on “My Device Hand­lers”
  • Next click the but­ton “Update from Repo” and select “ST-Kodi (mas­ter)”
  • Tick the only option, and tick the “pub­lish” but­ton and click “Execute Update”

2. Enable HTTP control of Kodi

  • Load Kodi on your PC
  • Open Sys­tem settngs
  • Nav­ig­ate to the “Ser­vices” option
  • In the UPnP tab, turn on “Allow remote con­trol via UPnp”
  • In the “Web serv­er” tab, turn on “Allow remote con­trol via HTTP

3. Configure the smartapp via the SmartThings app

  • Open the SmartTh­ings App on your mobile device
  • Click on SmartApps at the bot­tom right
  • Scroll down to the bot­tom to “My Apps”
  • Select “Kodi (formerly XBMC)”
  • The auto­mat­ic setup should find your Kodi box, when it has, select it and click done
  • Click “Done” a second time to fin­ish the setup
  • A device will appear in “My Home”, it should show what the Kodi machine is doing. Click on it to get a set of media con­trols

PART C: Using SmartThings routines to turn off sockets when PC goes to sleep

Once the above 2 guides were com­plete it was very easy to cre­ate a SmartTh­ings routine to mon­it­or the status of the PC and turn off sock­ets when it is off, and turn on sock­ets when it is on.

1. Create SmartThings routine

  • Open the SmartTh­ings app on your mobile device
  • Click on the “auto­ma­tion” tab at the bot­tom and then select the “Routines” tab at the top
  • Click “Add a routine”
  • Give your routine a name
  • In the second screen, select the “turn off these lights or switches” and set the smart­plug you want to turn off
  • Next click on “Auto­mat­ic­ally per­form…” and then select “Some­thing turns on or off”
  • In the next menu click on “Which?” and select the vir­tu­al switch you cre­ated for your PC. Change “On” to “Off”
    for the “Turns” option, then click save, then click save again. You should now see your routine lis­ted
  • Cre­ate a second routine to turn the smart­plug back on when the vir­tu­al switch is turned on

What do you think? Drop us a comment below! If you would like to subscribe please use the subscribe link on the menu at the top right. You can also share this with your friends by using the social links below. Cheers.

Leave a Reply