public override void Setup() { var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.LivingRoomHSREL8, new I2CSlaveAddress(18)); var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.LivingRoomHSREL5, new I2CSlaveAddress(57)); var input0 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input0); var input1 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input1); var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>(); const int SensorPin = 12; var room = Controller.CreateArea(Room.LivingRoom) .WithTemperatureSensor(LivingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(LivingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithLamp(LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState()) .WithLamp(LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState()) .WithSocket(LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1)) .WithSocket(LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2)) .WithSocket(LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3)) .WithSocket(LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5)) .WithSocket(LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7)) .WithSocket(LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4)) .WithSocket(LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0)) .WithButton(LivingRoom.ButtonUpper, input0.GetInput(15)) .WithButton(LivingRoom.ButtonMiddle, input0.GetInput(14)) .WithButton(LivingRoom.ButtonLower, input0.GetInput(13)) .WithButton(LivingRoom.ButtonPassage, input1.GetInput(10)) .WithWindow(LivingRoom.WindowLeft, w => w.WithLeftCasement(input0.GetInput(10), input0.GetInput(11)).WithRightCasement(input0.GetInput(9), input0.GetInput(8))) .WithWindow(LivingRoom.WindowRight, w => w.WithLeftCasement(input1.GetInput(14), input1.GetInput(15)).WithRightCasement(input1.GetInput(13), input1.GetInput(12))); room.GetLamp(LivingRoom.LampDiningTable) .ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonUpper)) .ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonPassage)); room.GetLamp(LivingRoom.LampCouch). ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonMiddle)); room.Socket(LivingRoom.SocketWallRightEdgeRight). ConnectToggleActionWith(room.GetButton(LivingRoom.ButtonLower)); Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.LivingRoom, "Wohnzimmer", "LivingRoom"); }
public void Setup(Controller controller, CCToolsBoardController ccToolsController, RemoteSocketController remoteSwitchController) { var hsrel8 = ccToolsController.CreateHSREL8(Device.OfficeHSREL8, new I2CSlaveAddress(20)); var hspe8 = ccToolsController.CreateHSPE8OutputOnly(Device.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37)); var input4 = controller.Device <HSPE16InputOnly>(Device.Input4); var input5 = controller.Device <HSPE16InputOnly>(Device.Input5); const int SensorPin = 2; var i2cHardwareBridge = controller.Device <I2CHardwareBridge>(); var office = controller.CreateArea(Room.Office) .WithMotionDetector(Office.MotionDetector, input4.GetInput(13)) .WithTemperatureSensor(Office.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(Office.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithLamp(Office.LightCeilingFrontRight, hsrel8.GetOutput(8).WithInvertedState()) .WithLamp(Office.LightCeilingFrontMiddle, hspe8.GetOutput(2).WithInvertedState()) .WithLamp(Office.LightCeilingFrontLeft, hspe8.GetOutput(0).WithInvertedState()) .WithLamp(Office.LightCeilingMiddleRight, hsrel8.GetOutput(9).WithInvertedState()) .WithLamp(Office.LightCeilingMiddleMiddle, hspe8.GetOutput(3).WithInvertedState()) .WithLamp(Office.LightCeilingMiddleLeft, hspe8.GetOutput(1).WithInvertedState()) .WithLamp(Office.LightCeilingRearRight, hsrel8.GetOutput(12).WithInvertedState()) .WithLamp(Office.LightCeilingRearLeft, hsrel8.GetOutput(13).WithInvertedState()) .WithSocket(Office.SocketFrontLeft, hsrel8.GetOutput(0)) .WithSocket(Office.SocketFrontRight, hsrel8.GetOutput(6)) .WithSocket(Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState()) .WithSocket(Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState()) .WithSocket(Office.SocketRearLeftEdge, hsrel8.GetOutput(7)) .WithSocket(Office.SocketRearLeft, hsrel8.GetOutput(2)) .WithSocket(Office.SocketRearRight, hsrel8.GetOutput(1)) .WithButton(Office.ButtonUpperLeft, input5.GetInput(0)) .WithButton(Office.ButtonLowerLeft, input5.GetInput(1)) .WithButton(Office.ButtonLowerRight, input4.GetInput(14)) .WithButton(Office.ButtonUpperRight, input4.GetInput(15)) .WithWindow(Office.WindowLeft, w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10))) .WithWindow(Office.WindowRight, w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8))) .WithSocket(Office.RemoteSocketDesk, remoteSwitchController.GetOutput(0)) .WithStateMachine(Office.CombinedCeilingLights, SetupLight); office.Button(Office.ButtonUpperLeft).WithLongAction(() => { office.StateMachine(Office.CombinedCeilingLights).TurnOff(); office.Socket(Office.SocketRearLeftEdge).TurnOff(); office.Socket(Office.SocketRearLeft).TurnOff(); office.Socket(Office.SocketFrontLeft).TurnOff(); }); }
public void Setup(Controller controller, CCToolsBoardController ccToolsController) { var hsrel8 = ccToolsController.CreateHSREL8(Device.LivingRoomHSREL8, new I2CSlaveAddress(18)); var hsrel5 = ccToolsController.CreateHSREL5(Device.LivingRoomHSREL5, new I2CSlaveAddress(57)); var input0 = controller.Device <HSPE16InputOnly>(Device.Input0); var input1 = controller.Device <HSPE16InputOnly>(Device.Input1); var i2cHardwareBridge = controller.Device <I2CHardwareBridge>(); const int SensorPin = 12; var livingRoom = controller.CreateArea(Room.LivingRoom) .WithTemperatureSensor(LivingRoom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(LivingRoom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithLamp(LivingRoom.LampCouch, hsrel8.GetOutput(8).WithInvertedState()) .WithLamp(LivingRoom.LampDiningTable, hsrel8.GetOutput(9).WithInvertedState()) .WithSocket(LivingRoom.SocketWindowLeftLower, hsrel8.GetOutput(1)) .WithSocket(LivingRoom.SocketWindowMiddleLower, hsrel8.GetOutput(2)) .WithSocket(LivingRoom.SocketWindowRightLower, hsrel8.GetOutput(3)) .WithSocket(LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5)) .WithSocket(LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7)) .WithSocket(LivingRoom.SocketWallRightEdgeRight, hsrel8.GetOutput(4)) .WithSocket(LivingRoom.SocketWallLeftEdgeLeft, hsrel8.GetOutput(0)) .WithButton(LivingRoom.ButtonUpper, input0.GetInput(15)) .WithButton(LivingRoom.ButtonMiddle, input0.GetInput(14)) .WithButton(LivingRoom.ButtonLower, input0.GetInput(13)) .WithButton(LivingRoom.ButtonPassage, input1.GetInput(10)) .WithWindow(LivingRoom.WindowLeft, w => w.WithLeftCasement(input0.GetInput(10), input0.GetInput(11)).WithRightCasement(input0.GetInput(9), input0.GetInput(8))) .WithWindow(LivingRoom.WindowRight, w => w.WithLeftCasement(input1.GetInput(14), input1.GetInput(15)).WithRightCasement(input1.GetInput(13), input1.GetInput(12))); livingRoom.Lamp(LivingRoom.LampDiningTable) .ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonUpper)) .ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonPassage)); livingRoom.Lamp(LivingRoom.LampCouch). ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonMiddle)); livingRoom.Socket(LivingRoom.SocketWallRightEdgeRight). ConnectToggleActionWith(livingRoom.Button(LivingRoom.ButtonLower)); }
public BedroomConfiguration(Controller controller, CCToolsBoardController ccToolsController) { if (controller == null) { throw new ArgumentNullException(nameof(controller)); } if (ccToolsController == null) { throw new ArgumentNullException(nameof(ccToolsController)); } _controller = controller; _hsrel5 = ccToolsController.CreateHSREL5(Device.BedroomHSREL5, new I2CSlaveAddress(38)); _hsrel8 = ccToolsController.CreateHSREL8(Device.BedroomHSREL8, new I2CSlaveAddress(21)); _input5 = controller.Device <HSPE16InputOnly>(Device.Input5); _input4 = controller.Device <HSPE16InputOnly>(Device.Input4); }
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"); }
public override void Setup() { var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.OfficeHSREL8, new I2CSlaveAddress(20)); var hspe8 = CCToolsBoardController.CreateHSPE8OutputOnly(InstalledDevice.UpperFloorAndOfficeHSPE8, new I2CSlaveAddress(37)); var input4 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input4); var input5 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input5); const int SensorPin = 2; var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>(); var room = Controller.CreateArea(Room.Office) .WithMotionDetector(Office.MotionDetector, input4.GetInput(13)) .WithTemperatureSensor(Office.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(Office.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithSocket(Office.SocketFrontLeft, hsrel8.GetOutput(0)) .WithSocket(Office.SocketFrontRight, hsrel8.GetOutput(6)) .WithSocket(Office.SocketWindowLeft, hsrel8.GetOutput(10).WithInvertedState()) .WithSocket(Office.SocketWindowRight, hsrel8.GetOutput(11).WithInvertedState()) .WithSocket(Office.SocketRearLeftEdge, hsrel8.GetOutput(7)) .WithSocket(Office.SocketRearLeft, hsrel8.GetOutput(2)) .WithSocket(Office.SocketRearRight, hsrel8.GetOutput(1)) .WithButton(Office.ButtonUpperLeft, input5.GetInput(0)) .WithButton(Office.ButtonLowerLeft, input5.GetInput(1)) .WithButton(Office.ButtonLowerRight, input4.GetInput(14)) .WithButton(Office.ButtonUpperRight, input4.GetInput(15)) .WithWindow(Office.WindowLeft, w => w.WithLeftCasement(input4.GetInput(11)).WithRightCasement(input4.GetInput(12), input4.GetInput(10))) .WithWindow(Office.WindowRight, w => w.WithLeftCasement(input4.GetInput(8)).WithRightCasement(input4.GetInput(9), input5.GetInput(8))) .WithSocket(Office.RemoteSocketDesk, RemoteSocketController.GetOutput(0)) .WithStateMachine(Office.CombinedCeilingLights, (s, a) => SetupLight(s, hsrel8, hspe8, a)); room.GetButton(Office.ButtonUpperLeft).GetPressedLongTrigger().Attach(() => { room.GetStateMachine(Office.CombinedCeilingLights).TryTurnOff(); room.Socket(Office.SocketRearLeftEdge).TryTurnOff(); room.Socket(Office.SocketRearLeft).TryTurnOff(); room.Socket(Office.SocketFrontLeft).TryTurnOff(); }); }
public override void Setup() { var hsrel5 = CCToolsBoardController.CreateHSREL5(InstalledDevice.BedroomHSREL5, new I2CSlaveAddress(38)); var hsrel8 = CCToolsBoardController.CreateHSREL8(InstalledDevice.BedroomHSREL8, new I2CSlaveAddress(21)); var input5 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input5); var input4 = Controller.Device <HSPE16InputOnly>(InstalledDevice.Input4); var i2cHardwareBridge = Controller.GetDevice <I2CHardwareBridge>(); const int SensorPin = 6; var room = Controller.CreateArea(Room.Bedroom) .WithTemperatureSensor(Bedroom.TemperatureSensor, i2cHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(Bedroom.HumiditySensor, i2cHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin)) .WithMotionDetector(Bedroom.MotionDetector, input5.GetInput(12)) .WithLamp(Bedroom.LightCeiling, hsrel5.GetOutput(5).WithInvertedState()) .WithLamp(Bedroom.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState()) .WithLamp(Bedroom.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState()) .WithSocket(Bedroom.SocketWindowLeft, hsrel5.GetOutput(0)) .WithSocket(Bedroom.SocketWindowRight, hsrel5.GetOutput(1)) .WithSocket(Bedroom.SocketWall, hsrel5.GetOutput(2)) .WithSocket(Bedroom.SocketWallEdge, hsrel5.GetOutput(3)) .WithSocket(Bedroom.SocketBedLeft, hsrel8.GetOutput(7)) .WithSocket(Bedroom.SocketBedRight, hsrel8.GetOutput(9)) .WithLamp(Bedroom.LampBedLeft, hsrel5.GetOutput(4)) .WithLamp(Bedroom.LampBedRight, hsrel8.GetOutput(8).WithInvertedState()) .WithButton(Bedroom.ButtonDoor, input5.GetInput(11)) .WithButton(Bedroom.ButtonWindowUpper, input5.GetInput(10)) .WithButton(Bedroom.ButtonWindowLower, input5.GetInput(13)) .WithButton(Bedroom.ButtonBedLeftInner, input4.GetInput(2)) .WithButton(Bedroom.ButtonBedLeftOuter, input4.GetInput(0)) .WithButton(Bedroom.ButtonBedRightInner, input4.GetInput(1)) .WithButton(Bedroom.ButtonBedRightOuter, input4.GetInput(3)) .WithRollerShutter(Bedroom.RollerShutterLeft, hsrel8.GetOutput(6), hsrel8.GetOutput(5)) .WithRollerShutter(Bedroom.RollerShutterRight, hsrel8.GetOutput(3), hsrel8.GetOutput(4)) .WithRollerShutterButtons(Bedroom.RollerShutterButtonsUpperUp, input5.GetInput(6), Bedroom.RollerShutterButtonsUpperDown, input5.GetInput(7)) .WithRollerShutterButtons(Bedroom.RollerShutterButtonsLowerUp, input5.GetInput(4), Bedroom.RollerShutterButtonsLowerDown, input5.GetInput(5)) .WithWindow(Bedroom.WindowLeft, w => w.WithCenterCasement(input5.GetInput(2))) .WithWindow(Bedroom.WindowRight, w => w.WithCenterCasement(input5.GetInput(3))); room.GetRollerShutter(Bedroom.RollerShutterLeft) .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsUpperUp), room.GetButton(Bedroom.RollerShutterButtonsUpperDown)); room.GetRollerShutter(Bedroom.RollerShutterRight) .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsLowerUp), room.GetButton(Bedroom.RollerShutterButtonsLowerDown)); room.CombineActuators(Bedroom.CombinedCeilingLights) .WithActuator(room.GetLamp(Bedroom.LightCeilingWall)) .WithActuator(room.GetLamp(Bedroom.LightCeilingWindow)) .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonDoor)) .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonWindowUpper)); room.GetButton(Bedroom.ButtonDoor).GetPressedLongTrigger().Attach(() => { room.GetStateMachine(Bedroom.LampBedLeft).TryTurnOff(); room.GetStateMachine(Bedroom.LampBedRight).TryTurnOff(); room.GetStateMachine(Bedroom.CombinedCeilingLights).TryTurnOff(); }); room.SetupRollerShutterAutomation() .WithRollerShutters(room.GetRollerShutters()) .WithDoNotOpenBefore(TimeSpan.FromHours(7).Add(TimeSpan.FromMinutes(15))) .WithCloseIfOutsideTemperatureIsGreaterThan(24) .WithDoNotOpenIfOutsideTemperatureIsBelowThan(3); room.SetupTurnOnAndOffAutomation() .WithTrigger(room.GetMotionDetector(Bedroom.MotionDetector)) .WithTarget(room.GetStateMachine(Bedroom.LightCeiling)) .WithOnDuration(TimeSpan.FromSeconds(15)) .WithTurnOnIfAllRollerShuttersClosed(room.GetRollerShutter(Bedroom.RollerShutterLeft), room.GetRollerShutter(Bedroom.RollerShutterRight)) .WithEnabledAtNight(Controller.ServiceLocator.GetService <IDaylightService>()) .WithSkipIfAnyActuatorIsAlreadyOn(room.GetLamp(Bedroom.LampBedLeft), room.GetLamp(Bedroom.LampBedRight)); room.WithStateMachine(Bedroom.Fan, (s, r) => SetupFan(s, r, hsrel8)); room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedLeft).SetNextState()); room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState()); room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState()); room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff()); room.GetButton(Bedroom.ButtonBedRightInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedRight).SetNextState()); room.GetButton(Bedroom.ButtonBedRightInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState()); room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState()); room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff()); Controller.ServiceLocator.GetService <SynonymService>().AddSynonymsForArea(Room.Bedroom, "Schlafzimmer", "Bedroom"); }
protected override void Initialize() { // Setup the health monitor which tracks the average time and let an LED blink if everything is healthy. InitializeHealthMonitor(LedGpio); // Setup the controller which provides ports from the GPIOs of the Pi2. var pi2PortController = new Pi2PortController(); // Setup the wrapper for I2C bus access. var i2CBus = new BuiltInI2CBus(Logger); // Setup the controller which creates ports for IO boards from CCTools (or based on PCF8574/MAX7311/PCA9555D). var ccToolsBoardController = new CCToolsBoardController(this, i2CBus, HttpApiController, Logger); 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)); // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano). var i2CHardwareBridge = new I2CHardwareBridge(new DeviceId("HB"), new I2CSlaveAddress(50), i2CBus, Timer); var remoteSwitchSender = new LPD433MHzSignalSender(i2CHardwareBridge, I2CHardwareBridge433MHzSenderPin, HttpApiController); // Setup the controller which creates ports for wireless sockets (433Mhz). var ic = new IntertechnoCodeSequenceProvider(); var remoteSwitchController = new RemoteSocketController(new DeviceId("RemoteSocketController"), remoteSwitchSender, Timer) .WithRemoteSocket(0, ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOn), ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOff)); // Setup the weather station which provides sunrise and sunset information. AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger)); // Add the example area with the example actuators. var area = this.CreateArea(Room.ExampleRoom) .WithTemperatureSensor(ExampleRoom.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(5)) .WithHumiditySensor(ExampleRoom.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(5)) .WithMotionDetector(ExampleRoom.MotionDetector, hspe16.GetInput(8)) .WithWindow(ExampleRoom.Window, w => w.WithCenterCasement(hspe16.GetInput(0))) .WithLamp(ExampleRoom.Lamp1, remoteSwitchController.GetOutput(0)) .WithSocket(ExampleRoom.Socket1, hsrel5.GetOutput(0)) .WithSocket(ExampleRoom.Socket2, hsrel5.GetOutput(4)) .WithSocket(ExampleRoom.BathroomFan, hsrel5.GetOutput(3)) .WithLamp(ExampleRoom.Lamp2, hsrel8.GetOutput(0)) .WithLamp(ExampleRoom.Lamp3, hsrel8.GetOutput(1)) .WithLamp(ExampleRoom.Lamp4, hsrel8.GetOutput(2)) .WithLamp(ExampleRoom.Lamp5, hsrel8.GetOutput(3)) .WithLamp(ExampleRoom.Lamp6, hsrel8.GetOutput(4)) .WithButton(ExampleRoom.Button1, hspe16.GetInput(1)) .WithButton(ExampleRoom.Button2, hspe16.GetInput(2)) .WithVirtualButtonGroup(ExampleRoom.LedStripRemote, g => SetupLEDStripRemote(i2CHardwareBridge, g)) .WithStateMachine(ExampleRoom.CeilingFan, (sm, r) => SetupCeilingFan(sm)); area.Lamp(ExampleRoom.Lamp5).ConnectToggleActionWith(area.Button(ExampleRoom.Button1)); area.Lamp(ExampleRoom.Lamp6).ConnectToggleActionWith(area.Button(ExampleRoom.Button1), ButtonPressedDuration.Long); area.StateMachine(ExampleRoom.CeilingFan).ConnectMoveNextAndToggleOffWith(area.Button(ExampleRoom.Button2)); SetupHumidityDependingOutput(area.HumiditySensor(ExampleRoom.HumiditySensor), hsrel8.GetOutput(5)); area.SetupTurnOnAndOffAutomation() .WithTrigger(area.MotionDetector(ExampleRoom.MotionDetector)) .WithTarget(area.BinaryStateOutput(ExampleRoom.BathroomFan)) .WithTarget(area.BinaryStateOutput(ExampleRoom.Lamp2)) .WithOnDuration(TimeSpan.FromSeconds(10)); Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); ccToolsBoardController.PollInputBoardStates(); }; }