private void OnHallwaySwitch(object sender, NexaEvent nexaEvent) { Log.Debug("Hallway switch"); if (nexaEvent.Value) { // Up position. // Cancel pending changes so we don't reapply away in case down and then up was pressed. if (mMode != null) { mMode.CancelPendingChanges(); } HomeScene(); } else { // Down position. if (mMode != null) { if (mMode.CurrentMode != mModeAway) { Speak(string.Format("Goodbye, activating away mode in {0} seconds", MODE_AWAY_TIMEOUT)); RunMacro("leaving"); mMode.QueueChange(mModeAway, MODE_AWAY_TIMEOUT); } else { Speak("Already away"); } } } }
private void OnDoorSensor(object sender, NexaEvent nexaEvent) { Log.Debug("Door sensor"); // On if (nexaEvent.Value) { if (mMode != null && mMode.CurrentMode == mModeAway) { if (!TimeHelper.IsDay) { mLampHallway.SwitchDevice(true); } if (mGalaxyS7 != null) { mGalaxyS7.CheckDevice(); // Trigger scan } } } }
private void OnSofaSwitchEvent(object sender, NexaEvent nexaEvent) { // Sofa table switches if (nexaEvent.Device == mSwitchSofa1) { Log.Debug("Sofa switch 1"); if (nexaEvent.Value) { if (mSofaSwitch != SofaSwitch.Button0On) { // 1st action ApplyCinemaLight(); } else { // 2nd action ApplyCinemaMisc(); } mSofaSwitch = SofaSwitch.Button0On; } else { if (mSofaSwitch != SofaSwitch.Button0Off) { // 1st action ApplyCinemaOffLight(); } else { // 2nd action ApplyCinemaOffMisc(); } mSofaSwitch = SofaSwitch.Button0Off; } } else if (nexaEvent.Device == mSwitchSofa2) { Log.Debug("Sofa switch 2"); if (nexaEvent.Value) { if (mSofaSwitch != SofaSwitch.Button1On) { // 1st action mReceiver.SetPower(true); mReceiver.SetScene(RECEIVER_SCENE_HTPC); } else { // 2nd action if (mProjector != null) { mProjector.PowerOn(); } } mSofaSwitch = SofaSwitch.Button1On; } else { mReceiver.SetPower(false); if (mProjector != null) { mProjector.PowerOff(); } mSofaSwitch = SofaSwitch.Button1Off; } } }