« Dear Jerry - please don't sell Yahoo to Microsoft | Main | C3SR represents no one! »

A REXX bigots answer to office automation

Every now and then a situation presents itself where I can again prove myself to be a poor, but effective coder. This months electric bill was a whopping $675.00 USD for a large two bedroom condo here in the tropics. It's winter, and I run the air conditioner for my home office 24 hours a day. Why? It keeps two servers, a workstation, three notebooks, four displays, lights and a raid array from turning the room into an oven.

All of my lights have been converted to compact flourescent, hot water heaters have been turned down, lots of steps have already been taken in terms of lifestyle to reduce my energy footprint but yet that $675.00 bill has me wondering if there isn't more I can do in the office. So I start rummaging around in the junk box and pull out a Radio Shack X-10 Heavy Duty Appliance Module (220V), a X-10 Firecracker interface, and a Radio Shack Plug & Power wireless receiver.

The Firecracker is a small dongle that plugs into the serial port of a computer, it broadcasts a signal that will command a X-10 receiver (such as the radio base of the Plug and Power remote) to switch things on and off. I connect the firecracker to the RS-232 port on the back of my Cobalt Qube (running Debian Etch), plug the receiver into the 110V side of my rack, and the air conditioner into the 220V Module. I enter the command "BR A1 OFF" and the air conditioner switches off. Excellent!

The next problem was a little more complicated. How do I tell what the temperature is when the server is a MIPS based Cobalt Qube. The motherboard and CPU don't report temperature, there are no sensors, there is no local hardware monitoring at all in this little box. However, it does have a 200 GB Maxtor hard disk in it. After looking around, I found a utility called HDDTEMP that will return the drive temperature via. the S.M.A.R.T. interface. The command "hddtemp /dev/hda" returned "/dev/hda: Maxtor 6Y200P0: 45 C". If I turn off the air conditioner that number goes up, and when it turn it back on the number goes down. Excellent!

To make this all work, I wrote the following software. It polls the drive temperature every 20 minutes and determines if it should turn the air conditioner on or off based on the temperature reported by the servers hard disk. The sweet spot appears to be 47C (on the hard disk) which means the room stays at about 74F (interestingly) give or take 3F. The script outputs this to the terminal every 20 minutes.

--> Target temp: 47.
Temp: 50, powering on aircon.
Total time on: 20, time off: 40.
Sleeping 20 minutes...

Anyone with knowledge of thermodynamics, fuzzy logic and the like is already making a face and cringing. Even so, next month it'll be interesting to see if this makes a dent in my power bill. I'd love any suggestions on the software as I am sure that could be better as well, so here it is...

#!/usr/bin/rexx
/*
Simple server temp based aircon control program
*/

parse value "0 hda 0 48 /tmp/hddtemp.tmp" with ontime source current target workfile
parse value "0 20 a5" with offtime interval aircon

call evaluate
exit 0

evaluate:
do forever
say "--> Target temp:" target"."
parse value check_temp(source) with stemp
if stemp>=target then do
ontime=ontime+interval
say " Temp:" stemp", powering on aircon."
say " Total time on:" ontime", time off:" offtime"."
"/usr/bin/br" aircon "on"
end
else do
offtime=offtime+interval
say " Temp:" stemp", turning aircon off."
say " Total time on:" ontime", time off:" offtime"."
"/usr/bin/br" aircon "off"
end
say " Sleeping" interval "minutes..."
say
"/bin/sleep" interval"m"
end
return

check_temp:
parse arg device
"/usr/sbin/hddtemp /dev/"device ">"workfile
call stream workfile,"C","CLOSE"
parse value linein(workfile) with . . . current .
call stream workfile,"C","CLOSE"
return current

TrackBack

TrackBack URL for this entry:
http://www.tyde.net/cgi-bin/mt/mt-tb.cgi/36

Comments (2)

dido:

Rexx still alive and kicking?
wow.. :-)

Made a slight modification. I took apart a spare remote control for the aircon and soldered four wires to the pads that control power and temperature. These wires are connected to universal modules. X-10 commands that momentarily pulse the pads allow the temperature to be adjusted up and down and the power to be controlled by the remote. I noticed that the appliance module plugging, and pulling the plug on the aircon unit was generating a high voltage spike with every on off cycle. (which was irritating the power conditioner) Using the remote appears to be better, in that there is no abrupt power spike.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on February 25, 2008 5:06 AM.

The previous post in this blog was Dear Jerry - please don't sell Yahoo to Microsoft.

The next post in this blog is C3SR represents no one! .

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.
Powered by
Movable Type 3.31