public void Apply() { var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.KitchenHSREL5, new I2CSlaveAddress(58)); var hspe8 = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.KitchenHSPE8, new I2CSlaveAddress(39)); var input0 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0); var input1 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1); var input2 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2); var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>(); const int SensorPin = 11; var room = _areaService.CreateArea(Room.Kitchen); _sensorFactory.RegisterWindow(room, Kitchen.Window, w => w.WithCenterCasement(input0.GetInput(6), input0.GetInput(7))); _sensorFactory.RegisterTemperatureSensor(room, Kitchen.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)); _sensorFactory.RegisterHumiditySensor(room, Kitchen.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)); _sensorFactory.RegisterMotionDetector(room, Kitchen.MotionDetector, input1.GetInput(8)); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState()); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState()); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState()); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState()); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState()); _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState()); _actuatorFactory.RegisterSocket(room, Kitchen.SocketWall, hsrel5.GetOutput(2)); _actuatorFactory.RegisterRollerShutter(room, Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3)); _sensorFactory.RegisterButton(room, Kitchen.ButtonKitchenette, input1.GetInput(11)); _sensorFactory.RegisterButton(room, Kitchen.ButtonPassage, input1.GetInput(9)); _sensorFactory.RegisterRollerShutterButtons(room, Kitchen.RollerShutterButtonUp, input2.GetInput(15), Kitchen.RollerShutterButtonDown, input2.GetInput(14)); room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonKitchenette)); room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonPassage)); _automationFactory.RegisterRollerShutterAutomation(room, Kitchen.RollerShutterAutomation) .WithRollerShutters(room.GetRollerShutter(Kitchen.RollerShutter)); room.GetRollerShutter(Kitchen.RollerShutter).ConnectWith( room.GetButton(Kitchen.RollerShutterButtonUp), room.GetButton(Kitchen.RollerShutterButtonDown)); _actuatorFactory.RegisterLogicalActuator(room, Kitchen.CombinedAutomaticLights) .WithActuator(room.GetLamp(Kitchen.LightCeilingWall)) .WithActuator(room.GetLamp(Kitchen.LightCeilingDoor)) .WithActuator(room.GetLamp(Kitchen.LightCeilingWindow)); _automationFactory.RegisterTurnOnAndOffAutomation(room, Kitchen.CombinedAutomaticLightsAutomation) .WithTrigger(room.GetMotionDetector(Kitchen.MotionDetector)) .WithTarget(room.GetActuator(Kitchen.CombinedAutomaticLights)) .WithEnabledAtNight(); _synonymService.AddSynonymsForArea(Room.Kitchen, "Küche", "Kitchen"); }
public void Apply() { var hsrel8 = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.OfficeHSREL8, new I2CSlaveAddress(20)); var hspe8 = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37)); var input4 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4); var input5 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5); var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>(); const int SensorPin = 2; var room = _areaService.CreateArea(Room.Office); _sensorFactory.RegisterWindow(room, Office.WindowLeft, w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10))); _sensorFactory.RegisterWindow(room, Office.WindowRight, w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8))); _sensorFactory.RegisterTemperatureSensor(room, Office.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)); _sensorFactory.RegisterHumiditySensor(room, Office.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)); _sensorFactory.RegisterMotionDetector(room, Office.MotionDetector, input4.GetInput(13)); _actuatorFactory.RegisterSocket(room, Office.SocketFrontLeft, hsrel8.GetOutput(0)); _actuatorFactory.RegisterSocket(room, Office.SocketFrontRight, hsrel8.GetOutput(6)); _actuatorFactory.RegisterSocket(room, Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState()); _actuatorFactory.RegisterSocket(room, Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState()); _actuatorFactory.RegisterSocket(room, Office.SocketRearLeftEdge, hsrel8.GetOutput(7)); _actuatorFactory.RegisterSocket(room, Office.SocketRearLeft, hsrel8.GetOutput(2)); _actuatorFactory.RegisterSocket(room, Office.SocketRearRight, hsrel8.GetOutput(1)); _actuatorFactory.RegisterSocket(room, Office.RemoteSocketDesk, _remoteSocketService.GetOutput(0)); _sensorFactory.RegisterButton(room, Office.ButtonUpperLeft, input5.GetInput(0)); _sensorFactory.RegisterButton(room, Office.ButtonLowerLeft, input5.GetInput(1)); _sensorFactory.RegisterButton(room, Office.ButtonLowerRight, input4.GetInput(14)); _sensorFactory.RegisterButton(room, Office.ButtonUpperRight, input4.GetInput(15)); _actuatorFactory.RegisterStateMachine(room, Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8, a)); room.GetButton(Office.ButtonUpperLeft).GetPressedLongTrigger().Attach(() => { room.GetStateMachine(Office.CombinedCeilingLights).TryTurnOff(); room.GetSocket(Office.SocketRearLeftEdge).TryTurnOff(); room.GetSocket(Office.SocketRearLeft).TryTurnOff(); room.GetSocket(Office.SocketFrontLeft).TryTurnOff(); }); }