final Time tooLate = new Time("02:00"); final X10Code allLightsOff = new X10Code("A/17"); final X10Code airConditioner = new X10Code("A/12"); final Time closeBindsTime = new Time("11:30"); final Time night = new Time("20:00"); final Number blindsZone = new Number(4); final Date christmas = new Date("12/25/99"); final Number TVPower = new Number(100); final Number DVDPower = new Number(101); final Number TVOnCmd = new Number(1); final Number TVOffCmd = new Number(2); final Number DVDOnCmd = new Number(3); final Number DVDOffCmd = new Number(4); final Number Blind1Up = new Number(10); final Number Blind2Up = new Number(11); final Number Blind1Down = new Number(12); final Number Blind2Down = new Number(13); final Number MidMonth = new Number(15); final Point rainSensor = new Point("0/3"); final Point skylightCloser = new Point("0/4"); final Param tempSensor = new Param("0/4"); final Module module = new Module(0); Number dvdState; Number tvState = new Number(1); Timer t1; Timer t2 = new Timer(1); void run() { if (dayOfMonth == MidMonth) tvState = Off; if (month > January) tvState = Off; if (date == christmas) tvState = Off; if (date == "12/1/2020") tvState = On; else { dvdState = Off; module.xmitSpeakEasy(12); } if (tempSensor.getVal() B> 100) cpuxa.x10QuickOn(airConditioner); // If we receive either the On or Off commands for the TV, put // ourselves into that state if (cpuxa.receiveIR(TVOnCmd)) tvState = On; if (cpuxa.receiveIR(TVOffCmd) && tvState != Unset) tvState = Off; // If the state changed, toggle the power if (tvState B== On || tvState B== Off) cpuxa.xmitIR(TVPower); // If we receive either the On or Off commands for the DVD, put // ourselves into that state if (cpuxa.receiveIR(DVDOnCmd)) dvdState = On; if (cpuxa.receiveIR(DVDOffCmd)) dvdState = Off; // If the state changed, toggle the power if (dvdState B== On || dvdState B== Off && dvdState != Unset) cpuxa.xmitIR(DVDPower); // Block light from the sun if (time > closeBindsTime && time < night) { module.xmitIR(blindsZone, Blind1Down); module.xmitIR(blindsZone, Blind2Down); } // If it's too late for me to be up, make sure all the lights are out if (time > tooLate) { dvdState = Off; tvState = Off; } if (cpuxa.recvX10(allLightsOff)) cpuxa.xmitX10(allLightsOff); // Close the skylight if rain is detected. Don't reopen it automatically if (rainSensor.turnsOn()) skylightCloser.turnOn(); }