public Logic(DeviceManager deviceManager, ServiceManager serviceManager) { mDeviceManager = deviceManager; mServiceManager = serviceManager; mWake = GetService <WakeOnLanService>(); mMode = GetService <ModeService>(); if (mMode != null) { mMode.OnModeChange += OnModeChange; } mScene = GetService <SceneService>(); if (mScene != null) { mScene.OnSceneEvent += OnSceneEvent; } mEvents = GetService <EventService>(); if (mEvents != null) { mEvents.OnEvent += OnExternalEvent; } // Livingroom mCurtainLivingroom = (CurtainDevice)deviceManager.GetDevice("curtain_livingroom"); mProjector = (EpsonDevice)deviceManager.GetDevice("projector"); mReceiver = (YamahaDevice)deviceManager.GetDevice("receiver"); mLampLivingroom = (NexaLampDevice)deviceManager.GetDevice("lamp_livingroom"); mLampTable = (NexaLampDevice)deviceManager.GetDevice("lamp_table"); mLampWindow = (NexaLampDevice)deviceManager.GetDevice("lamp_window"); mLampDarthLeft = (ArduinoLamps.LampDevice)deviceManager.GetDevice("lamp_darth_left"); mLampDarthRight = (ArduinoLamps.LampDevice)deviceManager.GetDevice("lamp_darth_right"); mMotionLivingroom = (NexaSensorDevice)deviceManager.GetDevice("motion_livingroom"); mSwitchSofa1 = (NexaSensorDevice)deviceManager.GetDevice("switch_sofa1"); mSwitchSofa2 = (NexaSensorDevice)deviceManager.GetDevice("switch_sofa2"); if (mSwitchSofa1 != null) { mSwitchSofa1.OnDeviceEvent += OnSofaSwitchEvent; } if (mSwitchSofa2 != null) { mSwitchSofa2.OnDeviceEvent += OnSofaSwitchEvent; } mDesktop = (ComputerProxyDevice)deviceManager.GetDevice("desktop"); // Bedroom mCurtainBedroom = (CurtainDevice)deviceManager.GetDevice("curtain_bedroom"); mLampBedroom = (NexaLampDevice)deviceManager.GetDevice("lamp_bedroom"); mLampBed = (NexaLampDevice)deviceManager.GetDevice("lamp_bed"); // Hallway mLampHallway = (NexaLampDevice)deviceManager.GetDevice("lamp_hallway"); mMotionDoor = (NexaSensorDevice)deviceManager.GetDevice("motion_door"); if (mMotionDoor != null) { mMotionDoor.OnDeviceEvent += OnDoorSensor; } mSwitchHallway = (NexaSensorDevice)deviceManager.GetDevice("switch_hallway"); if (mSwitchHallway != null) { mSwitchHallway.OnDeviceEvent += OnHallwaySwitch; } // Presence devices mGalaxyS7 = (BluetoothDevice)deviceManager.GetDevice("presence_s7"); if (mGalaxyS7 != null) { mGalaxyS7.OnDeviceEvent += OnBluetoothEvent; } mSpeech = GetService <SpeechService>(); if (mSpeech != null) { var commands = new List <DeviceBase.VoiceCommand>(); commands.Add(new DeviceBase.VoiceCommand("activate night mode", () => { MacroNight(); })); mSpeech.LoadCommands(commands); } Speak("System ready"); }