ouimeaux 0.3 released: Device Caching, Aliases, Configuration Options and More

In response to a couple of tickets, I've released ouimeaux 0.3. It includes some bug fixes and a few nice features:

Device Cache

Discovery results are now cached on the filesystem, so command-line operations will be much faster to initialize. The cache can be disabled with the --no-cache option.

Aliases

Some device names are long or contain spaces, which makes using them on the command line unwieldy. You can now define aliases that make that easier to deal with. For example, you can alias "TV Room" to "tv" allowing you to run wemo switch tv on.

Discovery Response Server Binding

The UDP server that listens for responses to the UPnP broadcast can now be configured to bind to a specific IP and port.

Config File

You can configure all of the above by modifying ~/.wemo/config.yml. It's fairly self-explanatory.

Toggle command

Tiny feature: You can now pass "toggle" as well as "on" or "off" as a wemo switch command.

pip install or fork at will, and let me know how it goes.

PyPI

GitHub

18 comments

  • Unknown  
    June 14, 2013 at 10:48 PM

    Hi, I found this framework, and it's cool.But when I'm using register_listeners method, it tells me AttributeError: 'Motion' object has no attribute 'register_listeners'. I googled it and read the code, looks no register_listeners method. How could i fix that?

    thanks a lot!

  • Anonymous  
    August 20, 2013 at 12:51 AM

    Love the idea of this but I am having a bit of trouble with ouimeaux. Not sure if you are willing to give support to a guy that has very little experience with python....

    I was able to successfully compile this on a debian box I have. I also have 3 WeMo Switches on my network. However, running "wemo list" returns nothing. Wondering if this is a linux issue since it seems you are developing this with python in windows... any suggestions are much appreciated!

    keep up the great work!

  • Anonymous  
    August 20, 2013 at 12:57 AM

    To further add - not sure if you want to try to reproduce this - this is what I did on a fresh debian install to try to get ouimeaux to work:

    install libevent-dev
    install python
    install python-all-dev
    install python-setuptools

    easy_install greenlet
    easy_install gevent
    easy_install ouimeaux

    after doing all that - running "wemo list" produces nothing. Maybe I missed something?

  • Ian McCracken  
    August 20, 2013 at 10:20 AM

    Nope, developing on Linux and OS X. Actually my Windows testing is nonexistent, I've been feeling bad about that, but a couple people have done it and submitted documentation patches, so maybe I should feel less bad.

    First, you can really just do "easy_install ouimeaux" or "pip install ouimeaux", and it should pull down all the dependencies. However, what you've done is also just fine.

    Second, try clearing your cache and discovering for a little longer. Run "wemo clear" (if you're on 0.4; if not, either upgrade ("easy_install --upgrade ouimeaux") or delete the file ~/.wemo/cache. Then run "wemo list --timeout 10" to listen for responses for ten seconds. Hopefully that will give your devices enough time to respond in your network, at which point your cache will be populated.

    You can always either just clear the cache or pass the --no-cache option, or modify the config file in ~/.wemo to disable the cache.

  • Anonymous  
    August 20, 2013 at 3:37 PM

    I actually tried all of that with the cache settings - even set the timeout to much longer intervals. Still nothing.

    I don't think I am really doing anything strange with my network setup either. I am also able to ping all of my WeMo devices and the iphone app controls them just fine. All of my WeMo's are also on the latest firmware - maybe that is the problem?

    Are there any other tests I can do to better understand why ouimeaux may or may not be seeing the wemo? I know my experience is limited but I would love to do whatever I can to help you try to troubleshoot this problem and improve the tool in case others are having this same problem.

  • Ian McCracken  
    August 21, 2013 at 10:26 AM

    Good thought. Upgraded all my firmware, now I only occasionally find a device. Guess it'll be a long weekend. Thanks!

  • Anonymous  
    August 22, 2013 at 2:53 PM

    Glad I could help point that out - I felt like I was doing something wrong! Let me know if there is something I can do to assist further - thanks very much for your time in making this! Very appreciated!!!

  • Jonathan  
    August 25, 2013 at 10:39 PM

    I'm in the same boat as "Anonymous," but also have the latest firmware.

    I do have one oddity, though. Check out this command and its result:

    root@raspberrypi:/usr/local/bin# wemo list --timeout 10
    usage: wemo [-h] [--timeout TIMEOUT] [--bind BIND] [--no-cache]
    {clear,switch,list} ...
    wemo: error: unrecognized arguments: --timeout 10
    root@raspberrypi:/usr/local/bin#

    What am I missing? Why won't it accept the --timeout flag?

    Also, to clarify, I'm running ouimeaux 0.4.

    Thanks for your work. I've got Siri controlling my Philip's Hue lights very well. If I can get ouimeaux working, I'll really be getting somewhere. And all on a Rapsberry Pi!

  • Ian McCracken  
    August 25, 2013 at 11:53 PM

    --timeout has to be passed before the command list or switch. I should make that more tolerant probably, as it bites me constantly, but it's argparse's default behavior.

    Okay, so I've added a --debug option in version 0.4.1. Please install it (pip install --upgrade ouimeaux) and run "wemo --no-cache --timeout 10 --debug list". Mine stopped failing, and now works every time, so I'm a little stumped.

  • Jonathan  
    August 26, 2013 at 8:24 AM

    I'm having trouble upgrading... Here's the install info that was logged to the screen:

    Downloading/unpacking ouimeaux from https://pypi.python.org/packages/source/o/ouimeaux/ouimeaux-0.4.1.tar.gz#md5=72ee20e644c6bd64d84e4b9704cbb9e8
    Downloading ouimeaux-0.4.1.tar.gz
    Running setup.py egg_info for package ouimeaux
    Traceback (most recent call last):
    File "", line 16, in
    File "/tmp/pip_build_root/ouimeaux/setup.py", line 6, in
    with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:
    IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/ouimeaux/README.rst'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

    File "", line 16, in

    File "/tmp/pip_build_root/ouimeaux/setup.py", line 6, in

    with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as f:

    IOError: [Errno 2] No such file or directory: '/tmp/pip_build_root/ouimeaux/README.rst'

  • Ian McCracken  
    August 26, 2013 at 10:16 AM

    I believe I've fixed that problem. Please try again at your leisure.

  • Jonathan  
    August 26, 2013 at 10:50 AM

    Ok, the fix worked fine and I updated successfully. Here's what I get:

    root@raspberrypi:~/.mypython# wemo --no-cache --timeout 10 --debug list
    DEBUG:ouimeaux.upnp:Binding datagram server to 127.0.1.1:54321
    INFO:ouimeaux.environment:Discovering devices
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    DEBUG:ouimeaux.upnp:Broadcasting M-SEARCH to 239.255.255.250:1900
    root@raspberrypi:~/.mypython#

    Please forgive me if this is some ridiculous error on my part. I'm relearning most of this stuff as I go, as I left software development over 8 years ago!

    Just an FYI, I was able to get the Perl-Belkin-WeMo-API by Eric Blue working, and it detects and manipulates my devices. So I believe they are functioning correctly. I'd still prefer to get your python solution working for me, though.

    Thanks for your help!

  • Ian McCracken  
    August 26, 2013 at 11:00 AM

    Aha! Your problem is that the server listening for responses is bound to 127.0.1.1, so the responses won't ever find their way there.

    Edit ~/.wemo/config.yml. Find the commented-out line that starts with "bind:", uncomment it, and set your local network IP and whatever port you want for the value.

    I need to make the automatic one smarter, but haven't figured that out yet. It'll just take the first resolution, so depending on how /etc/hosts is configured some people get the loopback instead of the local network.

  • Anonymous  
    August 26, 2013 at 11:13 AM

    I'm away at the moment but plan to try this out later in the week when I return. Thanks for all your time put into this!!!

  • Jonathan  
    August 26, 2013 at 2:03 PM

    That certainly did the trick. You said "local network ip," and I wasn't sure if that meant to put the IP of my router or of the machine I was running on. I tried both, and the router didn't work, and the machine I was running on did, so I assume that's correct.

    In any event, your scripts now find and manipulate my devices. I do notice that it takes about 3 seconds for each action, where as the perl script I'm using takes about 1 second.

    I've seen your video with the RaPi, and obviously you're getting nearly instantaneous response. What do I need to do to speed things up? I am allowing my device results to be cached. Is there another step I'm missing?

  • Anonymous  
    August 29, 2013 at 10:40 AM

    haha! it feels great when something works! I had the same problem as Jonathan! Changed "bind" to my machines ip and BOOM - it all works perfectly! This is fantastic!!! Thanks so much for all the help!

  • Ian McCracken  
    August 31, 2013 at 11:09 AM

    Just released 0.4.3 with much better default way to obtain IP, so hopefully the scenarios in which one must pass --bind or edit config.yml are fewer. Also updated docs, and had it print an error message with instructions if 127.0.0.1 is the IP being used.

    Thanks for the leg work!

  • Unknown  
    October 31, 2013 at 8:12 PM

    >>> def on_motion(value):
    ... print "Motion detected!"
    ...
    >>> env.get_motion('Front Hallway').register_listeners(on_motion)
    >>> env.wait()

    Your example for motion register is there one for power point switch one? as i can't seem to get it to work!

Post a Comment