![]() | ||||||||||||
Welcome to myHouse | ||||||||||||
to Main | ||||||||||||
Mac | IIgs | |||||||||||
In 1983 I began writing a menu driven house manager program (Master Control) in Applesoft Basic (about 6 mos. after purchasing an Apple II plus). Actually, I didn't set out to write a house manager, I was just 'testing' various features of the machine. Once I discovered the game port, I was hooked. I could read from the three 'pushbutton' inputs and control four relays from the 'annunciator' outputs. The machine now had the ability to reach out beyond itself: it could detect a change in its environment and respond. WOW! It didn't take long to start filling those slots; extending the Apple's reach. In 1987 I re-wrote Master Control in Pascal as a IIgs Desktop application and renamed it myHouse. I've managed to fill every slot and plug something into every port (and then some) on my IIgs. The IIgs has run all day, every day since then without a break (except for maintenance). In 1999 I bought a Blue & White G3 PowerMac. Eventually, some functions will be migrated to the Mac. So far, the Mac has taken over the online duties that the IIgs used to perform, but for the forseeable future, the IIgs will still be in charge of the house. Time Marches On... Towards the end of 2004, the IIgs began crashing once or twice a week and no amount of troubleshooting could pinpoint the problem. So, in January 2005, I began rewriting myHouse in C (using Apple's Xcode) to run on the Mac. After all, by 2005 the Mac was 6 years old; surely it qualified as old technology. I finally packed up the IIgs in April 2005, after 17 1/2 years of faithful service. Hopefully, I'll get the same type of mileage from the Mac. myHouse/IIgs was written in Pascal, so coding myHouse/Mac in C was similar, yet totally different. IIgs applications live in a singletasking environment, while Mac applications live in a multitasking environment. This meant that some features of myHouse/IIgs, such as backup scheduling and announcing the time were not needed in myHouse/Mac. Since the IIgs was a single tasker, myHouse was designed to take advantage of all the screen real estate. On the Mac, many programs may be running and using the screen, so the design philosophy for myHouse was to use as little screen real estate as possible; at least for the main desktop screen. The second screen is channel 92 on the 52" TV downstairs, and that screen is just for displaying myHouse info. On the main screen, internal temperatures and computer uptime are displayed on the bottom left side of the screen, while the external temperature and sunrise / sunset times are displayed on the botton right. Informational "flags" are displayed down the left side of the screen. Before I could start writing myHouse/Mac, I had to find the necessary hardware to interface the Mac to the world. Since the Mac is slot poor compared to the IIgs, I decided my best bet would be USB. First up, I needed a USB to serial port adapter so I connect my CP290. A Keyspan 2 port adapter fit the bill nicely. Next I needed an analog to digital converter to measure stuff, like temperatures. I found a serial A/D converter at B&B Electronics, which was perfect: I had a spare port on the USB to serial port adapter (never did like having an unused port) and being a serial device, it didn't need a driver. (B&B also makes a USB version, but it is more expensive and requires a driver, and of course, they only have a windows version.) The final piece of hardware I needed was an Input/Output module, so I could read incoming voltages from "on/off" switches and switch output voltages to control things like relays. The ActiveWire USB board was what I wanted, but it didn't have a OS X driver available, just an OS 8-9 one. Luckily, an independent developer wrote one and, even luckier, I bought a copy before his website disappeared. Note: the driver has reappeared as open source here. It now requires OS 10.4 or higher. Combining Technologies By the beginning of 2006, myHouse was maturing nicely. The next step was to start coloring outside the lines. I added an Applescript interface to myHouse so that a script could extract house info. I wrote a script, myHouseWeb, that would extract info from myHouse and upload it to my website (along with an optional webcam snapshot ). This allows me to check on the house when I'm away. Better yet, I can start and stop this script via email. That way, the script doesn't have to be running all the time, I can start it up from anywhere, view the status page at my leisure and stop the script when done. To see the myHouse status page, go back to the main page and click on the gears. Another fun and convenient combination is a little project I call BedTunes. It makes use of ActiveWire, X-10, myHouse, iTunes, AirTunes/Airport Express, a wireless network, Applescript and the stereo system in the living room. This is how it works: I'm laying in bed and want to hear some music. I pick up the wireless X-10 controller on the headboard and press the on button for the "BedTunes device". That device is really an X-10 Universal module that closes a relay when it receives an on signal. The relay passes voltage to a channel on the ActiveWire board. When myHouse see the BefTunes channel is on, it displays an info flag on the desktop and launches an Applescript. The script launches iTunes, sets a low volume level, tells iTunes to play the BedTunes playlist (I set up this playlist ahead of time) and sends a command to the CP290 to turn on the stereo (speakers in the bedroom are connected to the stereo). iTunes is set up to stream music via Airtunes to the Airport Express connected to the stereo. And, when I've had enough music, I just press the off button for Bedtunes on the wireless X-10 controller. Using the same mechanism, iTunes quits and the stereo shuts off. Spinoffs One good thing about rewriting myHouse for the Mac has been spinoff freeware. I needed to be able to communicate with the CP290 from Applescript, but there were no serial port Scripting Additions for OS X; so I wrote one. I also wanted full blown applications for the CP290, one for using it as a controller and another to manage schedules of Events. I had already written the core code for myHouse to communicate with the CP290, so I already had a head start on xCommander and xMaster. All three of these programs can be found on my Mac Software page; enjoy. Further on Down the Road... In June 2007, I purchased a used G4 (Gigabit Ethernet) tower to replace the old Blue and White. I hadn't intended to buy a new machine, I originally just wanted to upgrade the cpu in the B & W. For the price of an upgrade, I was able to buy the G4 used. Not only did I get more cpu power, but other goodies like bootable (and more stable) firewire, faster ATA bus and AGP graphics. I moved the Blue and White to the recreation room downstairs and added a USB wireless adapter, so it could join the network. I then started a new project to turn myHouse into a client / server application. The current version of myHouse (with some modifications and networking code) became the server side, running on the G4 connected to the house. The client software (myHouse Remote) has the same interface and functionality as myHouse. It can be installed on any Mac and only needs a wifi connection; the server side does the heavy lifting. The B & W was used as the testbed for myHouse Remote. The real reason I wrote the client software was the anticipation of buying a new Macbook Pro in the summer of 2009. The G4 will serve as the automation and music server for the house, the B & W will sit in a closet waiting as a backup should the G4 fail, and the Macbook Pro will become my main machine. There was another spinoff from all this network programming. I soon realized that I would want remote access to the CP290 attached to the G4. I wrote xStation, a sever side application that could receive commands over a network and pass them on to a locally attached CP290. I then modified xCommander to be able to run as the client. So, now anyone who has a CP290 attached to a networked Mac can have access to that CP290 from any Mac on the network.
| ||||