Saturday, March 8, 2014

Presence Detection Using Mobile Phone for Lowes' Iris System

One of the pitfalls of using Iris by Lowes is a poor mobile app and the lack of ability to be able to use my mobile phone to detect presence in the house.  Sure, Lowes offers a keyfob to do that but that thing is huge and hideous and looks like it came straight out of the 1980s.  Also, there is really no reason why in the year 2014 we are not able to detect user's presence using mobile phone.

Since I could not find any solutions online I decided to create my own.

My solution consists of the following:

  • Java application that pings my phone (and my wives) every second to see if phones are present on our WiFi. Any number of phones can be added through the settings file.
  • Once both phones are abent for X amount of time, the application will login to Iris and set home mode to Away, triggering any magic rules associated with it.
  • Once one of the phones arrives and connects to WiFi (in my case, it happens before  I get out of the car and open my garage entry door), the application will set the home mode back to Home, again, triggering any magic rules associated with it.

Since I was creating the app anyways, I decided what the heck, why not include some additional functionality.  So the same application also contains a web server that accepts commands so that you can turn alarm on/off, set home modes, and do some other things (I'll add functionality as time goes on).

On my TODO list is the following:

  • Replicate all native app functionality
  • Create a mobile web app with a nice user interface using one of the Mobile apps frameworks such as Jquery Mobile.
  • Interface with iCloud to get phone location using GPS
  • Create a native app (this one may be wishful thinking as I am not an iOS developer)
Let me know if you are using this app and how it's working for you.

Download it here: IrisTools1.0
Access docs here: docs1.0

NOTE: Make sure you edit the iristools.dat file (must be placed in the same directory as IrisTools.jar) and provide your Iris login credentials as well as comma separated list of your mobile devices. 

To run the jar use the following (make sure you have Java Runtime Environment installed): 
java -jar IrisTools.jar

Basic usage of the built-in web server:

Set mode to away: http://localhost:8080?command=setProfileAway
Set alarm to on: http://localhost:8080?command=setAlarmOn

I also included a simple alarm.htm file that you can open and use to control profile and alarm modes.  I plan on making a full featured web frontend at some point.

For full list, use the docs link above and click on the IrisApi class.

At this point, consider this a beta software and I take no responsibility for any damage it may do (although I am running it on my Mac with no issues).  This application does not transmit any of your information to any server other than Iris servers - you can verify this by using a web traffic analyzer of your choice.

I would like to get some feedback from someone who is running this on Windows or Linux.

Tuesday, March 4, 2014

Integrating Spring with IceFaces

Since I spent hours and hours trying to find information on various forums on how to accomplish this when I first started using Spring framework and subsequently, IceFaces and since I've been using both for a couple of years now, I figured I'll create a sample project and hopefully make someone else's life just a little bit easier.

At the link below you can download a sample project that integrates Spring and IceFaces in Java.  It uses Maven so you'll need to get that installed.

Few things:
  • Download Maven here (I use 2.x, so using 3.x may require a couple of changes to the pom).
  • In applicationContext.xml, you'll need to reference a valid data source - you can create one in WebLogic and use a JNDI lookup or install a mySQL and use a local data source.  I provided examples of both.
  • I use WebLogic, but Tomcat should work as well as the application server.
  • To compile, do mvn clean install
  • To open the application, navigate to http://localhost:7001/example, if you are using WebLogic, or http://localhost:8080/example, if you are using Tomcat (port may be different in your configuration).
Hope this helps someone.  Let me know in the comments if it does or if there any problems.  Due to my workload and a new baby I won't have time to troubleshoot with you but I'll try to help if it's something simple.


Tuesday, February 18, 2014

Lowes Iris Security/Home Automation

I've been using X10 to automate a few lights, but recently some of my modules started to fail and being that it is an older technology I decided to upgrade.  My criteria for the new setup was that it has to be reliable, simple to use and have highly available and affordable hardware.  The two different products i looked at were Vera Micasa Verde and Lowes Iris.

After some research and deliberation I decided to go with Iris due to the cheaper initial setup and being able to pick up additional sensors at my local Lowes store.  Another reason is it is my hope that since Iris is backed by a major retailer it will be continued to be developed and improved.

I started with picking up the Safe and Secure bundle consisting of the Hub, Keypad, 2 Door Sensors, and a Motion Sensor for $179 (picked mine up on Black Friday sale for $149).  I wanted to start with an alarm system as I've been wanting to install one for a while and wanted to see if Iris would satisfy my needs before committing my budget to the home automation setup.

Lowes states that it will take about an hour to hook everything up.  This was a fairly accurate estimate as it took me about 45 minutes to set everything up.  

I also picked up a smart plug and a smart button to replace my existing X10 module to control bedroom lights.

First thoughts - I was very impressed.  Everything worked a lot better than my old X10 setup. Lights were turning on and off at the press of the button with very minimal delay (there were a few exceptions where it took a second or so for lights to turn on or off).

The Good:
  • Easy setup
  • Fast response time
  • Reliable
The Bad:
  • $10 monthly fee, which I think is pretty much required as basic setup has almost no features
  • Limited magic rules (more on those later)
The Ugly:
  • iPhone app (more on it later)
  • Notification speed (more on it later)
After I committed to keeping the system I picked up a few more devices:
  • Thermostat
  • Siren
  • Multiple Dimmers
  • Multiple Light Switches
  • Multiple Contact Sensors
  • Smart Button
  • Smart Plug
  • Keyfobs
  • CO/Smoke detector
  • Lock
  • Range extender (required after you reach more than 15-16 devices to prevent disconnection)
Everything (for the most part) paired and connected without a hitch.

My current setup is as follows:
  • Contact sensor on every entry door
  • Contact sensors on the garage doors
  • Dimmers on the first floor
  • Switches in a couple of rooms
  • Smart Plug/Smart Button combination for a two separate lights
  • Lock on the front door
  • Siren on the second floor
  • Keyfobs for home/away modes
  • CO/Smoke detector on the first floor
I have a lot of rules setup as well:
  • When alarm is triggered all lights turn on
  • When certain contact sensors are opened (front door, for example), turn lights around the sensor on
  • When my wife and I leave/get home, turn on/off the alarm and adjust thermostat
  • When I set alarm for the night, turn off certain lights and turn bedroom lights on
  • Turn outside lights on/off from sunset to sunrise
  • And there are some other ones as well...
Here is what I like about the Iris system:

I like the fact that I can control groups of lights when sensors trigger.  Keyfobs do a very good job in controlling home mode - by the time I park the car in the garage and get out of the car the alarm has already been shut off.    This makes my life a lot easier.  I also like that the light switches work reliably (especially compared to my X10 setup).  Siren is nice and loud.  All hardware looks very good and sensors are nice and small and blend in very well.

Here is what I do not like about the Iris system:

Magic rules are limited.  There is no reason why I can only select from a predetermined set of values for time I want to keep a device on (1,5,10 minutes, for example).  This should simply be an edit box where I can type my own value in.  Notification for the alarm trigger is horrible.  Sometimes it takes up to 15 minutes for me to receive a call/text/email notification when alarm is triggered.  This should take just a few seconds!  The iPhone app is slow and includes options which I do not have (grayed out but showing - Camera, Power Meter, etc).  

Overall, the system has been good and other than some issues back in January it's been pretty stable.  I'm currently working to replace the keyfobs with a software solution to detect presence based on my mobile phone.  Stay tuned for next post.

Monday, October 29, 2012

X10 Home Automation with Raspberry Pi

PLEASE NOTE THAT THIS TUTORIAL INCLUDING ALL REFERENCED FILES HAVE BEEN MOVED TO THE URL BELOW:

http://80degreeswest.com/apps/x10

------------------------------------------------------------

I have a confession to make.

Ever since I ordered my Raspberry Pi and finally received it in the mail I've been obsessed with it.  Probably not in a healthy way.  My wife calls herself a 'Pi widow'.  

I get more and more amazed every day at what this little box can do.

First, I put RaspBMC on it and set it up with my Network Storage to stream my entire movie and music library to my TV.  That worked great, but I since decided to go with Roku box (which is great) to free up the Pi box for other projects.

And this is where this post comes in as the current project was to setup home automation using Raspberry Pi.

Please note, that you should have some basic Linux experience or ability to Google for how to do stuff in Linux.  I'm not a Linux expert by any means so I cannot provide any expertise on how to troubleshoot anything if you run into issues.

Here is what you will need:
  • Raspberry Pi
  • SD card (I used 4 GB SanDisk Ultra II 15MB/s)
  • CM19A X10 controller (eBay, Amazon)
  • TM751 X10 Module (Get it here)
  • Any other X10 modules you want to use
  • Network cable
  • USB hub with Micro USB cable (or a dedicated Micro USB power supply - 5V)
  • HDMI cable
  • TV or Monitor with HDMI input
  • USB Mouse
  • USB Keyboard
Software I used:
Step 1: Install Linux on the Raspberry Pi:
Step 2: Install Apache web server:
  • sudo apt-get install apache2
  • Configure your router to assign a static IP address to your Raspberry Pi
Step 3: Install Java Runtime Environment:
  • sudo apt-get clean
  • sudo apt-get update
  • sudo apt-get install openjdk-6-jre
Step 4: Install Libusb:
  • sudo apt-get install libusb-1.0-0-dev
Step 5: Install Mochad:
  • wget http://sourceforge.net/projects/mochad/files/mochad-0.1.15.tar.gz
  • tar xf mochad-0.1.15.tar.gz
  • cd mochad-0.1.15
  • ./configure
  • make
  • sudo make install
Step 6: Install X10 Java Server:
  • Download it from here
  • Extract X10.class and put it in your /home/pi directory
  • Download the startup script here
  • Extract x10 and put it in your /etc/init.d directory
  • Run this command to make script executable: sudo chmod 755 /etc/init.d/x10
  • Run this command to launch server on Linux boot: sudo update-rc.d x10 defaults
Step 7: Install X10 Web Client:
  • Download the zip here
  • Extract it to X10 folder and copy the whole folder to the apache web directory /var/www
  • Edit index.htm file to modify your devices
  • In index.htm, update mochadServer and controllerServer ip address (replace current IP with your Pi's IP address.
After all the steps are done, unplug your mouse and plug in the CM19A X10 Controller (or use a USB hub to have it all plugged in).  Restart your Pi.  Set your TM751 on house code A, open your web client and try it out by going to http://192.168.1.10/X10 (replace the IP address with the one of your Pi).