See http://www.smarthomepro.com/solution34.html