Belkin Wemo motion and TP-Link HS110 smart switch with energy monitoring

November 27, 2016


Gadget Pros Cons
Wemo motion
  • High accuracy detecting motion
  • Easy setup
  • Mobile app can connect the devices from different network
  • Belkin released wemo bridge so that all of their wemo devices become homekit compatible. 2018-01-08
  • No official API/SDK
  • No working open source api for motion detection/event subscription. ouimeaux can switch on and off the switch, but not able to listen to motion detection event. Did not yet try another node.js open source api at the moment. Update here later. wemo bridge can overcome this with apple homekit! nice!
  • Buggy mobile apps. IOS app never able to configure the motion and switch, not usable at all. Android app able to configure both the motion and switch, but still have problem upgrading firmware for the devices. Need a lot of lucks to have the things being configured.

    Fixed after couple mobile app updates recently. 2017-01-25

  • Using uPnP and SOAP… Requires Wifi… Need to turn on uPnP from broadband router. I always prefer devices using either bluetooth like EVE or a LAN bridge like HUE.
TP-Link HS110
  • Just works as it should
  • Easy setup
  • Plain http call (rest).
  • Have open source api to manipulate the switch
  • Official android and ios apps working well.
  • Mobile app need to be the same network to access the device.
  • Scheduled jobs not always executed
  • Requires Wifi

I purchased the wemo motion and tp-link hs110 from HKTV and it delivered to me yesterday.

Both were great toys. As this give me further control to more electronic that I would like to turn on and off.

Talk a look at the wemo motion first.



The package comes with a sensor and a smart switch. The little sensor itself attach to a switch like adapter which need to plug into a socket as power source. Of course it is not just an power adapter, it should be the thing which actually collect data from the sensor, interact with your wifi and mobile application.

The setup is easy. But the firmware is a little bit too out-of-date. Even the WEMO mobile app refused to upgrade the firmware as the firmware of the motion is way too old. This is SUCK. I still try to figure out how to perform a firmware upgrade yet.. But anyway, it is working fine without firmware upgrade.

The first thing I do for this sensor thing is to integer with IFTTT such that when motion detected, have IFTTT turn on the Philips HUE light. It works, but, but… IFTTT reaction time is about 15 minutes….. which is a joke. I have to give up IFTTT.

So I have a looks at WEMO SDK instead and see if I can code an android app to fix this. But so sad, Belkin shutdown the SDK… This is a Hugh disappointment. I should have look at this before purchase. I further research on open source api and I found a python api and a node.js api. I’ll spend time on those API later on.

After the disappointment, I open the box of TP-LINK HS110. The setup of HS1110 is almost the same as WEMO. Which is also very easy. The max load of this switch is 13A which is good enough to handle the air conditioner in our bedroom. Can’t use it in Living room because that air conditioner requires 15A.

TP-LINK HS110 [UK Version]

TP-LINK HS110 [UK Version]

HS110 is working well. The app can turn the switch on and off, with figure of energy consumption, which is nice. So you can calculate how many you got to paid to turn the electronic on.

The main goal I purchase these switch is automation. I research open source api for HS110 and I found a very simple bash script provided by George’s Techlog: Controlling the TP-LINK HS100 Wi-Fi smart plug .

It was written for HS100 and only a few modification it works very well on my HS110. I further enhance the script with python and made a php script so that I can control HS110 with a simple HTTP request. That mean I can turn it of and off with my Kiosk made by Raspberry Pi. For automation, simply create cron job which firing HTTP request with curl command.

HS110 is far exceeded my expectation and I’ll probably get a few more to have everything in my home fully automated.

Security Concerns

Hacking these switch is so simple which is really bad for security. Imagine a hacker hacked your wifi or gain the backdoor on your dirty PC which allow them to control your IOT so easy. If you played WATCHDOG, you should harden the security of your home network otherwise you will become one of the WATCHDOG citizen ;p

Update on Wemo Motion 2017-01-15

Pretty disappointed on Belkin WeMo motion.

  1. Firstly, the iPhone app never works for the motion. It detects firmware upgrade needed, and refused to perform anything without upgrade firmware first. Fine. But the app never able to perform firmware upgrade on the devices. That make the whole things not doing anything. Luckily, I was an Android fan and so I tried Android app and it able to perform firmware upgrade for the motion. And I am able to edit rules for the motion. That make the things working, at least. But still, the Android app not able to perform firmware upgrade for the switch… But it don’t block the use of the devices…
  2. There is no official open api to control the things. And it use uPNP standard, which I hate most. I find ouimeaux python scripts version 0.8. It able to detect my motion and switch, I can program a python scripts to switch on and off the switch. But ouimeaux signal/events never works on both switch and motion. So no motion detection for the python scripts. That’s not nice.
  3. btw, I have turned on uPNP feature on my broadband router. I used to have uPNP off because security concerns.
  4. So, for the motion to works, I need an Android devices. And no working api for further customizing the motion detection events.

Last Resort for customizing motion detection

The last resort for turning on all HUE lights when motion detects should be either

Workaround 1

  • Setup an always on Android device (can I run android on raspberry pi??)
  • Write a custom app which always listen to wemo motion push notification event.
  • Fire HTTP request to my raspberry pi to turn on HUE light

