// // control.xaj // Bearwood Cabin Control Program v1.2 // Copyright 2000 by Mark A. Day (mad@sawkill.com) // // IR Memories // AUX1 - Alarm Control final Number IR_AUX1_1 = 1; final Number IR_AUX1_2 = 2; final Number IR_AUX1_3 = 3; final Number IR_AUX1_4 = 4; final Number IR_AUX1_5 = 5; final Number IR_AUX1_6 = 6; final Number IR_AUX1_7 = 7; final Number IR_AUX1_8 = 8; final Number IR_AUX1_9 = 9; final Number IR_AUX1_0 = 10; final Number IR_AUX1_AB = 11; final Number IR_AUX1_Enter = 12; final Number IR_AUX1_ChDn = 13; // Motion Tracking Off final Number IR_AUX1_ChUp = 14; // Motion Tracking On final Number IR_AUX1_Last = 15; final Number IR_AUX1_Mute = 16; final Number IR_AUX1_VolDn = 17; // Speak Easy Messages Off final Number IR_AUX1_VolUp = 18; // Speak Easy Messages On final Number IR_AUX1_Disp = 19; final Number IR_AUX1_Play = 22; // ASCII Messages + final Number IR_AUX1_Stop = 23; // ASCII Messages - final Number IR_AUX1_Rew = 24; // System mode Away final Number IR_AUX1_FF = 25; // System mode Home final Number IR_AUX1_Record = 26; final Number IR_AUX1_Power = 27; // AUX 2 - X-10 Gateway final Number IR_AUX2_1 = 28; // Front Porch final Number IR_AUX2_2 = 29; // Rear Porch final Number IR_AUX2_3 = 30; // House Floods final Number IR_AUX2_4 = 31; // Garage Floods final Number IR_AUX2_5 = 32; // Basement Porch final Number IR_AUX2_6 = 33; // final Number IR_AUX2_7 = 34; // final Number IR_AUX2_8 = 35; // final Number IR_AUX2_9 = 36; // Bedroom Occupancy Force On/Off final Number IR_AUX2_0 = 37; // Main Room Lights final Number IR_AUX2_AB = 38; // final Number IR_AUX2_Enter = 39; // final Number IR_AUX2_ChDn = 40; // Dim * 2 final Number IR_AUX2_ChUp = 41; // Bright * 2 final Number IR_AUX2_Last = 42; // Bedroom Occupancy Enable final Number IR_AUX2_Mute = 43; // Outside Lights Off final Number IR_AUX2_VolDn = 44; // Dim * 4 final Number IR_AUX2_VolUp = 45; // Bright * 4 final Number IR_AUX2_Disp = 46; // Main+Bedroom Lights On final Number IR_AUX2_Record = 53; // Main+Bedroom Lights Off final Number IR_AUX2_Power = 54; // Outside Lights On // CBL - AV Control final Number IR_CBL_1 = 55; // Preset #01 final Number IR_CBL_2 = 56; // Preset #02 final Number IR_CBL_3 = 57; // Preset #03 final Number IR_CBL_4 = 58; // Preset #04 final Number IR_CBL_5 = 59; // Preset #05 final Number IR_CBL_6 = 60; // Preset #06 final Number IR_CBL_7 = 61; // Preset #07 final Number IR_CBL_8 = 62; // Preset #08 final Number IR_CBL_9 = 63; // Preset #09 final Number IR_CBL_0 = 64; // Preset #10 final Number IR_CBL_AB = 65; // DBS/Local Switch final Number IR_CBL_ChUp = 67; // DBS/TV Channel + final Number IR_CBL_ChDn = 68; // DBS/TV Channel - final Number IR_CBL_Power = 78; // DBS/TV Power final Number IR_CBL_Disp = 79; // DBS/TV Info // Television final Number IR_TV_1 = 81; final Number IR_TV_2 = 82; final Number IR_TV_3 = 83; final Number IR_TV_4 = 84; final Number IR_TV_5 = 85; final Number IR_TV_6 = 86; final Number IR_TV_7 = 87; final Number IR_TV_8 = 88; final Number IR_TV_9 = 89; final Number IR_TV_0 = 90; final Number IR_TV_AB = 91; final Number IR_TV_Enter = 92; final Number IR_TV_ChDn = 93; final Number IR_TV_ChUp = 94; final Number IR_TV_VolDn = 95; final Number IR_TV_VolUp = 96; final Number IR_TV_Last = 97; final Number IR_TV_Mute = 98; final Number IR_TV_Disp = 99; final Number IR_TV_Power = 100; // DBS Receiver final Number IR_DBS_1 = 101; final Number IR_DBS_2 = 102; final Number IR_DBS_3 = 103; final Number IR_DBS_4 = 104; final Number IR_DBS_5 = 105; final Number IR_DBS_6 = 106; final Number IR_DBS_7 = 107; final Number IR_DBS_8 = 108; final Number IR_DBS_9 = 109; final Number IR_DBS_0 = 110; final Number IR_DBS_AB = 111; final Number IR_DBS_Info = 115; final Number IR_DBS_Power = 128; // X-10 Addresses final X10Code BedRoomLight = "B/1"; final X10Code FrontPorchCmd = "E/1"; final X10Code RearPorchCmd = "E/2"; final X10Code HouseFloodCmd = "E/3"; final X10Code GarageFloodCmd = "E/4"; final X10Code ASCIICmd = "E/5"; final X10Code OccupancyCmd = "E/6"; final X10Code FireAlarm = "E/7"; final X10Code DrivewayMotion = "E/8"; final X10Code DrivewaySense = "E/9"; final X10Code OccupancySensor = "E/10"; final X10Code GarageMotionRear = "E/12"; final X10Code GarageLoopWindow = "E/13"; final X10Code GarageMotionFront = "E/14"; final X10Code GarageLoopDoor = "E/15"; final X10Code MainRoomLight = "E/16"; final X10Code SecurityLightsOff = "E/17"; final X10Code SecurityLightsOn = "E/18"; final X10Code MainLightsDim = "E/21"; final X10Code MainLightsBright = "E/22"; final X10Code RemoteChime = "F/1"; final X10Code PowerHorn = "F/2"; final X10Code RemotePowerHorn = "F/3"; final X10Code CrawlTemperature = "H/1"; final X10Code CrawlWater = "H/2"; final X10Code RacewayWater = "H/3"; final X10Code LaundryWater = "H/4"; final X10Code FrontPorchLight = "O/1"; final X10Code RearPorchLight = "O/2"; final X10Code HouseFloodLight = "O/3"; final X10Code GarageFloodLight = "O/4"; final X10Code BasementPorchLight = "O/5"; final X10Code OutsideLightsOnCmd = "O/19"; final X10Code OutsideLightsOffCmd = "O/20"; // Alarm Points final Point AlarmZone1 = new Point("1/0"); // Front Loop final Point AlarmZone2 = new Point("1/1"); // Rear Loop final Point AlarmZone3 = new Point("1/2"); // Front Motion final Point AlarmZone4 = new Point("1/3"); // Rear Motion final Point AlarmZone5 = new Point("1/4"); // Garage Motion final Point AlarmZone6 = new Point("1/5"); // Basement Motion final Point AlarmZone7 = new Point("1/6"); // Fire Alarm final Point AlarmZone8 = new Point("1/7"); // Window Loop final Point AlarmArm = new Point("1/8"); // Arm/Disarm // final Point AlarmMode = new Point("1/9"); // Install/Run // final Point AlarmBusy = new Point("1/10"); // final Point AlarmACPower = new Point("1/11"); // final Point AlarmBattery = new Point("1/12"); // Alarm States final Number ZoneAlert = 1; final Number ZoneClear = 2; final Number Run = 2; final Number Install = 3; final Number Busy = 4; final Number Armed = 1; final Number Disarmed = 2; final Number Home = 1; final Number Away = 2; final Number Good = 1; final Number Fault = 2; final Number Zone1 = 1; final Number Zone2 = 2; final Number Zone3 = 3; final Number Zone4 = 4; final Number Zone5 = 5; final Number Zone6 = 6; final Number Zone7 = 7; final Number Zone8 = 8; final Number Reset = 3; // AV States final Number AV_Mode_Off = 2; final Number AV_Mode_DBS = 3; final Number AV_Mode_Local = 4; // Occupancy States final Number OccupancyForceOff = 2; final Number OccupancyEnable = 3; final Number OccupancyForceOn = 4; // ASCII States final Number ASCII_Off = 2; final Number ASCII_Mute = 3; final Number ASCII_Voice = 4; final Number ASCII_Chime = 5; final Number ASCII_Both = 6; // ASCII Messages final Number Msg_System_Reset = 0; // System Reset final Number Msg_Zone1_Alert = 1; // Zone 01 - Front Wired Loop final Number Msg_Zone2_Alert = 2; // Zone 02 - Rear Wired Loop final Number Msg_Zone3_Alert = 3; // Zone 03 - Front Motion final Number Msg_Zone4_Alert = 4; // Zone 04 - Rear Motion final Number Msg_Zone5_Alert = 5; // Zone 05 - Garage Motion final Number Msg_Zone6_Alert = 6; // Zone 06 - Basement Motion final Number Msg_Zone7_Alert = 7; // Zone 07 - Fire Alarm final Number Msg_Zone8_Alert = 8; // Zone 08 - Window Loop final Number Msg_Zone1_Clear = 9; // Zone 01 - Cleared final Number Msg_Zone2_Clear = 10; // Zone 02 - Cleared final Number Msg_Zone3_Clear = 11; // Zone 03 - Cleared final Number Msg_Zone4_Clear = 12; // Zone 04 - Cleared final Number Msg_Zone5_Clear = 13; // Zone 05 - Cleared final Number Msg_Zone6_Clear = 14; // Zone 06 - Cleared final Number Msg_Zone7_Clear = 15; // Zone 07 - Cleared final Number Msg_Zone8_Clear = 16; // Zone 08 - Cleared final Number Msg_Console_Install = 17; // Alarm Console Install final Number Msg_Console_Run = 18; // Alarm Console Run final Number Msg_Console_Armed = 19; // Alarm Console Armed final Number Msg_Console_Disarmed = 20; // Alarm Console Disarmed final Number Msg_Console_Alarm = 21; // Alarm Console Alarm!!! final Number Msg_Garage_Rear = 22; // Zone 09 - Garage Rear Motion final Number Msg_Garage_Loop_Window = 23; // Zone 10 - Garage Window Loop final Number Msg_Garage_Front = 24; // Zone 11 - Garage Front Motion final Number Msg_Garage_Loop_Door = 25; // Zone 12 - Garage Door Loop final Number Msg_Driveway_Motion = 26; // Zone 14 - Driveway Motion final Number Msg_Driveway_Light = 27; // Zone 14 - Driveway Light Sense final Number Msg_Crawlspace_Temp = 28; // Zone 15 - Crawlspace Thermal final Number Msg_Crawlspace_Water = 29; // Zone 16 - Crawlspace Water final Number Msg_Raceway_Water = 30; // Zone 17 - Raceway Water final Number Msg_Laundry_Water = 31; // Zone 18 - Laundry Water final Number Msg_ASCII_Off = 40; // ASCII Messages Off final Number Msg_ASCII_Mute = 41; // ASCII Messages Mute final Number Msg_ASCII_Voice = 42; // ASCII Messages Voice final Number Msg_ASCII_Chime = 43; // ASCII Messages Chime final Number Msg_ASCII_Both = 44; // ASCII Messages Both final Number Msg_SpeakEasy_Off = 45; // SpeakEasy Messages Off final Number Msg_SpeakEasy_On = 46; // SpeakEasy Messages On final Number Msg_MotionTracking_Off = 47; // Motion Tracking Off final Number Msg_MotionTracking_On = 48; // Motion Tracking On // Timers Timer FrontLightsTimer; Timer RearLightsTimer; Timer HouseFloodsTimer; Timer GarageFloodsTimer; Timer OccupancyTimer; Timer SecurityLightsTimer; Timer AlarmArmedTimer; // Timeouts final Number SecurityLightTimeout = 300; final Number OccupancyTimeout = 240; final Number PorchLightsTimeout = 300; final Number FloodLightsTimeout = 300; final Number AlarmArmedTimeout = 3; // Event Times final Time AtDawn = new Time("R-0"); final Time AtDusk = new Time("S+0"); final Time BeforeDawn = new Time("R-30"); final Time AfterDusk = new Time("S+30"); final Time EarlyTime = new Time("23:00"); final Time LateTime = new Time("08:30"); // Variables Number HomeAway = new Number(Home); Number Zone1Status = new Number(ZoneClear); Number Zone2Status = new Number(ZoneClear); Number Zone3Status = new Number(ZoneClear); Number Zone4Status = new Number(ZoneClear); Number Zone5Status = new Number(ZoneClear); Number Zone6Status = new Number(ZoneClear); Number Zone7Status = new Number(ZoneClear); Number Zone8Status = new Number(ZoneClear); Number AlarmModeStatus = new Number(Run); Number AlarmArmStatus = new Number(Disarmed); Number AlarmTripped = new Number(False); Number AlarmLastZone = new Number(Unset); Number OccupancySense = new Number(OccupancyEnable); Number MotionTracking = new Number(Off); Number AV_State = new Number(AV_Mode_Off); Number Audio_State = new Number(Off); Number Scanner_State = new Number(Off); Number AsciiMessages = new Number(ASCII_Off); Number SpeakEasyMessages = new Number(Off); Number TempVar = new Number(Off); // Methods void TV_Power_On() { // Turn TV/DBS On cpuxa.xmitIR(IR_DBS_Power); cpuxa.xmitIR(IR_TV_Power); AV_State = AV_Mode_DBS; } void TV_Power_Off() { // Turn TV/DBS Off cpuxa.xmitIR(IR_TV_3); cpuxa.xmitIR(IR_TV_Enter); cpuxa.xmitIR(IR_TV_Power); cpuxa.xmitIR(IR_DBS_Power); AV_State = AV_Mode_Off; } void TV_Mode_DBS() { // Change to DBS mode cpuxa.xmitIR(IR_TV_3); cpuxa.xmitIR(IR_DBS_AB); cpuxa.xmitIR(IR_TV_Enter); AV_State = AV_Mode_DBS; } void TV_Mode_Local() { // Change to LOCAL mode cpuxa.xmitIR(IR_TV_2); cpuxa.xmitIR(IR_TV_9); cpuxa.xmitIR(IR_DBS_AB); cpuxa.xmitIR(IR_TV_Enter); AV_State = AV_Mode_Local; } void DBS_Memory_1() { // NBC cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_4); cpuxa.xmitIR(IR_DBS_1); } void DBS_Memory_2() { // CNN cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_0); cpuxa.xmitIR(IR_DBS_0); } void DBS_Memory_3() { // HNN cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_0); cpuxa.xmitIR(IR_DBS_2); } void DBS_Memory_4() { // PBS cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_4); cpuxa.xmitIR(IR_DBS_9); } void DBS_Memory_5() { // NASA cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_3); } void DBS_Memory_6() { // TLC cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_7); cpuxa.xmitIR(IR_DBS_8); } void DBS_Memory_7() { // DISC cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_8); cpuxa.xmitIR(IR_DBS_2); } void DBS_Memory_8() { // FOOD cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_0); } void DBS_Memory_9() { // TWC cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_1); cpuxa.xmitIR(IR_DBS_4); } void DBS_Memory_0() { // FOX cpuxa.xmitIR(IR_DBS_2); cpuxa.xmitIR(IR_DBS_4); cpuxa.xmitIR(IR_DBS_7); } void TV_Memory_1() { // ABC - WHSV cpuxa.xmitIR(IR_TV_3); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_2() { // CBS - WTVR cpuxa.xmitIR(IR_TV_6); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_3() { // ABC - WRIC cpuxa.xmitIR(IR_TV_8); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_4() { // NBC - WWBT cpuxa.xmitIR(IR_TV_1); cpuxa.xmitIR(IR_TV_2); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_5() { // PBS - WVPT cpuxa.xmitIR(IR_TV_1); cpuxa.xmitIR(IR_TV_9); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_6() { // NBC - WVIR cpuxa.xmitIR(IR_TV_2); cpuxa.xmitIR(IR_TV_9); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_7() { // FOX - WRLH cpuxa.xmitIR(IR_TV_3); cpuxa.xmitIR(IR_TV_5); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_8() { // PBS - WHTJ cpuxa.xmitIR(IR_TV_4); cpuxa.xmitIR(IR_TV_1); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_9() { // PAX - WADA cpuxa.xmitIR(IR_TV_5); cpuxa.xmitIR(IR_TV_5); cpuxa.xmitIR(IR_TV_Enter); } void TV_Memory_0() { // NBC - WVIR cpuxa.xmitIR(IR_TV_2); cpuxa.xmitIR(IR_TV_9); cpuxa.xmitIR(IR_TV_Enter); } void QuickOn(X10Code Address) { // Send Unit On cpuxa.x10QuickOn(Address); } void QuickOff(X10Code Address) { // Send Unit Off cpuxa.x10QuickOff(Address); } void BedRoomLightsOn() { // Bedroom Lights QuickOn(BedRoomLight); } void BedRoomLightsOff() { QuickOff(BedRoomLight); } void BedRoomLightsFlashOn() { QuickOn(BedRoomLight); QuickOff(BedRoomLight); } void BedRoomLightsFlashOff() { QuickOff(BedRoomLight); QuickOn(BedRoomLight); } void GarageFloodsOn() { // Flood Lights QuickOn(GarageFloodLight); } void GarageFloodsOff() { QuickOff(GarageFloodLight); } void HouseFloodsOn() { QuickOn(HouseFloodLight); } void HouseFloodsOff() { QuickOff(HouseFloodLight); } void FloodLightsOn() { cpuxa.xmitX10(GarageFloodLight); cpuxa.xmitX10(HouseFloodLight); cpuxa.xmitX10(OutsideLightsOnCmd); } void FloodLightsOff() { cpuxa.xmitX10(GarageFloodLight); cpuxa.xmitX10(HouseFloodLight); cpuxa.xmitX10(OutsideLightsOffCmd); } void MainRoomLightsOn() { // Main Room Lights QuickOn(MainRoomLight); } void MainRoomLightsOff() { QuickOff(MainRoomLight); } void MainRoomLightsFlashOn() { QuickOn(MainRoomLight); QuickOff(MainRoomLight); } void MainRoomLightsFlashOff() { QuickOff(MainRoomLight); QuickOn(MainRoomLight); } void MainRoomLightsDim(Number Repeat) { cpuxa.xmitX10Rpt(MainLightsDim, Repeat); } void MainRoomLightsBright(Number Repeat) { cpuxa.xmitX10Rpt(MainLightsBright, Repeat); } void FrontPorchLightsOn() { // Porch Lights QuickOn(FrontPorchLight); } void FrontPorchLightsOff() { QuickOff(FrontPorchLight); } void RearPorchLightsOn() { QuickOn(RearPorchLight); } void RearPorchLightsOff() { QuickOff(RearPorchLight); } void PorchLightsOn() { cpuxa.xmitX10(FrontPorchLight); cpuxa.xmitX10(RearPorchLight); cpuxa.xmitX10(OutsideLightsOnCmd); } void PorchLightsOff() { cpuxa.xmitX10(FrontPorchLight); cpuxa.xmitX10(RearPorchLight); cpuxa.xmitX10(OutsideLightsOffCmd); } void OutsideLightsOn() { // All Outside Lights cpuxa.xmitX10(GarageFloodLight); cpuxa.xmitX10(HouseFloodLight); cpuxa.xmitX10(FrontPorchLight); cpuxa.xmitX10(RearPorchLight); cpuxa.xmitX10(OutsideLightsOnCmd); } void OutsideLightsOff() { cpuxa.xmitX10(GarageFloodLight); cpuxa.xmitX10(HouseFloodLight); cpuxa.xmitX10(FrontPorchLight); cpuxa.xmitX10(RearPorchLight); cpuxa.xmitX10(OutsideLightsOffCmd); } void ChimeOnce() { // Alarm Zone Chimes QuickOn(RemoteChime); } void Chime1() { QuickOn(RemoteChime); AlarmTripped = False; } void Chime2() { QuickOn(RemoteChime); QuickOn(RemoteChime); AlarmTripped = False; } void Chime3() { QuickOn(RemoteChime); QuickOn(RemoteChime); QuickOn(RemoteChime); AlarmTripped = False; } void Chime4() { QuickOn(RemoteChime); QuickOn(RemoteChime); QuickOn(RemoteChime); QuickOn(RemoteChime); AlarmTripped = False; } void SetZone(Number Zone) { // Trap Alarm Zone AlarmLastZone = Zone; } void SendAscii(Number Msg) { // Send ASCII Message cpuxa.sendAscii(Msg); } void SoundPowerHorn() { // Water Alarm QuickOn(PowerHorn); QuickOff(PowerHorn); QuickOn(PowerHorn); QuickOff(PowerHorn); QuickOn(PowerHorn); QuickOff(PowerHorn); } // Main void run() { // AUX1 IR - Alarm/System Control if (cpuxa.receiveIR(IR_AUX1_ChUp)) MotionTracking = On; if (cpuxa.receiveIR(IR_AUX1_ChDn)) MotionTracking = Off; if (cpuxa.receiveIR(IR_AUX1_VolUp)) SpeakEasyMessages = On; if (cpuxa.receiveIR(IR_AUX1_VolDn)) SpeakEasyMessages = Off; if (cpuxa.receiveIR(IR_AUX1_FF)) HomeAway = Away; if (cpuxa.receiveIR(IR_AUX1_Rew)) HomeAway = Home; if (cpuxa.receiveIR(IR_AUX1_Play) && AsciiMessages < ASCII_Both) AsciiMessages += 1; if (cpuxa.receiveIR(IR_AUX1_Stop) && AsciiMessages > ASCII_Off) AsciiMessages -= 1; if (MotionTracking B== On && AsciiMessages > ASCII_Off) SendAscii(Msg_MotionTracking_On); if (MotionTracking B== Off && AsciiMessages > ASCII_Off) SendAscii(Msg_MotionTracking_Off); if (SpeakEasyMessages B== On && AsciiMessages > ASCII_Off) SendAscii(Msg_SpeakEasy_On); if (SpeakEasyMessages B== Off && AsciiMessages > ASCII_Off) SendAscii(Msg_SpeakEasy_Off); // AUX2 IR - X-10 Gateway if (cpuxa.receiveIR(IR_AUX2_1) && cpuxa.x10State(FrontPorchLight, IsOff)) FrontPorchLightsOn(); if (cpuxa.receiveIR(IR_AUX2_1) && cpuxa.x10State(FrontPorchLight, IsOn)) FrontPorchLightsOff(); if (cpuxa.receiveIR(IR_AUX2_2) && cpuxa.x10State(RearPorchLight, IsOff)) RearPorchLightsOn(); if (cpuxa.receiveIR(IR_AUX2_2) && cpuxa.x10State(RearPorchLight, IsOn)) RearPorchLightsOff(); if (cpuxa.receiveIR(IR_AUX2_3) && cpuxa.x10State(HouseFloodLight, IsOff)) HouseFloodsOn(); if (cpuxa.receiveIR(IR_AUX2_3) && cpuxa.x10State(HouseFloodLight, IsOn)) HouseFloodsOff(); if (cpuxa.receiveIR(IR_AUX2_4) && cpuxa.x10State(GarageFloodLight, IsOff)) GarageFloodsOn(); if (cpuxa.receiveIR(IR_AUX2_4) && cpuxa.x10State(GarageFloodLight, IsOn)) GarageFloodsOff(); if (cpuxa.receiveIR(IR_AUX2_9) && cpuxa.x10State(BedRoomLight, IsOff)) OccupancySense = OccupancyForceOn; if (cpuxa.receiveIR(IR_AUX2_9) && cpuxa.x10State(BedRoomLight, IsOn)) OccupancySense = OccupancyForceOff; if (cpuxa.receiveIR(IR_AUX2_Last)) OccupancySense = OccupancyEnable; if (cpuxa.receiveIR(IR_AUX2_0) && cpuxa.x10State(MainRoomLight, IsOff)) MainRoomLightsOn(); if (cpuxa.receiveIR(IR_AUX2_0) && cpuxa.x10State(MainRoomLight, IsOn)) MainRoomLightsOff(); if (cpuxa.receiveIR(IR_AUX2_ChDn)) MainRoomLightsDim(2); if (cpuxa.receiveIR(IR_AUX2_ChUp)) MainRoomLightsBright(2); if (cpuxa.receiveIR(IR_AUX2_VolDn)) MainRoomLightsDim(4); if (cpuxa.receiveIR(IR_AUX2_VolUp)) MainRoomLightsBright(4); if (cpuxa.receiveIR(IR_AUX2_Power)) OutsideLightsOn(); if (cpuxa.receiveIR(IR_AUX2_Mute)) OutsideLightsOff(); if (cpuxa.receiveIR(IR_AUX2_Disp)) { MainRoomLightsOn(); BedRoomLightsOn(); } if (cpuxa.receiveIR(IR_AUX2_Record)) { MainRoomLightsOff(); BedRoomLightsOff(); } // CBL IR - A/V Control if (cpuxa.receiveIR(IR_CBL_1) && AV_State == AV_Mode_DBS) DBS_Memory_1(); if (cpuxa.receiveIR(IR_CBL_2) && AV_State == AV_Mode_DBS) DBS_Memory_2(); if (cpuxa.receiveIR(IR_CBL_3) && AV_State == AV_Mode_DBS) DBS_Memory_3(); if (cpuxa.receiveIR(IR_CBL_4) && AV_State == AV_Mode_DBS) DBS_Memory_4(); if (cpuxa.receiveIR(IR_CBL_5) && AV_State == AV_Mode_DBS) DBS_Memory_5(); if (cpuxa.receiveIR(IR_CBL_6) && AV_State == AV_Mode_DBS) DBS_Memory_6(); if (cpuxa.receiveIR(IR_CBL_7) && AV_State == AV_Mode_DBS) DBS_Memory_7(); if (cpuxa.receiveIR(IR_CBL_8) && AV_State == AV_Mode_DBS) DBS_Memory_8(); if (cpuxa.receiveIR(IR_CBL_9) && AV_State == AV_Mode_DBS) DBS_Memory_9(); if (cpuxa.receiveIR(IR_CBL_0) && AV_State == AV_Mode_DBS) DBS_Memory_0(); if (cpuxa.receiveIR(IR_CBL_1) && AV_State == AV_Mode_Local) TV_Memory_1(); if (cpuxa.receiveIR(IR_CBL_2) && AV_State == AV_Mode_Local) TV_Memory_2(); if (cpuxa.receiveIR(IR_CBL_3) && AV_State == AV_Mode_Local) TV_Memory_3(); if (cpuxa.receiveIR(IR_CBL_4) && AV_State == AV_Mode_Local) TV_Memory_4(); if (cpuxa.receiveIR(IR_CBL_5) && AV_State == AV_Mode_Local) TV_Memory_5(); if (cpuxa.receiveIR(IR_CBL_6) && AV_State == AV_Mode_Local) TV_Memory_6(); if (cpuxa.receiveIR(IR_CBL_7) && AV_State == AV_Mode_Local) TV_Memory_7(); if (cpuxa.receiveIR(IR_CBL_8) && AV_State == AV_Mode_Local) TV_Memory_8(); if (cpuxa.receiveIR(IR_CBL_9) && AV_State == AV_Mode_Local) TV_Memory_9(); if (cpuxa.receiveIR(IR_CBL_0) && AV_State == AV_Mode_Local) TV_Memory_0(); if (cpuxa.receiveIR(IR_CBL_AB) && AV_State == AV_Mode_DBS) { TV_Mode_Local(); TempVar = On; } if (cpuxa.receiveIR(IR_CBL_AB) && AV_State == AV_Mode_Local && TempVar == Off) { TV_Mode_DBS(); } if (TempVar == On) TempVar = Off; if (cpuxa.receiveIR(IR_CBL_Power) && AV_State == AV_Mode_Off) { TV_Power_On(); TempVar = On; } if (cpuxa.receiveIR(IR_CBL_Power) && AV_State > AV_Mode_Off && TempVar == Off) { TV_Power_Off(); } if (TempVar == On) TempVar = Off; // if (cpuxa.receiveIR(IR_CBL_ChUp) && AV_State == AV_Mode_DBS) cpuxa.xmitIR(IR_DBS_ChUp); // if (cpuxa.receiveIR(IR_CBL_ChDn) && AV_State == AV_Mode_DBS) cpuxa.xmitIR(IR_DBS_ChDn); if (cpuxa.receiveIR(IR_CBL_ChUp) && AV_State == AV_Mode_Local) cpuxa.xmitIR(IR_TV_ChUp); if (cpuxa.receiveIR(IR_CBL_ChDn) && AV_State == AV_Mode_Local) cpuxa.xmitIR(IR_TV_ChDn); if (cpuxa.receiveIR(IR_CBL_Disp) && AV_State == AV_Mode_DBS) cpuxa.xmitIR(IR_DBS_Info); if (cpuxa.receiveIR(IR_CBL_Disp) && AV_State == AV_Mode_Local) cpuxa.xmitIR(IR_TV_Disp); // ASCII Messages if (cpuxa.x10State(ASCIICmd, OnCmdPair ) && AsciiMessages < ASCII_Both) AsciiMessages += 1; if (cpuxa.x10State(ASCIICmd, OffCmdPair) && AsciiMessages > ASCII_Off) AsciiMessages -= 1; if (AsciiMessages B== ASCII_Off) SendAscii(Msg_ASCII_Off); if (AsciiMessages B== ASCII_Mute) SendAscii(Msg_ASCII_Mute); if (AsciiMessages B== ASCII_Voice) SendAscii(Msg_ASCII_Voice); if (AsciiMessages B== ASCII_Chime) SendAscii(Msg_ASCII_Chime); if (AsciiMessages B== ASCII_Both) SendAscii(Msg_ASCII_Both); // X-10 Macros if (cpuxa.x10State(FrontPorchCmd, TurnsOn)) FrontPorchLightsOn(); if (cpuxa.x10State(FrontPorchCmd, TurnsOff)) FrontPorchLightsOff(); if (cpuxa.x10State(RearPorchCmd, TurnsOn)) RearPorchLightsOn(); if (cpuxa.x10State(RearPorchCmd, TurnsOff)) RearPorchLightsOff(); if (cpuxa.x10State(HouseFloodCmd, TurnsOn)) HouseFloodsOn(); if (cpuxa.x10State(HouseFloodCmd, TurnsOff)) HouseFloodsOff(); if (cpuxa.x10State(GarageFloodCmd, TurnsOn)) GarageFloodsOn(); if (cpuxa.x10State(GarageFloodCmd, TurnsOff)) GarageFloodsOff(); // Occupancy Sensing if (cpuxa.x10State(OccupancyCmd, OnCmdPair) && OccupancySense < OccupancyForceOn) { OccupancySense += 1; OccupancyTimer = 0; } if (cpuxa.x10State(OccupancyCmd, OffCmdPair) && OccupancySense > OccupancyForceOff) OccupancySense -= 1; if (cpuxa.x10State(OccupancySensor, OnCmdPair) && OccupancySense == OccupancyEnable) OccupancyTimer = 1; if (OccupancyTimer B== 1 && cpuxa.x10State(BedRoomLight, IsOff)) BedRoomLightsOn(); if (OccupancyTimer B== OccupancyTimeout && cpuxa.x10State(BedRoomLight, IsOn)) { BedRoomLightsOff(); OccupancyTimer = 0; } if (OccupancySense B== OccupancyForceOn || OccupancySense B== OccupancyForceOff) OccupancyTimer = 0; if (OccupancySense B== OccupancyEnable && cpuxa.x10State(BedRoomLight, IsOn)) OccupancyTimer = 1; if (OccupancySense B== OccupancyForceOn && cpuxa.x10State(BedRoomLight, IsOff)) BedRoomLightsOn(); if (OccupancySense B== OccupancyForceOff && cpuxa.x10State(BedRoomLight, IsOn)) BedRoomLightsOff(); // Garage if (cpuxa.x10State(GarageMotionRear, OnCmdPair) && AsciiMessages > ASCII_Off) SendAscii(Msg_Garage_Rear); if (cpuxa.x10State(GarageMotionFront, OnCmdPair) && AsciiMessages > ASCII_Off) SendAscii(Msg_Garage_Front); if (cpuxa.x10State(GarageLoopWindow, OnCmdPair) && AsciiMessages > ASCII_Off) SendAscii(Msg_Garage_Loop_Window); if (cpuxa.x10State(GarageLoopDoor, OnCmdPair) && AsciiMessages > ASCII_Off) SendAscii(Msg_Garage_Loop_Door); // Motion Tracking - Garage if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && cpuxa.x10State(GarageMotionFront, OnCmdPair) && cpuxa.x10State(GarageFloodLight, IsOff) && GarageFloodsTimer == 0) { GarageFloodsOn(); GarageFloodsTimer = 1; } if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && cpuxa.x10State(GarageMotionFront, OnCmdPair) && cpuxa.x10State(GarageFloodLight, IsOn) && GarageFloodsTimer > 0) { GarageFloodsTimer = 1; } if (GarageFloodsTimer B== FloodLightsTimeout) { GarageFloodsOff(); GarageFloodsTimer = 0; } // Driveway if (cpuxa.x10State(DrivewayMotion, OnCmdPair) && AsciiMessages > ASCII_Off) SendAscii(Msg_Driveway_Motion); if (cpuxa.x10State(DrivewaySense, OnCmdPair) && time > AfterDusk && AsciiMessages > ASCII_Off) { SendAscii(Msg_Driveway_Light); } if (cpuxa.x10State(DrivewaySense, OnCmdPair) && time < BeforeDawn && AsciiMessages > ASCII_Off) { SendAscii(Msg_Driveway_Light); } // Water if (cpuxa.x10State(CrawlTemperature, OnCmdPair)) { SoundPowerHorn(); } if (cpuxa.x10State(CrawlWater, OnCmdPair)) { SoundPowerHorn(); } if (cpuxa.x10State(RacewayWater, OnCmdPair)) { SoundPowerHorn(); } if (cpuxa.x10State(LaundryWater, OnCmdPair)) { SoundPowerHorn(); } if (cpuxa.x10State(CrawlTemperature, OnCmdPair) && AsciiMessages > ASCII_Off) { SendAscii(Msg_Crawlspace_Temp); } if (cpuxa.x10State(CrawlWater, OnCmdPair) && AsciiMessages > ASCII_Off) { SendAscii(Msg_Crawlspace_Water); } if (cpuxa.x10State(RacewayWater, OnCmdPair) && AsciiMessages > ASCII_Off) { SendAscii(Msg_Raceway_Water); } if (cpuxa.x10State(LaundryWater, OnCmdPair) && AsciiMessages > ASCII_Off) { SendAscii(Msg_Laundry_Water); } // Security Lighting if (cpuxa.recvX10(SecurityLightsOn) && SecurityLightsTimer == 0) SecurityLightsTimer = 1; if (cpuxa.recvX10(SecurityLightsOff) && SecurityLightsTimer == 0) SecurityLightsTimer = 1; if (cpuxa.x10State(MainRoomLight, OnCmdPair) && SecurityLightsTimer > 0) SecurityLightsTimer = 0; if (cpuxa.x10State(MainRoomLight, OffCmdPair) && SecurityLightsTimer > 0) { SecurityLightsTimer = 0; AlarmTripped = Reset; } if (cpuxa.x10State(MainRoomLight, OffCmdPair) && AlarmTripped == True) { AlarmTripped = Reset; } if (SecurityLightsTimer B== SecurityLightTimeout) { QuickOff(MainRoomLight); SecurityLightsTimer = 0; } // Alarm Console // if (AlarmMode.turnsOn()) { // AlarmModeStatus = Install; // } if (AlarmArm.turnsOn() && AlarmArmedTimer > 0) { AlarmArmedTimer = 1; } if (AlarmArm.turnsOn() && AlarmArmedTimer == 0) { AlarmArmedTimer = 1; } if (AlarmArmedTimer B== AlarmArmedTimeout && AlarmArm.isOn()) { AlarmArmedTimer = 0; AlarmArmStatus = Armed; } // if (AlarmMode.turnsOff()) { // AlarmModeStatus = Run; // } if (AlarmArm.turnsOff() && AlarmArmedTimer > 0) { AlarmArmedTimer = 1; } if (AlarmArm.turnsOff() && AlarmArmedTimer == 0) { AlarmArmedTimer = 1; } if (AlarmArmedTimer B== AlarmArmedTimeout && AlarmArm.isOff()) { AlarmArmedTimer = 0; AlarmArmStatus = Disarmed; } if (AlarmArmStatus B== Armed && AsciiMessages > ASCII_Off) SendAscii(Msg_Console_Armed); if (AlarmArmStatus B== Disarmed && AsciiMessages > ASCII_Off) SendAscii(Msg_Console_Disarmed); // Remember Tripped Zone if (AlarmZone1.turnsOn() && AlarmModeStatus == Run) Zone1Status = ZoneAlert; if (AlarmZone2.turnsOn() && AlarmModeStatus == Run) Zone2Status = ZoneAlert; if (AlarmZone3.turnsOn() && AlarmModeStatus == Run) Zone3Status = ZoneAlert; if (AlarmZone4.turnsOn() && AlarmModeStatus == Run) Zone4Status = ZoneAlert; if (AlarmZone5.turnsOn() && AlarmModeStatus == Run) Zone5Status = ZoneAlert; if (AlarmZone6.turnsOn() && AlarmModeStatus == Run) Zone6Status = ZoneAlert; if (AlarmZone7.turnsOn() && AlarmModeStatus == Run) Zone7Status = ZoneAlert; if (AlarmZone8.turnsOn() && AlarmModeStatus == Run) Zone8Status = ZoneAlert; // Send Zone Tripped Message if (Zone1Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone1_Alert); if (Zone2Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone2_Alert); if (Zone3Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone3_Alert); if (Zone4Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone4_Alert); if (Zone5Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone5_Alert); if (Zone6Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone6_Alert); if (Zone7Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone7_Alert); if (Zone8Status B== ZoneAlert && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone8_Alert); if (Zone1Status B== ZoneAlert) SetZone(1); // Set Last Tripped Zone for Chimes if (Zone2Status B== ZoneAlert) SetZone(2); if (Zone3Status B== ZoneAlert) SetZone(3); if (Zone4Status B== ZoneAlert) SetZone(4); if (Zone5Status B== ZoneAlert) SetZone(5); if (Zone6Status B== ZoneAlert) SetZone(6); if (Zone7Status B== ZoneAlert) SetZone(7); if (Zone8Status B== ZoneAlert) SetZone(8); if (Zone1Status B== ZoneAlert // Home Mode = Wired Loops + Motion Detectors || Zone2Status B== ZoneAlert || Zone3Status B== ZoneAlert || Zone4Status B== ZoneAlert || Zone5Status B== ZoneAlert || Zone6Status B== ZoneAlert || Zone7Status B== ZoneAlert || Zone8Status B== ZoneAlert && AlarmArmStatus == Armed && HomeAway == Home) { AlarmTripped = True; } if (Zone1Status B== ZoneAlert // Away Mode = Wired Loops + Garage Motion || Zone2Status B== ZoneAlert || Zone5Status B== ZoneAlert || Zone7Status B== ZoneAlert || Zone8Status B== ZoneAlert && AlarmArmStatus == Armed && HomeAway == Away) { AlarmTripped = True; } // Motion Tracking - Front if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && Zone3Status B== ZoneAlert && cpuxa.x10State(FrontPorchLight, IsOff) && FrontLightsTimer == 0) { FrontPorchLightsOn(); FrontLightsTimer = 1; } if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && Zone3Status B== ZoneAlert && cpuxa.x10State(FrontPorchLight, IsOn) && FrontLightsTimer > 0) { FrontLightsTimer = 1; } if (FrontLightsTimer B== PorchLightsTimeout) { FrontPorchLightsOff(); FrontLightsTimer = 0; } // Motion Tracking - Rear if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && Zone4Status B== ZoneAlert && cpuxa.x10State(RearPorchLight, IsOff) && RearLightsTimer == 0) { RearPorchLightsOn(); RearLightsTimer = 1; } if (time > AfterDusk || time < BeforeDawn && MotionTracking == On && Zone4Status B== ZoneAlert && cpuxa.x10State(RearPorchLight, IsOn) && RearLightsTimer > 0) { RearLightsTimer = 1; } if (RearLightsTimer B== PorchLightsTimeout) { RearPorchLightsOff(); RearLightsTimer = 0; } // Send Console Alarmed Message if (AlarmTripped B== True && AsciiMessages > ASCII_Off) SendAscii(Msg_Console_Alarm); // Chime Last Alarm Zone Tripped after "Lights Off" Received if (AlarmTripped == Reset && AlarmLastZone == Zone1) Chime1(); if (AlarmTripped == Reset && AlarmLastZone == Zone2) Chime2(); if (AlarmTripped == Reset && AlarmLastZone == Zone3) Chime3(); if (AlarmTripped == Reset && AlarmLastZone == Zone4) Chime4(); if (AlarmTripped == Reset && AlarmLastZone == Zone5 && cpuxa.x10State(BedRoomLight, IsOff)) { BedRoomLightsFlashOn(); } if (AlarmTripped == Reset && AlarmLastZone == Zone6 && cpuxa.x10State(BedRoomLight, IsOff)) { BedRoomLightsFlashOn(); Chime1(); } if (AlarmTripped == Reset && AlarmLastZone == Zone7 && cpuxa.x10State(BedRoomLight, IsOff)) { BedRoomLightsFlashOn(); Chime2(); } if (AlarmTripped == Reset && AlarmLastZone == Zone8 && cpuxa.x10State(BedRoomLight, IsOff)) { BedRoomLightsFlashOn(); Chime3(); } if (AlarmTripped == Reset && AlarmLastZone == Zone5 && cpuxa.x10State(BedRoomLight, IsOn)) { BedRoomLightsFlashOff(); } if (AlarmTripped == Reset && AlarmLastZone == Zone6 && cpuxa.x10State(BedRoomLight, IsOn)) { BedRoomLightsFlashOff(); Chime1(); } if (AlarmTripped == Reset && AlarmLastZone == Zone7 && cpuxa.x10State(BedRoomLight, IsOn)) { BedRoomLightsFlashOff(); Chime2(); } if (AlarmTripped == Reset && AlarmLastZone == Zone8 && cpuxa.x10State(BedRoomLight, IsOn)) { BedRoomLightsFlashOff(); Chime3(); } // Clear Tripped Zone if (AlarmZone1.turnsOff() && AlarmModeStatus == Run) Zone1Status = ZoneClear; if (AlarmZone2.turnsOff() && AlarmModeStatus == Run) Zone2Status = ZoneClear; if (AlarmZone3.turnsOff() && AlarmModeStatus == Run) Zone3Status = ZoneClear; if (AlarmZone4.turnsOff() && AlarmModeStatus == Run) Zone4Status = ZoneClear; if (AlarmZone5.turnsOff() && AlarmModeStatus == Run) Zone5Status = ZoneClear; if (AlarmZone6.turnsOff() && AlarmModeStatus == Run) Zone6Status = ZoneClear; if (AlarmZone7.turnsOff() && AlarmModeStatus == Run) Zone7Status = ZoneClear; if (AlarmZone8.turnsOff() && AlarmModeStatus == Run) Zone8Status = ZoneClear; // Send Zone Cleared Message if (Zone1Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone1_Clear); if (Zone2Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone2_Clear); if (Zone3Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone3_Clear); if (Zone4Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone4_Clear); if (Zone5Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone5_Clear); if (Zone6Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone6_Clear); if (Zone7Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone7_Clear); if (Zone8Status B== ZoneClear && AsciiMessages > ASCII_Off) SendAscii(Msg_Zone8_Clear); }