New WeMo Nodes for Node-RED

Based on my previous playing with a set of Belkin WeMo sockets and lightbulbs I decided to have a go at improving support in Node-RED.

I’ve built 2 new nodes, control and event nodes.

WeMo Control Node
WeMo Control Node

The control node accepts the following values in the msg.payload

  • on/off
  • 1/0
  • true/false
  • A JSON object like this
    {
      state: 'on'
      brightness: 255
      color: '255,0,0'
    }
WeMo Event node
WeMo Event node

The input (event) node now uses uPNP events rather than polling status from the devices every 2 seconds. This means you won’t get the “nc” no change messages but you will get events when lights change brightness or colour as well as on/off messages.

Both nodes use a shared config node that uses uPNP discovery to locate WeMo devices on your local network so you don’t have to work out what IP address and port number they are using.

WeMo Device discovery
WeMo Device discovery

Discovery runs once a minute to ensure all devices are found and any change in IP address or port number are quickly picked up. First discovery may take a little while so please allow a little time if you don’t see all the devices you expect listed when you look in the config node.

All the code is up on github here, I’ll push them to npmjs after people have given them a bit more of a test and I’ll have a chat with the Node-RED guys about maybe swapping out the original WeMo node. There is basic backwards compatibility with the original WeMo node, but the nodes work better if after upgrading you use the configuration dialog to pick a discovered device from the list.

15 thoughts on “New WeMo Nodes for Node-RED”

  1. Leaving a comment to subscribe to follow ups. Please leave a comment when you add this to npm.

    1. I need to find time to roll it into the node-red-nodes package to replace the existing wemo node.

      In the mean time you can install it directly from github with npm:

      npm install hardillb/node-red-contrib-wemo-ng

  2. Man, you did a great job, thank you !
    I’m subscribing too to be notified when it is pushed to the “official” module :-)

  3. Hi there I have been using the Wemo node-red nodes and they are working great. I do have one problem with the Wemo motion sensor. I wish to send the output which is json thing with state as a boolean and send it to the ui node “chart” which needs a number. If I extract the state and make it a number the chart node still does not accept it.

    Also I noted sometimes my router fails in a strange way and the wemos are lost. After a restart of the router the wemos did not get found so after an hour I restarted the node-red and they were found

    1. If you have bugs please raise them as issues onthe appropriate github project.

      And you’ll do better discussing how things work on the mailing list rather than here

  4. Curious if you know the uPNP ports Wemo uses. I can open specific ufw ports, but can’t disable ufw altogether. My NR install isn’t discovering my Wemo devices. Left a DM on Slack as well, so pardon the dupes.

    1. There are 2 separate problems here:

      1. Discovery, this uses SSDP which sends a broadcast UDP packet from which any device can respond. Because it’s UDP it’s stateless so you can’t easily use connection tracking to work out who is responding. The outgoing packet is on port 1900 and responses should come from the same port, but I’m sure I’ve seen cases of random reply source ports. There is supposed to be a iptables plugin to support this, but I’ve never been able to find a system with it enabled. The closest I’ve seen is this
      2. The second problem is the UPnP notifications, these should just be HTTP and will be delivered to the same port that Node-RED is running on, so should be ok as long as you’ve allowed your network access to 1880
  5. Hi Ben. Great work and fascinating things! I am trying to emulate wemo lights using nodejs, as this is an easy way for Alexa/Echo to control devices over the local network without using custom smarthome skills, which already works great for setBinaryState on/off. Now I would like to also add functionality to emulate brightness / dimming. Unfortunately I don’t own any wemo hardware to reverse engineer and also can’t find any information about how the devices announce their capabilities for brightness adjustment to upnp discovery requests. From looking at the sources of various wemo remote control libraries, I guess brightness can be set using a setDeviceStatus call with option 10008 to set brightness of a lamp. Do you happen to have a wemo device which supports dimming? it would be very helpful to see how that device responds to upnp discovery broadcasts. thanks!

    1. You don’t uPnP discover bulbs, you discover the bridge then you need to query the bridge for what bulbs it can see.

      Details about how to discover bulbs is in my other blog post about the wemo control script. When you get the Paired Device list it includes the list of capabilities each device supports.

  6. Looks very interesting and I’m thinking of trying it. Just have a few questions. Does it support the motion sensor as well? And will this stop working in case there is a firmware upgrade pending? I know a python lib I used before had troubles with this and updates are rather frequent with Wemo… :(

    1. I don’t have motion sensor so really can’t say. If it uses the basic event notification then it should do. As for firmware updates it’s been working for well over a year for me but who can say what Belkin will change in the future.

  7. I have tried it out now and the output nodes work fine. But it seems that after a while my input node stops working (connected to a motion sensor). I trigger the motion sensor, but doesn’t get anything from the node. The icon says is is connected, but I don’t know if I can get any more debug? Please help me figure this out. I am a developer myself, but I’m not familiar with how node-red debugging is done…

    1. The problem is that the wemos seam to forget the upnp subscription from time to time for no obvious reason. The latest version reduced the time between renewing the subscriptions to renew at about a third of the period before it would expire and it got better, but can sometimes still be flaky. The code should try to subscribe again if the resubscribe fails, but it may miss events in between. It may also be related to if the wemo device drops off the wifi (even very briefly). I’ve tried to debug it but due to how infrequently it happens for me I’ve not got to the bottom of it. The code is all here if you want to have a look.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>