Workaround 2

  • To have the motion turn on the wemo switch once motion detected.
  • Setup a scheduled job to monitor the status of the wemo switch per 5 seconds.
  • Fire HTTP request to my raspberry pi to turn on HUE light once the switch is turned on by the motion.

Those ‘solution’ is never ideal. But it should works.

I will update the solution above once I get it done.

Update 2017-01-16

Okay. Both workaround works. For workaround 1, I’ve written a very simple android app to call my rest api to turn on HUE lights when wemo motion push notification detected. The Android app simply use Accessibility Service to monitor push notification event for the WeMo App then fire the HTTP call to turn on HUE lights.

This solution is very silly, but works quite well. It can be broken anytime when Belkin upgrade their app and have things changing from time to time. But it don’t need constant polling.

Highlight of the Android code


This first thing to do is to create a new AccessibilityService. From the onAccessibilityEvent() function, trigger the background task which actually fire the http request to my raspberry pi php. You need to act for the WeMo app’s notification only, do this by filtering the TYPE_NOTIFICATION_STATE_CHANGED event and only for the package “com.belkin.wemoandroid”.

public class WeMoAccessibilityService extends AccessibilityService {

	public void onAccessibilityEvent(AccessibilityEvent event) {
		if(event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED  && "com.belkin.wemoandroid".equals(event.getPackageName().toString())){
			//Trigger URL
				Toast.makeText(getApplicationContext(), "Triggering HUE Lights", Toast.LENGTH_LONG).show();
				RestfulTask task = new RestfulTask(((DetectorApp)super.getApplicationContext()).getMainActivity());

				task.execute((Void) null);
			}catch (Exception e){
				Log.e(TAG_NAME, e.getMessage());



Things need to be done in the manifest.xml as well.

    <application ...>

        <service android:name=".WeMoAccessibilityService"
        	android:label="WeMo Motion Detector"
		         <action android:name="android.accessibilityservice.AccessibilityService" />
            	android:resource="@xml/accessibilityservice" />


     <!-- Network State Permissions to detect Internet status -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

Create the accessibiltyservice.xml

The xml should be created under res/xml directory.

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:notificationTimeout="100" />

And don’t forget to turn on the accessibility setting from the system preference.

It is all that simple.

The Drawback

If I have another motion installed, the ‘solution’ break. The app can’t tell which device detected the motion. The android event just don’t have enough information to tell.

Workaround 2 should be better, and it works for multiple motion as different script monitors different wemo switch. But it need constant polling. For some reason, the main hub I setup to run all my scheduled jobs (a raspibery pi 2) cannot run the ouimeaux script. The pi I used for experiment is working fine however. I don’t want to have production job running on an experimental device. Need further time to troubleshoot before I can apply workaround 2 and install more wemo motion for the bedrooms later. The main difference between the main hub and the experimental pi is that the main hub is secured by the firewall, while the experimental pi have no firewall at all, and it runs newer version of Raspbian OS. In order to use mutliple motion I will need workaround 2 running on my main hub.

Python script for workaround 2

#!/usr/bin/env python3

import subprocess
import urllib2
from ouimeaux.environment import Environment
from ouimeaux.signals     import statechange, receiver

def on_switch(switch):
        print "Switch found!", switch.name

def on_motion(motion):
        print "Motion found!", motion.name

env = Environment(on_switch, on_motion);

switch=env.get_switch('WeMo Switch')

state = switch.get_state()

if state == 1:

Workaround 2 need at least port 54321 to be open for uPnP devices discovery.

Update 2017-01-25

The latest wemo iOS app finally able to perform firmware upgrades for my motion and switch.

Update 2017-02-04

I give up customizating Wemo motion using an always-on nexus 5x. The ‘solution’ works, but the Nexus 5x need reboot constantly to keep it functioning. Android phone is not designed that way. And the ouimeaux scripts solution only works on the raspiberry pi without firewall on. I don’t want to run a linux device without firewall up. I need the security. I decided to give up Wemo motion to turn on HUE light. Just have it turn on the Wemo switch to control other appliance.

I’ll try Elgato Eve Motion instead which is homekit compatible. It must works well with my HUE lights without any programming >_<

Update Nov 25, 2017

The task scheduler of TP-Link HS110 requires Wi-Fi connection always on. I only have wifi running 802.11x which HS110 cannot connect to. So I have the HS110 connect to the wifi hotspot of my iphone instead. The schedule jobs setup’ed in the Kasa app working ONLY when HS110 have active internet connection on. When wifi is off’ed, the jobs never executed.

Update Nov 30, 2017

Referring to the last update Nov 25, the HS110 was only used to schedule the lighting on the new Christmas tree on and off. Since I figured out the scheduled jobs not executed, I just ignored it, as there are still like a month for Christmas to come. A couple days later, the scheduled job was working suddenly. Able to switch itself on and off as what was configured, without connection to wifi.

So it is weird. It is working, but not as stable as I expected.

Update Dec 1, 2017
Heck, the scheduled jobs not executed again. The scheduled jobs of HS110 is totally unstable.


I gave up both HS110 and WeMo switch+motion. I replaced them with EVE motion and EVE energy switch instead. Don’t bother with HS110 and WeMo if you have iphone/ipad and Apple TV. EVE only use bluetooth, no dependency on internet connection and wifi at all.

Leave a Reply

Your email address will not be published. Required fields are marked *