Saturday, April 19, 2014

Android, Samsung Phone, My very own app, and a Raspberry Pi Home Automation Server

I did it; I finally took the plunge and created an app for Android that runs on my phone and controls the house.  I didn't want to go through the learning curve necessary to conquer the Android Development Environment, so I just relied on the web interface for all this time.  The problem is that I got a new phone and it was too great a temptation for me.  I had to do it.

I lucked out and ran across AppInventor 2 from MIT (it was once owned by Google) and it looked pretty cool, so I started trying it out.  The very first tutorial was enough to get me wound up.  Over several days, I experimented and coaxed an app out of it and then went totally nuts.  It's still a work in progress like all my projects, but it is SO COOL!

Here's the screen you see when you first tap on it

The first three buttons: Power, Temp, and Clock open the SteelSeries gauges I've already created and put them up so I can watch them.  The clock is bound to the time at my house so I can see exactly what time it is there wherever I am.  The data is supplied by my Raspberry Pi in JSON format so there is very little traffic to load it down.  All the formatting and such is done exclusively on the phone saving my little Pi for doing the monitoring tasks.  Those buttons were a pain.  Do you know how hard it is to find cool buttons out there?  That is without having to spend days editing them to get them to look OK.  Here's what it looks like with the power gauge showing:

Yes, this is the exact same display code I use for the web interface.  Appinventor 2 has provisions for a little browser that can handle javascript code.  I can't do the fancy graphs yet, because they are Flash based.  I'll have to look into that in the future.  Just for fun, here's the display when I put up the temperature gauge:

I stack the various controls and gauges one on top of the other so I can scroll between them if needed.  For example, Here's the screen when I have both thermostats showing:

I color the buttons yellow to show inactive and green for active which means they should be showing on the screen.  You can see how the two A/C unit selectors are green and below the controls and status of each of them.  One of them is idle and the other is recirculating the air; that's what the green fan is showing.  Yes, the fan turns; figuring out how to make it rotate was painful since the tool doesn't support animated GIFs yet.  The black fan doesn't turn silly, it means it isn't running.  There's also red and blue fans to show heating or cooling.  The tool has a 'picker' screen built into it, so to change the mode from Off to something else I pop up this display to choose from:

There's something similar for the fan also.  I got fancier on the temperature and put up a slider and set buttons:

When you slide it towards the red, the temperature setting goes up and similarly the other direction, then touch set and you have a new temperature setting.  When you touch set, the temperature controls go away and it leaves you with just the thermostat readings displayed.  This gives me darn good control over the thermostats and a nice flashy display.  I put pictures on the lights to show their state:

Those lights were a total pain in the butt.  I had to construct them from pictures that were waaay too big and didn't match the off representation.  Took a few hours using to get them right.  To turn off the lights, just touch the icon itself:

Notice how I managed to find a nice clear bulb and use it for both states.  No, I can't dim the bulbs, nor do I want to.  The garage doors are still pretty primitive:

But, they get the job done.  I want to fancy that display up some over time.  Similarly, the pool controls are still in the beginning stages:

Lots of refinements are needed here.  All of it works though, I can turn on the pool light anywhere I have data service on the phone.  Of course, no rural place would be complete without knowing the state of the septic tank:

When septic gets too full, the OK icon goes red.  I do the same thing when the acid pump goes low.  I show this to people and they invariably click on the septic tank:

I love their reaction when they have to select "I'm a Dummy" from the picker.  There's a couple of Easter Egg messages like that in other places as well.  Hey, gotta have fun with it too ... right?

Needless to say, I spent a heck of a lot of time just playing with the controls and watching things turn on and off around the house.  I actually had the front lights cycling in a kind of rhythm for a while, much to the amusement of the neighbors.  I guess the new will wear off in a few weeks, but then I'll just make something else and hook it into the system.  I'll also be looking for cute icons to include in various places in the app; it would be nice to have a cartoon garage door to show when it is open.  I'm thinking about using my old cell phone as a house control.  Take the battery that expanded out <link> and hook it to power.  Since everything will work except the actual phone, I should be able to turn it into a house controller that sets by the bed, or maybe mount it on the wall.  It would give me great pleasure to repurpose that device so it would actually get some use ... finally.

I can't wait to show this off.  So, people, what's holding you up from building something like this as well?  No, I won't port this to the iPhone.

Sunday, April 13, 2014

Why I'll Never Buy Another Motorola Cell Phone

A couple of years ago I pre-ordered a Motorola Razr Max cell phone.  It came right on time, the day it was released, and was SO COOL!  It was running Android and had all the bells and whistles that modern technology could create.  I specifically waited for this phone because they put a battery in it large enough to last a full day of normal use and because the screen was big enough to actually use the device.

I was so stoked.  I played with it for days, customizing every little tiny feature.  I carried it with me everywhere. It became a companion.  Don't get me wrong, I don't spend all my time chatting on the phone, text messages are mostly unused, and email can wait until I have a real keyboard to use.  But I could turn my lights on using a web browser from the Burger King in town.  This is a techie's dream.

