Updated WEMO control script

A while ago I wrote a little nodejs script to control WeMo devices. At the time I only had two bulbs that I had in different rooms so it didn’t make sense to support light groups.

Towards the end of 2014 Belkin and Osram announced that Osram’s Lightify bulbs would support WeMo’s bridge controller. In this line was a GU10 bulb and I recently purchased two of these.

Both of these have been fitted into a single light fitting so it made sense to group them together, but this left me with a problem that my script wouldn’t work. After a little bit of playing (and another fruitless back and forth with @WEMOCares on twitter) I managed to get group support working properly. It could do with a bit of cleaning up and refactoring but it works:

16 thoughts on “Updated WEMO control script”

  1. Hi

    First I would like to thank you for offering this program. I have a question about response I get from bulbs which delay a bit. Is it normal for a command to execute after 3-4 seconds ?

    Thank you

    1. Yes, there is a 3 second timeout in the script to allow for full discovery to happen before any commands are fired.

      The script doesn’t cache any data so does discovery every time it runs, it would be possible to cache responses to speed things up, but this code was meant to be more of a proof of concept for people to build on rather than production level code.

      1. Ok it is understood. I’m using it in openhab for switching lights when motion is detected so delay is pretty annoying in such cases. I will see if I can play around with the code.

        Thank you again for your immediate reply !!

        D

      2. Hi again,

        I tried a parameter in the code that seemed to me that was the delay timer but didn’t have any affect (obviously I was touching a wrong parameter..) Could u please give a hint with the name of this parameter and find it myself ?

        Thank you again

        1. The 3000 in line 302 is the 3 second wait for discovery. I wouldn’t reduce it to anything less than 1000 (1 second).

          My work on a better WeMo Node-RED module is going well, I hope to publish it next week, it will keep track of all devices so should have minimal lag

          1. My intention was to play with 1500 which is sufficient for my usage. I’m pretty sure I played with that line so now I’m suspicious that my openhab inserted another delay in triggering the event. Thank you very much and I look forward for your new development.

  2. any help appreciated.

    I’m trying to write a lib for esp8266 that allows you to integrate multiple devices into on device. I’d like the user in the main sketch to register a device, (switch, rgbLED etc…) then when sending setup.xml it includes all the config for these devices and when a command arrives for the device it calls a user callback to action it.

    like this

    wemos.addDevice( new WemosSwitch(“test”, [](bool state) {
    Serial.printf( “Switch has been turned : %s\n”, (state)? “on” : “off” );

    if (state) {
    output(true);
    } else {
    output(false);
    }
    }) );

    I’ve got this working for a switch very nicely, but i’ve no idea how to configure the xml, for multiple end devices. I’m guessing that i’ll have to configure the ESP8266 to be a bridge device.

    Do you have some example setup.xml that you can show me for rgb lights / switches under a bridge?

    would be great

    thanks

    1. I’m not sure I understand what you are asking here, you can’t interact with multiple WeMo devices in a single network exchange, you need to talk to each device individually.

      The WeMo Bridge is purely for talking to WeMo Lightbulbs, it’s called the Bridge because it bridges from TCP/IP to the Zigbee protocol that the lightbulbs use. The bridge offers the option of grouping bulbs together so they act like a single entity, but this is only for bulbs not sockets.

      1. ah ok. That is a little disappointing as it is limited to 16 devices, and i’m building some esp8266 relay boards that have 3 solid state relays on. Would have been good to control all three through one ESP without resorting to defining multiple ports. I guess that emulating a bridge with connected light bulbs even if they are just switches would work no? turn x off, turn x on.

        Should still be possible to emulate a bridge with connected devices? I’m just not sure how at all to even begin.

        Amazon should really build some open source way of using the smart home devices.

        1. OK, it’s now a little clearer what you are trying to do. You could emulate a bridge in order to collect together a group of devices.

          But based on your last comment you are looking to do this with a Amazon Echo, unfortunately the Echo does not support WeMo lights so this won’t work. Now having said all that, come back next week when I hope to have finished my Echo to Node-RED Home Skill bridge that will allow you to control anything that you can control with Node-RED

  3. Did you manage to figure out how to interrogate each bulb for its firmware version and also then compare with latest firmware available?

    1. No, the current version is probably in the data returned, but I never tried to use the firmware upgrade endpoints.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.