Quantcast
Channel: Desert Home
Viewing all articles
Browse latest Browse all 218

Wemo Light Switches and Intermittent Failures ... Found it!

$
0
0
I have four Wemo light switches operating around the house on outside lights.  You know the ones.  They're the switches that you remember after you get in bed and have the covers pulled up.  In my case, I just grab a phone and turn the darn things off from the bed ... except ...

Every once in a while they don't respond.  This has driven me nuts ever since I got the switches and I'm not alone.  There are other folk out there that have been annoyed by this behavior.  After I simplified my code running the switches <link>, and the problem was still there; I set out to see what the heck was going on.  At first the code would hang waiting for a response from the switches, so I put a timeout on the socket read.

When the inevitable timeout came, I at least had a clue; the switch just quit responding.  So, I caught the timeout and printed the URL that was involved.  A few days later, it timed out again and I discovered that the IP address was ok, but the port number the Wemo was listening to had changed.  There's simply no reason for the port number to change ... unless the switch had done it intentionally.  Naw, no one would do that.

Then, the power failed to my house and everything rebooted.  Fine, I'd wait until it happened again.

One evening, one of the switches failed.  I got an email telling me the switch had gone off line.  Yes, an email.  One of the great things about working on a Pi is that it can do things like this.  I had put code in to send me an email when one of the switches got into this state.  I checked the logs (another great thing) and sure enough, the port number had changed.  A little while later, another switch failed, then the other two as well.  The period of working was roughly three days, and then, the switches would change the port number they responded to.

I don't have definitive proof, but I firmly believe they reboot the switches every three days.  Over time I could probably accumulate evidence to support this, but I don't want evidence; I want the darn switches to work.

What I had done in the code was to set a timeout on the socket receive from a polling request to the switch.  When it timed out, it would send me mail and then my process would exit.  Since the process is controlled by upstart (google it), it would start right back up and rediscover the switches.  Everything should be fine then because the new port number would be recorded and control would be set up correctly.  I actually rebooted the control process to just start over.  Not very elegant, but it worked.  When the four switches went south, the process restarted each time and got control back.

Ha, take that Belkin.

Of course there's a downside.  During the time the process is restarting, there could be a command to the switches missed.  It takes about 30 seconds to discover the switches and get all set up so the window is small, but it's there.  I think I can live with that.  I removed the code that sends mail to keep the changes I make to Miranda to an absolute minimum and have the changes running right now.  After a couple of weeks, I'll know how well it worked out.

It's very important to me to avoid relying on an external service to control something around my house, so things like If This Then That, are not an option.  Sure, I like the Wemo app for checking the lights from town, but I don't want to rely on it.  The Internet is just too flaky, companies change policies, and people like to muck with other people's stuff.  I want control inside my own house.

I'm getting closer now.

Viewing all articles
Browse latest Browse all 218

Trending Articles