Skip to content
Drive the Smart Switch locally from any app in your network.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Drive the Smart Switch locally from any app in your network.


  • Java needs to be installed and on the path.
    • If you know where javac or javac.exe is you can use the full path to it to compile the class.
  • You know the IP address of the switch.
    • Query your router's web page for attached devices HS100
    • You can allocate a fixed ip address so things dont change over time.
  • I have included a compiled file (.class) so you dont really need to compile it unless you change the code (.java).
    • You will need the Java runtime to be installed.
    • just type 'java' on the command line to find out if it installed.

Clone this project:

CD to a project directory (any path will do): On the command line type

git clone

Or just copy the files if you do not have git. You only really need the .class file but make sure it is in the 'external' directory.

The following files and directories are created:

├── external
│   ├── HS100Controller.class
│   └──
  • is the source code. You will need to compile if it is changed.
  • HS100Controller.class is the java executable produced when you compile the source file.
    • The existing file will run on any computer that has Java Rruntime installed.
  • The file you are reading now!


You will need to have the Java Development Kit (JDK) installed to compile the code.

From the root directory. The one with the file in it, type:

javac external/

This will create a new HS100Controller.class file.

Test the program

Assuming your device has an ip address like this '' you can execute the program as follows:

java external/HS100Controller

One of two things will happen:

  1. A long String will be printed to the log.
    1. If this happens your are good to go.
    2. This string contains status data from your switch. (More on this below)
  2. The program hangs (freezes) for about 15 seconds
    1. This means the ip address is probably wrong.

Be patient. It often takes a couple of seconds to wake up!

Read the help

java external/HS100Controller

This will uptput the usage instructions (I wont include them here as you can see them for yourself).

Turn the switch ON

java external/HS100Controller on

The following text should be output:


Turn the switch OFF

java external/HS100Controller off

The following text should be output:


Fetch the device status

java external/HS100Controller status


java external/HS100Controller

Note this is the default behaviour if no action is defined

The following text should be output (note. I have changed the id's to ? to hide my device):

{"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 171213 Rel.101014","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS100(UK)","mac":"??:??:??:??:??:??","deviceId":"?????????????????????","hwId":"?????????????????????","fwId":"00000000000000000000000000000000","oemId":"?????????????????????","alias":"plug 1","dev_name":"Wi-Fi Smart Plug","icon_hash":"","relay_state":1,"on_time":7194,"active_mode":"schedule","feature":"TIM","updating":0,"rssi":-65,"led_off":0,"latitude":99.99,"longitude":99.99}}}

A clearer version of that data follows:

To see this go to the following site and paste the text from your device in to the empty box. Then press the Validate button. The text will be re-formatted to look somthing like this:

         "sw_ver":"1.2.5 Build 171213 Rel.101014",
         "alias":"plug 1",
         "dev_name":"Wi-Fi Smart Plug",
         "relay_state":1,            <--- This is the important line --->

If the switch is ON:


If the switch is OFF:



Thanks to the following articles who's authors inspired this work!

Visit their sites to get more information on the TP-LINK switches.

And Mkyong for the REGX ip validation.
You can’t perform that action at this time.