WEMO,( IFTTT) and Wink Spotter

Forum rules

Questions about hardware that can be controlled by Indigo (but not through the interfaces and plugins listed). If Indigo doesn't support some bit of hardware you're interested in, and you don't find a 3rd Party Plugin for it, add it to this forum. Be sure to include links to as much information as you can find about it.

Note: adding it here does not mean we're going to add it - in fact it's possible one of our 3rd party developers may decide to write a plugin for it. We add hardware/features based on a lot of different factors beyond just having a request for it.

Posted on
Thu Feb 16, 2017 10:06 am
Richard offline
Posts: 68
Joined: Feb 05, 2015

Re: WEMO,( IFTTT) and Wink Spotter

Thank you for your hard work and sharing the script. Works Great!

Posted on
Fri Apr 20, 2018 6:01 pm
DVDDave offline
Posts: 280
Joined: Feb 26, 2006
Location: San Jose, CA

Re: WEMO,( IFTTT) and Wink Spotter

mclass wrote:
Having had a Wemo Insight switch fall into my hands, I have searched the Indigo forums for means to integrate the device with Indigo - without success :roll:

Searching further, I have come across a script that I have successfully deployed (with some minor changes) as a series of action groups to turn the Wemo on and off, toggle the state and to determine its state. Regrettably, I am not sufficiently software literate to develop this further into a plugin, but have posted it it in the hope that it may generate further interest in developing support for this and other Wemo devices!

Note that the Wemo app is still required to set up the switch on the local wifi network.
...
mclass

Thanks for this great code! I made a few modifications to fix up the status messages and make it more convenient to use a Wemo mini switch as a virtual device. The switches are on sale at Costco for $40 for 2 of them. Much cheaper than any other switch I know about, especially considering it includes a built-in pushbutton and returns status. WiFi is a good alternative to my cheap X10 switches for some tricky locations and the range seems quite good. The switch was a little finicky to set up but seems to be working reliably now.

Code: Select all
# Python script to operate or obtain status of Wemo switch
# based on a script WeMo.py published by pruppert on GitHub
# at https://gist.github.com/pruppert/

# Usage:
# Tested with Wemo Mini switch as an embedded script in an
# Indigo Action Group/Virtual Device

#!/usr/bin/python

import re
import urllib2

# Configuration:
# Enter the local IP address of your WeMo in the parentheses of the ip variable below.
# You may have to check your router to see what local IP is assigned to the WeMo.
# It is recommended that you assign a static local IP to the WeMo to ensure the WeMo is always at that address.
# Uncomment one of the triggers at the end of this script.
# Insert the appropriate message for the Indigo event log near line 89

ip = 'insert address here'
WemoVar = "Insert name of Indigo status variable here"

class wemo:
   OFF_STATE = '0'
   ON_STATES = ['1', '8']
   ip = None
   ports = [49153, 49152, 49154, 49151, 49155]
   

   def __init__(self, switch_ip):
      self.ip = switch_ip     
   
   def toggle(self):
      status = self.status()
      if status in self.ON_STATES:
         result = self.off()
#         result = 'WeMo is now off.'
      elif status == self.OFF_STATE:
         result = self.on()
 #        result = 'WeMo is now on.'
      else:
         raise Exception("UnexpectedStatusResponse")
      indigo.variable.updateValue(WemoVar, value=result)
      return result   

   def on(self):
      status = self.status()
      if status in self.ON_STATES:
         result = status
      elif status == self.OFF_STATE:
          result = self._send('Set', 'BinaryState', 1)
      else:
         raise Exception("UnexpectedStatusResponse")
      indigo.variable.updateValue(WemoVar, value=result)
      return result   

   def off(self):
      status = self.status()
      if status in self.ON_STATES:
          result = self._send('Set', 'BinaryState', 0)
      elif status == self.OFF_STATE:
          result = status
      else:
         raise Exception("UnexpectedStatusResponse")
      indigo.variable.updateValue(WemoVar, value=result)
      return result   

   def status(self):
      result = self._send('Get', 'BinaryState')
      indigo.variable.updateValue(WemoVar, value=result)
      return result

   def name(self):
      return self._send('Get', 'FriendlyName')

   def signal(self):
      return self._send('Get', 'SignalStrength')
 
   def _get_header_xml(self, method, obj):
      method = method + obj
      return '"urn:Belkin:service:basicevent:1#%s"' % method
   
   def _get_body_xml(self, method, obj, value=0):
      method = method + obj
      return '<u:%s xmlns:u="urn:Belkin:service:basicevent:1"><%s>%s</%s></u:%s>' % (method, obj, value, obj, method)
   
   def _send(self, method, obj, value=None):
      body_xml = self._get_body_xml(method, obj, value)
      header_xml = self._get_header_xml(method, obj)
      for port in self.ports:
         result = self._try_send(self.ip, port, body_xml, header_xml, obj)
         if result is not None:
            self.ports = [port]
         return result
      raise Exception("TimeoutOnAllPorts")

   def _try_send(self, ip, port, body, header, data):
      try:
         request = urllib2.Request('http://%s:%s/upnp/control/basicevent1' % (ip, port))
         request.add_header('Content-type', 'text/xml; charset="utf-8"')
         request.add_header('SOAPACTION', header)
         request_body = '<?xml version="1.0" encoding="utf-8"?>'
         request_body += '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
         request_body += '<s:Body>%s</s:Body></s:Envelope>' % body
         request.add_data(request_body)
         result = urllib2.urlopen(request, timeout=3)
         return self._extract(result.read(), data)
      except Exception as e:
         print str(e)
         return None

   def _extract(self, response, name):
      exp = '<%s>(.*?)<\/%s>' % (name, name)
      g = re.search(exp, response)
      if g:
         return g.group(1)
      return response