Then one day I was taking a picture in the back yard and the screen cracked.  Yep, it cracked vertically from top to bottom when I touched the little icon on the screen.  I couldn't believe it.  Here was a device that had a Kevlar case and Gorilla Glass screen and was advertised as being able to handle 'real life' that broke under my index finger.

I called the cell phone provider about the problem and met with the, "physical damage is not covered under warranty" line.  I argued for almost an hour that taking a picture wasn't damage, it was normal use, but they didn't give an inch.  I took it to one of the corporate stores and they did the same thing. I was totally annoyed and actually thought about a little mayhem as a possible route to some degree of satisfaction.  I even contacted the manufacturer about it.  The result was exactly the same.  Their logic is that a cracked screen is a result of damage, not bad design or manufacture.  They couldn't possibly be at fault.

Having exactly zero success trying to get someone to acknowledge that there was a problem that needed correcting, I used the insurance I bought along with the phone.  A hundred bucks later, I had a new phone just like the old one, but the magic was gone.  The device was too fragile to trust.  I equipped it with an otterbox, which make it boxy and ugly, but it might survive being used and nursed it along.

During this time I noticed a slight bulge on the back of the phone; the darn battery was swelling.  Yep, the state-of-the-art lithium-ion battery was puffing up and distorting the case.  So much for embedded batteries that you can't change; it was failing in one year nine months and bending the back cover.  Again on the phone with the provider and they say that it's out of warranty and there's nothing to be done, but I could use the insurance again (another 100 bucks) and get a replacement.  I decided not to send good money chasing after bad and continued to treat the phone like a new girl friend until the contract ended.

My thinking was that I'd get a different manufacturer's device and maybe have better luck.  And, as luck would have it, Samsung announced that their Galaxy 5 would come out in a couple of months; last Friday (the release date) my new phone was delivered to the house (again on the day of release).  I'm in love again.

However, I still have a bitter taste in my mouth about putting up with a piece of crap for two years because Motorola created a hunk-o-junk, but I'll get over it in time.  Here's a couple of pictures of the damage done by the expanding battery:

The bulge is really obvious, but take a look at the next photo.

The case has actually split at a seam and you can see inside the phone if you get a flashlight.  This is the damage that Motorola and Verizon won't warranty because too much time has passed.  Just like the crack down the screen they wouldn't cover because of 'physical damage'.  The swelling actually broke the speaker on the back, so I couldn't hear a ring; I had to rely on vibrate for the last month.

What a racket.

Yes, I know that one should get a case for a cell phone.  But doesn't that eliminate the need to make it slim, attractive and stylish?  Take a piece of high tech jewelry and hide it inside a poly carbonate case with a silicon protector around it and it looks like a plastic box, not a cell phone.  Yes, I know that screens can crack, but when you touch it to take a picture??  What the heck is up with that?  That generation of Gorilla Glass doesn't deserve the name.  The good thing is that I tested the heck out of the Otterbox case; I'm certain that the case was the only reason I didn't have to replace the phone a couple more times.

So ends an annoying chapter of my life.  I would change carriers to get away, but no other carrier works out here.

Now, I get to play with all the features of a new phone.  I get to customize every little thing and put pictures of my dog on it to annoy other people with.

Motorola used to be a great company.  Maybe Google will bring some of the life back to them since they took over the mobile phone part, but I'm keeping my distance.

Tuesday, April 8, 2014

Kissing Goodbye to DynDns

For a long time now I've been using Dyn's free service DynDns.  For those of you that don't understand what I'm talking about, most homes have DSL provided by one of the big names or cable modems provided by some of the same big names.  I happen to have CenturyLink (used to be Qwest).  With these services, your IP address changes periodically so it's hard to have a name linked to an IP address when it changes every time the provider decides they want to.  At one time CenturyLink was changing my IP address a couple of times a day.

So there are a number of dynamic dns services out there that will update the various name servers on the internet when your IP address changes.  Doing something like this saves you the extra fee for a static IP and you can still get to your home machine by some name or other.  These services used to be free, but over time, they've started to charge for the service.  Dyn just did this.  Over the weekend I got an email telling me that my free account with them would be cancelled.

So, what to do?  I simply signed up with a different service and changed the bookmark in my browser.

Now, a lot of you folk can't do it that easily.  You may have distributed the name of your site or machine to friends and relatives and now you would have to let them know it changed.  Or, perhaps wait until they try it and give you a call to see what happened.

Don't misunderstand, I don't mind paying for value.  If they had said that they were going to charge $5 a year for this service I wouldn't have even thought about it, I would have just signed up and paid the five bucks.  They wanted $25 a year (discounted the first year), and frankly, that's too much for such a simple thing as sending an update to the name servers that your IP address has changed.  To be fair, they offer a number of other services and have a good reputation, but I don't need the other services.  Perhaps someday when I have a huge corporation to worry about, I might consider them again.  For now, my one little blog and one little computer will do just fine without them.

So, if you want to visit my home control and monitoring system, use this link <link>.  Strangly, it took me about six minutes to get it working and another ten to find the software to keep it updated through IP address changes.  That's about 1/10th the time it took me to set it up originally with DynDns.