Translate

Friday, October 14, 2011

Motorcyles, home automation and Linix

Ok so here is a weird crossover between things I regularly spout off about.  A friend of mine has recently become a motorcycle owner and as such is facing some of the unique problems associated therein.   Like, how do you get the garage door open / closed from the bike.  (I personally have an opener permanently stationed in a saddle bag)

After a conversation with my friend and a little thought here is the start of a simple solution I came up with while waiting for computers to do their job this afternoon. 

Assume the following - you have x10 or similar home automation system.  You own a smart phone.  You have a home wifi network. 

The solution looks like this:

  • Add an x10 switch for the garage door.
  • On your network - assign a fixed IP to your phone. 
  • On your linux server - use cron to run a script that pings for the address.  When you get home and your phone connects to your network the script gets a ping response from your phone - it does an http put or get to your web based home control server to open the door (or just sends the appropriate heyu command if your linux box is also the automation server).
The simple beginings:

Cron entries - the first runs the script every minute for an hour starting at 5pm.  At 6pm the second deletes the semaphore file created when the script opens the door (so it only opens the door once) to reset for the next day.

* 17 * * 1-5 /home/mydir/garage.sh 2>&1 1>/dev/null
0 18 * * 1-5 rm -f /home/mydir/garagedoor.txt 2>&1 1>/dev/null

The script - checks for the existence of the semaphore file.  If it exists it exits, otherwise it sends a single ping and opens the door if there is a response.  If it opens the door it creates the semaphore.

if [ ! -f /home/mydir/garagedoor.txt ]
then
     if ping -c1 -q
          then wget #or heyu command...
          touch
/home/mydir/garagedoor.txt
     fi
fi


That's it.  Of course you could take this as far as you want but this would at least wait for you to get home from work and open the door as a start.

No comments: