private RemoteSocketController SetupRemoteSwitchController() { const int LDP433MhzSenderPin = 10; var i2cHardwareBridge = GetDevice <I2CHardwareBridge>(); var brennenstuhl = new BrennenstuhlCodeSequenceProvider(); var ldp433MHzSender = new LPD433MHzSignalSender(i2cHardwareBridge, LDP433MhzSenderPin, ApiController); var remoteSwitchController = new RemoteSocketController(ldp433MHzSender, Timer) .WithRemoteSocket(0, brennenstuhl.GetSequencePair(BrennenstuhlSystemCode.AllOn, BrennenstuhlUnitCode.A)); return(remoteSwitchController); }
public Task ApplyAsync() { _synonymService.TryLoadPersistedSynonyms(); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input0, new I2CSlaveAddress(42)); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input1, new I2CSlaveAddress(43)); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input2, new I2CSlaveAddress(47)); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input3, new I2CSlaveAddress(45)); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input4, new I2CSlaveAddress(46)); _ccToolsBoardService.RegisterHSPE16InputOnly(InstalledDevice.Input5, new I2CSlaveAddress(44)); var i2CHardwareBridge = new I2CHardwareBridge(new I2CSlaveAddress(50), _i2CBusService, _schedulerService); _deviceService.AddDevice(i2CHardwareBridge); _remoteSocketService.Sender = new LPD433MHzSignalSender(i2CHardwareBridge, LDP433MhzSenderPin, _apiService); var brennenstuhl = new BrennenstuhlCodeSequenceProvider(); _remoteSocketService.RegisterRemoteSocket(0, brennenstuhl.GetSequencePair(BrennenstuhlSystemCode.AllOn, BrennenstuhlUnitCode.A)); _containerService.GetInstance <BedroomConfiguration>().Apply(); _containerService.GetInstance <OfficeConfiguration>().Apply(); _containerService.GetInstance <UpperBathroomConfiguration>().Apply(); _containerService.GetInstance <ReadingRoomConfiguration>().Apply(); _containerService.GetInstance <ChildrensRoomRoomConfiguration>().Apply(); _containerService.GetInstance <KitchenConfiguration>().Apply(); _containerService.GetInstance <FloorConfiguration>().Apply(); _containerService.GetInstance <LowerBathroomConfiguration>().Apply(); _containerService.GetInstance <StoreroomConfiguration>().Apply(); _containerService.GetInstance <LivingRoomConfiguration>().Apply(); _synonymService.RegisterDefaultComponentStateSynonyms(); var ioBoardsInterruptMonitor = new InterruptMonitor(_pi2GpioService.GetInput(4)); ioBoardsInterruptMonitor.InterruptDetected += (s, e) => _ccToolsBoardService.PollInputBoardStates(); ioBoardsInterruptMonitor.Start(); return(Task.FromResult(0)); }
private void SetupRoom() { var ccToolsBoardController = GetDevice <CCToolsBoardController>(); var hspe16 = ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.HSPE16, new I2CSlaveAddress(41)); var hsrel8 = ccToolsBoardController.CreateHSREL8(InstalledDevice.HSRel8, new I2CSlaveAddress(40)); var hsrel5 = ccToolsBoardController.CreateHSREL5(InstalledDevice.HSRel5, new I2CSlaveAddress(56)); var i2CHardwareBridge = GetDevice <I2CHardwareBridge>(); var remoteSwitchSender = new LPD433MHzSignalSender(i2CHardwareBridge, I2CHardwareBridge433MHzSenderPin, ApiController); var intertechno = new IntertechnoCodeSequenceProvider(); var brennenstuhl = new BrennenstuhlCodeSequenceProvider(); var remoteSwitchController = new RemoteSocketController(remoteSwitchSender, Timer) .WithRemoteSocket(0, intertechno.GetSequencePair(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1)) .WithRemoteSocket(1, intertechno.GetSequencePair(IntertechnoSystemCode.B, IntertechnoUnitCode.Unit1)) .WithRemoteSocket(2, brennenstuhl.GetSequencePair(BrennenstuhlSystemCode.AllOn, BrennenstuhlUnitCode.B)) .WithRemoteSocket(3, brennenstuhl.GetSequencePair(BrennenstuhlSystemCode.AllOn, BrennenstuhlUnitCode.C)); const int SensorPin = 5; var area = this.CreateArea(Room.ExampleRoom) .WithTemperatureSensor(ExampleRoom.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(ExampleRoom.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithMotionDetector(ExampleRoom.MotionDetector, hspe16[HSPE16Pin.GPIO8]) .WithLamp(ExampleRoom.Lamp1, remoteSwitchController.GetOutput(0)) .WithLamp(ExampleRoom.Lamp2, remoteSwitchController.GetOutput(1)) .WithSocket(ExampleRoom.Socket1, hsrel5[HSREL5Pin.Relay0]) .WithSocket(ExampleRoom.Socket2, hsrel5[HSREL5Pin.Relay4]) .WithSocket(ExampleRoom.BathroomFan, hsrel5[HSREL5Pin.Relay3]) .WithLamp(ExampleRoom.Lamp3, hsrel8[HSREL8Pin.Relay0]) .WithLamp(ExampleRoom.Lamp4, hsrel8[HSREL8Pin.Relay1]) .WithLamp(ExampleRoom.Lamp5, hsrel8[HSREL8Pin.Relay2]) .WithLamp(ExampleRoom.Lamp6, hsrel8[HSREL8Pin.Relay3]) .WithLamp(ExampleRoom.Lamp7, remoteSwitchController.GetOutput(2)) .WithLamp(ExampleRoom.Lamp8, remoteSwitchController.GetOutput(3)) .WithRollerShutter(ExampleRoom.RollerShutter, hsrel8[HSREL8Pin.Relay4], hsrel8[HSREL8Pin.Relay5]) .WithButton(ExampleRoom.Button1, hspe16[HSPE16Pin.GPIO1]) .WithButton(ExampleRoom.Button2, hspe16[HSPE16Pin.GPIO2]) .WithStateMachine(ExampleRoom.CeilingFan, (sm, r) => SetupCeilingFan(sm)) .WithWindow(ExampleRoom.Window, w => w.WithCenterCasement(hspe16[HSPE16Pin.GPIO0])); area.GetButton(ExampleRoom.Button1).GetPressedShortlyTrigger().Attach(area.GetLamp(ExampleRoom.Lamp5).GetSetNextStateAction()); area.GetButton(ExampleRoom.Button1).ConnectToggleActionWith(area.GetLamp(ExampleRoom.Lamp6), ButtonPressedDuration.Long); area.GetStateMachine(ExampleRoom.CeilingFan).ConnectMoveNextAndToggleOffWith(area.GetButton(ExampleRoom.Button2)); SetupHumidityDependingLamp(area.GetHumiditySensor(ExampleRoom.HumiditySensor), area.GetLamp(ExampleRoom.Lamp7)); area.SetupTurnOnAndOffAutomation() .WithTrigger(area.GetMotionDetector(ExampleRoom.MotionDetector)) .WithTarget(area.GetStateMachine(ExampleRoom.BathroomFan)) //.WithTarget(area.GetLamp(ExampleRoom.Lamp2)) .WithOnDuration(TimeSpan.FromSeconds(10)); SetupLEDStripRemote(i2CHardwareBridge, area); RegisterSynonyms(); }