def output(message):
# Write message to Indigo server event log
   indigo.server.log ("Wemo Device Name - " + message)

switch = wemo(ip)

# Configuration:
# Uncomment only one of the lines below to make the script work.

#output(switch.on())
#output(switch.off())
output(switch.toggle())
#output(switch.status())

Posted on
Fri Apr 20, 2018 6:04 pm
Different Computers online
User avatar
Posts: 1675
Joined: Jan 02, 2016
Location: East Coast

Re: WEMO,( IFTTT) and Wink Spotter

very slick automation through a simple and intuitive cloud services


My experience with IFTTT was that it was none of these things. From having relied on it heavily when I was using the god-awful SmartThings, with Indigo I now use it not at all.

I've come to realize that any competently designed HA system (of which there are astonishingly few examples besides Indigo) does not require IFTTT integration, because all the services you need are already integrated one way or another. And usually multiple ways!

For example: Philips Hue? There's an Indigo plugin for that with more capability and 100% local. Also 100% more logging and troubleshooting, which IFTTT is *terrible* at.

Weather statuses? There are at least two if not three plugins for that, and even one that works with your own weather station equipment directly.

Alarms and time based triggers? Built in, and more flexible than IFTTT.

Automatic? Plugin. Nest? Plugin. That list goes on and on.

Wemo? From everything I read, and everything I know about Belkin, it's unreliable hardware. Buy better stuff from other manufacturers for the same price.

SmartThings refugee & happy to be on Indigo now.
Mac OS 10.12.6 on a i5 MBP running Harmony Hub, Hue, DomoPad, Dynamic URL, EPS Device Extensions, HomeBridge Buddy, Smart Dimmer, MatplotLib, Plex, Scale Adapters, uniFAP, Wunderground, Airfoil Pro.

Posted on
Sun Apr 29, 2018 9:45 am
DVDDave offline
Posts: 280
Joined: Feb 26, 2006
Location: San Jose, CA

Re: WEMO,( IFTTT) and Wink Spotter

jay (support) wrote:
We continue to evaluate the various technologies out there for inclusion in Indigo, but the demand for Wemo support has thus far been very limited in comparison to other things (Indigo Touch, more extensive Z-Wave support, etc.) that are a much higher priority.

We would certainly love to see a 3rd party developer add Wemo support via a plugin but none seem to be particularly interested at the moment.

Hi Jay,

FWIW, I'd like to echo what others have said about wanting Wemo support in Indigo. The inexpensive switch from Costco that I integrated has been working very well. I think the inexpensive Wemo units are a good substitute for cheap X10 devices to allow whole home automation at a much lower cost than z-wave, insteon and others. They also work at wifi distances which is farther than other technologies in my experience. Low demand may be a chicken and egg issue since I put off buying one due to lack of Indigo support for them. I finally got it when I saw the script posted by mclass. A plug-in would be ok, and I wish I had the capability of creating one, but I agree with others that Wemo is getting much bigger now as evidenced by Costco selling them. Just my 2 cents. Thanks as always;

--Dave

Posted on
Mon Apr 30, 2018 9:47 am
jay (support) offline
Site Admin
User avatar
Posts: 14074
Joined: Mar 19, 2008
Location: Austin, Texas

Re: WEMO,( IFTTT) and Wink Spotter

DVDDave wrote:
FWIW, I'd like to echo what others have said about wanting Wemo support in Indigo. The inexpensive switch from Costco that I integrated has been working very well. I think the inexpensive Wemo units are a good substitute for cheap X10 devices to allow whole home automation at a much lower cost than z-wave, insteon and others. They also work at wifi distances which is farther than other technologies in my experience. Low demand may be a chicken and egg issue since I put off buying one due to lack of Indigo support for them. I finally got it when I saw the script posted by mclass. A plug-in would be ok, and I wish I had the capability of creating one, but I agree with others that Wemo is getting much bigger now as evidenced by Costco selling them. Just my 2 cents. Thanks as always;


Thanks for the feedback. If you look at this thread, for example, I think you'll see what we mean by low demand (mclass only looked into it because one "fell into his hands"). And another interpretation for something showing up in Costco is that they aren't selling well... ;)

But, in any event, now that mclass has done at least part of the work someone else could build the plugin so if there's sufficient demand I'm sure one of our 3rd party developers will pick it up.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Apr 30, 2018 9:53 am
DVDDave offline
Posts: 280
Joined: Feb 26, 2006
Location: San Jose, CA

Re: WEMO,( IFTTT) and Wink Spotter

jay (support) wrote:
Thanks for the feedback. If you look at this thread, for example, I think you'll see what we mean by low demand (mclass only looked into it because one "fell into his hands"). And another interpretation for something showing up in Costco is that they aren't selling well... ;)

But, in any event, now that mclass has done at least part of the work someone else could build the plugin so if there's sufficient demand I'm sure one of our 3rd party developers will pick it up.

Good points. You may be right and time will tell. Thanks.

Who is online

Users browsing this forum: No registered users and 2 guests