Tuesday, June 10, 2008

ZCell Controller - Day 3

I know it's been a while...

I finally had a chance to get back into things a little more. Last night I ripped out the code for my server and started over with it. I went with an asynchronous method instead on this version of it and it can also handle up to 30,000 clients - of course, I haven't tested with that many yet, and I likely won't ever, but hey, at least it's an option :)

I made some excellent progress. I have the client talking to the server and am able to see a list of all my zWave devices as well as turn them on/off. I'm on a 1x network with my cell phone, so the response time isn't as fast as I'd like - it varies from 1-3 seconds. The speed feels about the same as my normal zwave controller at least...

As far as future updates, here's what I've got planned:

- View a specific device and allow the level to be set (instead of just toggled on/off)
- Auto-update the client when a switch's level event is fired
- Change the server so it'll optionally only show Switches (instead of sensors, outlets, etc.)
- Pretty it up with icons
- Show useless details such as how long the light's been on, etc.

All in all, things are going well.

Friday, May 16, 2008

ZCell Controller - Day 2

I've started coding on my zwave cell phone "controller." I spent most of the day getting things setup. I decided to use Java as the driver for my cell phone application. The main reason is that the phone I have now happens to only run java apps, but the other reason is that Java will have the farthest reach should I ever change my cell phone or switch providers.

I downloaded Netbeans and started researching where to start. I found out rather quickly that Sun has a J2ME specifically for cell phones. I put together a quick Hello World app and uploaded it to my Helio Ocean just to make sure the Ocean would really let me program custom apps. I was in luck, it worked great!

I need to make sure this application screams. The bottle neck is going to be the communication with my home server so I've spent a lot of time playing around and trying to determine the fastest communication method.

My first test was to simply use good old fashioned sockets. I set up a mini server on my computer to listen for a connection and then I did a quick test app on the phone. It looked promising, but as I started hashing out the communications I found that though quick and simple, this way would ultimately have a somewhat large maintenance overhead because of all the string parsing I'd have to do.

To simplify the maintenace, I started looking for ways to easily serialize an object in .NET then de-serialize it in java. I knew this concept would work well at least on the server-side (since it was .NET) - it takes about 3 lines of code to serialize then 3 more lines to de-serialize back into an object. However, Java is another story all together. There's simply no easy way to get an XML string back into an object without writting many, many lines of code. Even with 3rd party libraries it takes major setup for each type of object just to make it happen...

So I stopped that line of thinking and moved on to the Web-service idea. Perhaps I could use SOAP to get my serialized object and use that to build my objects again in java. It only took a few minutes to find a 3rd party class that should have worked well. I was on my own about implementing it though as there was very little on the internet in terms of samples or documentation. After 2 or 3 hours I gave up trying to make it work. It seems something on my phone was preventing me from consuming a web-service. I'll have to dig into this more later...

I moved back to the idea of making my own protocol using sockets and by the end of the day was able to display a "hello world" on my phone (which was sent to it from my home's zwave server).

All in all I learned (or re-learned) a few things about java...

1) If java had a gender, it would be female (it's so picky and insists on doing things the hard way)
2) I was reminded of why I removed Java from my resume (I love the simply nature of .NET, and hate the crap you have to go through for Java to perform the simplest of tasks)
3) I was amazed at the quality (or lack of really) of the java samples and examples that exist on the internet. Compared to .NET, which abounds in great quality, java is hugely lacking.

In the end I had a lot of fun. I learned a lot, stretched my mind more than usually and found out some new tricks. I'm excited to see what I can do tomorrow. :)

I'm out -

Thursday, May 15, 2008

ZWave Fun - Day 1

I've got a few zwave projects I want to do around my home. The first one involves my doorbell and getting a notification about my visitor. The other involves turning my cell phone into a type of zwave controller.

The Doorbell Project
We are just finishing up our home theatre room in the basement. It's sound-proofed and tucked away in the far reaches of our house. I like my movies loud, so when the doorbell rings, chances are I'll not be able to hear it.... not that I care anyway, I'd rather people contact me via email... but The Wife cares. So this got me thinking about how I could do some smart home automation to solve the problem.

The solution I'd like would be to install a weather-proof IP camera outside above the door. When a visitor arrives, the camera would take a picture and either display it on my TV (as a live feed) or take a few frames and toss an SMS message with the picture of my visitor on my cell phone.

There are of course a few problems, I'll touch on the one that I know is going to be the breaker:

To my knowledge there's no such thing as a zwave doorbell. I'd have to figure out some other way to notify my server that the doorbell has been triggered. Since I have a wireless doorbell, my initial thought was to locate some sort of device that could intercept the frequency of my doorbell... it does seem like a lot of work but perhaps there's a simple solution that can already integrate with the computer?

Another thought might be to install a motion detector outside near the door and let that trigger the camera. This could work well since there are already plenty of proven motion detectors around. One down side to this might be false positives though (like say a car drives by, I wouldn't want that triggering my camera and spamming me for the fun of it...)

A final option would be to make my own doorbell. I'm sure I could put together a zwave switch outside that would trigger my computer to make a doorbell chime. Not sure how keen the wife would be on this idea though... :)

Cell Phone Controller
The other project is to convert my cell phone into a type of z-wave controller. This would involve having a server at home that would communicate with my cell phone and allow the phone to issue commands. Seems pretty straight forward. I'm most likely going to tackle this project first as it involves the least cost and the most coding right out of the box... and since I'm a coder, that's what counts :)

So with that said, over the next few days I'll be making posts about how this project is coming along.