public void Apply() { var hsrel8LowerHeatingValves = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.LowerHeatingValvesHSREL8, new I2CSlaveAddress(16)); var hsrel5UpperHeatingValves = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.UpperHeatingValvesHSREL5, new I2CSlaveAddress(56)); var hsrel5Stairway = _deviceService.GetDevice <HSREL5>(InstalledDevice.StairwayHSREL5); var input3 = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input3); var room = _areaService.CreateArea(Room.Storeroom); _actuatorFactory.RegisterLamp(room, Storeroom.LightCeiling, hsrel5Stairway[HSREL5Pin.GPIO1]); _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetector, input3.GetInput(12)); _sensorFactory.RegisterMotionDetector(room, Storeroom.MotionDetectorCatLitterBox, input3.GetInput(11).WithInvertedState()); _actuatorFactory.RegisterSocket(room, Storeroom.CatLitterBoxFan, hsrel5Stairway[HSREL5Pin.GPIO2]); _actuatorFactory.RegisterSocket(room, Storeroom.CirculatingPump, hsrel5UpperHeatingValves[HSREL5Pin.Relay3]); _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.LightCeilingAutomation) .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetector)) .WithTarget(room.GetLamp(Storeroom.LightCeiling)); _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CatLitterBoxFan) .WithTrigger(room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox)) .WithTarget(room.GetSocket(Storeroom.CatLitterBoxFan)); // Both relays are used for water source selection (True+True = Lowerr, False+False = Upper) // Second relays is with capacitor. Disable second with delay before disable first one. hsrel5UpperHeatingValves[HSREL5Pin.GPIO0].Write(BinaryState.Low); hsrel5UpperHeatingValves[HSREL5Pin.GPIO1].Write(BinaryState.Low); _automationFactory.RegisterTurnOnAndOffAutomation(room, Storeroom.CirculatingPumpAutomation) .WithTrigger(_areaService.GetArea(Room.Kitchen).GetMotionDetector(KitchenConfiguration.Kitchen.MotionDetector)) .WithTrigger(_areaService.GetArea(Room.LowerBathroom).GetMotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector)) .WithTarget(room.GetSocket(Storeroom.CirculatingPump)) .WithPauseAfterEveryTurnOn(TimeSpan.FromHours(1)) .WithEnabledAtDay(); _catLitterBoxTwitterSender = new CatLitterBoxTwitterSender(_timerService, _twitterClientService).WithTrigger( room.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox)); _synonymService.AddSynonymsForArea(Room.Storeroom, "Abstellkammer", "Storeroom"); }
public override void Setup() { var hsrel8LowerHeatingValves = CCToolsBoardController.CreateHSREL8(InstalledDevice.LowerHeatingValvesHSREL8, new I2CSlaveAddress(16)); var hsrel5UpperHeatingValves = CCToolsBoardController.CreateHSREL5(InstalledDevice.UpperHeatingValvesHSREL5, new I2CSlaveAddress(56)); var hsrel5Stairway = Controller.Device <HSREL5>(InstalledDevice.StairwayHSREL5); var input3 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input3); var storeroom = Controller.CreateArea(Room.Storeroom) .WithMotionDetector(Storeroom.MotionDetector, input3.GetInput(12)) .WithMotionDetector(Storeroom.MotionDetectorCatLitterBox, input3.GetInput(11).WithInvertedState()) .WithLamp(Storeroom.LightCeiling, hsrel5Stairway.GetOutput(7).WithInvertedState()) .WithSocket(Storeroom.CatLitterBoxFan, hsrel8LowerHeatingValves.GetOutput(15)); storeroom.SetupTurnOnAndOffAutomation() .WithTrigger(storeroom.GetMotionDetector(Storeroom.MotionDetector)) .WithTarget(storeroom.GetLamp(Storeroom.LightCeiling)) .WithOnDuration(TimeSpan.FromMinutes(1)); storeroom.SetupTurnOnAndOffAutomation() .WithTrigger(storeroom.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox)) .WithTarget(storeroom.Socket(Storeroom.CatLitterBoxFan)) .WithOnDuration(TimeSpan.FromMinutes(2)); storeroom.WithSocket(Storeroom.CirculatingPump, hsrel5UpperHeatingValves.GetOutput(3)); // TODO: Create RoomIdFactory like ActuatorIdFactory. storeroom.SetupTurnOnAndOffAutomation() .WithTrigger(Controller.GetArea(new AreaId(Room.Kitchen.ToString())).GetMotionDetector(KitchenConfiguration.Kitchen.MotionDetector)) .WithTrigger(Controller.GetArea(new AreaId(Room.LowerBathroom.ToString())).GetMotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector)) .WithTarget(storeroom.Socket(Storeroom.CirculatingPump)) .WithPauseAfterEveryTurnOn(TimeSpan.FromHours(1)) .WithOnDuration(TimeSpan.FromMinutes(1)) .WithEnabledAtDay(Controller.GetService <IDaylightService>()); _catLitterBoxTwitterSender = new CatLitterBoxTwitterSender(Controller.Timer).WithTrigger( storeroom.GetMotionDetector(Storeroom.MotionDetectorCatLitterBox)); Controller.GetService <SynonymService>().AddSynonymsForArea(Room.Storeroom, "Abstellkammer", "Storeroom"); }