I need some suggestion for a WiFi based smart light switch that can be remotely controlled and has an open API.

WeMo light switch doesn't have open remote API. Same with another popular TP-Link HS200. Most other remote controlled switches I found can only be controlled via their own Apps. There are some GitHub projects which have reverse engineered these apps, but I would prefer to use API directly published by the manufacturer because my project is long term, and I don't want to bet on reverse engineered solution.

3 Answers 3


Your most future proof solutions will be those which fully separate the hardware from the protocol.

Your example HS200 light switch joins many smart outlets in being based on an Embedded Linux system (the source is available in TP Link's GPL Code Center) Chances are, like most of the outlets, the underlying system is one derived from a strange vendor branch of a common Linux distribution intended for routers. Other models might use an ESP8266. Any of these can generally have the stock firmware replaced with a different one, which can act as a server on a local network permitting control that way, and or subscribe to messages relayed through something like an MQTT broker in the cloud, enabling out-of-home control. You retain the full ability to enable either or both paths, to change the rules, and change the service providers.

Should the hardware you were using then become unavailable, because you fully control the protocol, all you need to do is find different hardware on which to run it. Moving the device side code between something like OpenWRT Linux common on router-derived products and a bare metal ESP8266 would be a fair amount of work, but is conceptually straightforward. But moving it from OpenWRT on one router chip to OpenWRT on another, or moving it to whatever Linux (or if you must, even perhaps Win IoT) which runs on your raspberry pi or Edison or Beagle Bone would be yet more direct.

Breaking up the roles of the system into distinct pieces with clear boundaries requires you to do a tiny bit more work up front, but means you'll be able to respond to any changes, in a way you might not be able to if you used a vertically integrated solution from a single vendor.

  • Thanks for explaining the limitation with using 'vertically integrated solution from a single vendor' and the benefits of loose coupling of the hardware and the protocol. If long term future proofing and total control was really important, perhaps, this is the only way to go. But, right now, I am just looking for a little better solution than some hacked API in github. What you proposed is too much work for us.
    – rajendra
    Aug 8, 2017 at 15:43

As Chris said, the key is to separate the protocol from the hardware. But that doesn't mean you have to implement your own firmware! You can choose a switch that supports a common and readily available home automation protocol, such as Z-Wave or Insteon. These are closed protocols, but there is a wide variety of manufacturers that create interoperable components with them. Then, you can use a home automation controller that integrates the home automation protocols with IP.

I use a Vera Edge home automation controller which offers a web API; and there are other choices as well. I chose Vera because the entire system runs locally without requiring access to a hosted cloud interface; there is no monthly service charge, and the device and rules are completely under my control. I can choose to hide the API behind my firewall, expose the API externally myself, or I can leverage Vera's free cloud services to expose the API for me. (As a plus, Vera has a very active community who is constantly adding support for new home automation devices.) Vera does offer a free app for iPhone and Android, but you are not bound to their app. Several independent developers have created their own apps which leverage Vera's API (Grasshopper, VeraMate, and ImperiHome are three such products) to provide alternative GUIs.

If you are opposed to a commercial gateway product, and are willing to put in a lot of work, there are also Open Source solutions for implementing your own home automation gateway that offer a web API. Domoticz and OpenHAB are two projects that spring to mind. However, these packages are both still far less mature than the commercial solutions, and both require a substantial amount of work to implement. (And you indicated you didn't want to hack together a solution.)

The only drawback I see to the gateway-based approach is that your question is asking about "a light switch", implying a quantity of one device. A Z-wave switch can cost anywhere from $10 to $40 (or more), and a commercial gateway can cost $100-$400 (or more.) For a single switch, the price tag likely isn't worth it. If you are automating an entire building, though, the cost of the hub can be spread out among dozens of devices.


I've been buying Sonoff smart plugs on eBay lately and flashed them with custom firmware. This is possible because they are based on the ESP8266. They are very affordable and pretty advanced.

They need to be opened and a pin header soldered onto the PCB, then you have to program them with a FTDI adapter, which you can also get cheap on eBay. It's pretty straight forward.

When flashed they connect to my WiFi network, and sends and receives MQTT commands. I'm using Home Assistant for this.

BRUH Automation has a video about them: https://www.youtube.com/watch?v=-JxPWA-qxAk

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.