This how-to was originally posted inside of this thread. I am starting a separate thread to gain additional visibility for anyone who is looking.
Special thanks to @dbej for creating the DTH and code for this, this is all his work. I’m just the messenger
Note: This setup requires the use of an internal “gateway” server/PC that receives commands from the SmartThings hub and translates/forwards them on to your TP-Link HS-100 outlets, so it’s more complex than the typical smartapp & DTH type integration. The instructions below are specific to a Windows environment, but several community members have been able to accomplish the same integration using a Raspberry Pi or similar. While @dbej used Docker to get this up and running, I am using a node.js command prompt instead, so keep in mind that there are other ways to do this that may be better suited to your needs.I recommend reading the original thread linked above to catch up on all of the conversation around this integration.
- Windows machine that stays turned on, logged in, and connected to your local network all the time. This will be your gateway PC
- Static IP address for your gateway PC. Assign through your router.
- Static IP address for each of your TP Link smart outlets (you can find the MAC addresses for your outlets in the Device Settings page in the Kasa app if needed)
- I recommend disabling automatic updates on the gateway PC so it does not auto-restart and kill your node.js session. Do this at your own risk.
Install node.js. Link here: https://nodejs.org/en/download/ note - make sure you get the msi installer package, not just the exe binary
Extract the zip file to whatever location you want. Name the folder something rational. For these instructions, I put the files in c:\test\hs100
Open a command prompt and navigate to the folder where you extracted the zip file from @dbej and run the command “npm install”. This will install the current 0.3.0 version of the hs100-api.
Go back to your command prompt, go to the hs100 folder, and run the command “node hs100.js”. This starts the gateway server listening for commands from SmartThings hub to forward to your TP Link outlets. This window has to stay open for this to work correctly. If it closes, the outlets will stop functioning with SmartThings.
Log in to SmartThings IDE, then go to “My Device Handlers”. Click the green button for “Create New Device Handler”.
On the Create New Device Handler page, choose the “From Code” option at the top. Paste in the raw groovy code from dbej site, then go to the bottom and click the “Create” button. https://gist.githubusercontent.com/danlogan9/66b8ed43c1cb372e3811756a737397b2/raw/bcd97ef4ded9d44075cb60dc0ef916a2d206e0b6/tplink-hs-100.groovy
On the next page that opens, click Publish, then For Me.
Go to My Devices in IDE, click on New Device in the top right corner (you will repeat this step for each of the outlets you have)
- Name - enter a unique name. I have 3 HS100 outlets, and named them HS100-1, HS100-2, HS100-3.
- Label - enter a label, this is what will show in the SmartThings app
- Device Network Id - enter a unique ID. I used tplink001, tplink002, and tplink003
- Type - select tplink-hs-100 from the drop down list (should be at the very bottom of the list)
- Version - Published
- Location and Hub - select for your setup
- Group - leave blank for now, you can assign to a room later through the app
Now that your device is created, you need to specify the IP addresses for your gateway PC and each outlet. To do this, click on “edit” next to Preferences (or find the outlet in your list of Things in the ST app, and go to settings).
Enter the IP addresses for the outlet and gateway PC, then enter port 8083 (I believe this can be changed by editing the hs100.js file, but default is 8083). Click Save.
Go into the SmartThings app, and you should now see your new outlets in your list of things. Turn one of them on and off a few times. Watch the command prompt you left open, you should see log entries for on and off, and your outlet should be turning on and off.