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

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

$
0
0
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 paint.net 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.

Viewing all articles
Browse latest Browse all 218

Trending Articles