public void Setup(Home home, CCToolsBoardController ccToolsController, IOBoardManager ioBoardManager, DHT22Accessor dht22Reader) { var hsrel8LowerHeatingValves = ccToolsController.CreateHSREL8(Device.LowerHeatingValvesHSREL8, 16); var hsrel5UpperHeatingValves = ccToolsController.CreateHSREL5(Device.UpperHeatingValvesHSREL5, 56); var hsrel5Stairway = ioBoardManager.GetOutputBoard(Device.StairwayHSREL5); var input3 = ioBoardManager.GetInputBoard(Device.Input3); var storeroom = home.AddRoom(Room.Storeroom) .WithMotionDetector(Storeroom.MotionDetector, input3.GetInput(12)) .WithLamp(Storeroom.LightCeiling, hsrel5Stairway.GetOutput(7).WithInvertedState()) .WithSocket(Storeroom.CatLitterBoxFan, hsrel8LowerHeatingValves.GetOutput(15)); storeroom.SetupAutomaticTurnOnAndOffAction() .WithTrigger(storeroom.MotionDetector(Storeroom.MotionDetector)) .WithTarget(storeroom.Lamp(Storeroom.LightCeiling)) .WithTarget(storeroom.Socket(Storeroom.CatLitterBoxFan)) .WithOnDuration(TimeSpan.FromMinutes(1)); storeroom.WithSocket(Storeroom.CirculatingPump, hsrel5UpperHeatingValves.GetOutput(3)); storeroom.SetupAutomaticTurnOnAndOffAction() .WithTrigger(home.Room(Room.Kitchen).MotionDetector(KitchenConfiguration.Kitchen.MotionDetector)) .WithTrigger(home.Room(Room.LowerBathroom).MotionDetector(LowerBathroomConfiguration.LowerBathroom.MotionDetector)) .WithTarget(storeroom.Socket(Storeroom.CirculatingPump)) .WithOnDuration(TimeSpan.FromMinutes(1)) .WithEnabledAtDay(home.WeatherStation); }
public void Setup(Home home, CCToolsBoardController ccToolsController, IOBoardManager ioBoardManager, DHT22Accessor dht22Accessor) { var hsrel8 = ccToolsController.CreateHSREL8(Device.LivingRoomHSREL8, 18); var hsrel5 = ccToolsController.CreateHSREL5(Device.LivingRoomHSREL5, 57); var input0 = ioBoardManager.GetInputBoard(Device.Input0); var input1 = ioBoardManager.GetInputBoard(Device.Input1); const int SensorPin = 12; // 0; var livingRoom = home.AddRoom(Room.LivingRoom) .WithTemperatureSensor(LivingRoom.TemperatureSensor, dht22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(LivingRoom.HumiditySensor, 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.SocketWallRightEdgeRight, hsrel8.GetOutput(4)) .WithSocket(LivingRoom.SocketWindowLeftUpper, hsrel8.GetOutput(5)) .WithSocket(LivingRoom.SocketWindowRightUpper, hsrel8.GetOutput(7)) .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 void Setup(Home home, CCToolsBoardController ccToolsController, IOBoardManager ioBoardManager, DHT22Accessor dht22Accessor, RemoteSwitchController remoteSwitchController) { var hsrel8 = ccToolsController.CreateHSREL8(Device.OfficeHSREL8, 20); var hspe8 = ccToolsController.CreateHSPE8OutputOnly(Device.UpperFloorAndOfficeHSPE8, 37); var input4 = ioBoardManager.GetInputBoard(Device.Input4); var input5 = ioBoardManager.GetInputBoard(Device.Input5); const int SensorPin = 2; //6; var office = home.AddRoom(Room.Office) .WithMotionDetector(Office.MotionDetector, input4.GetInput(13)) .WithTemperatureSensor(Office.TemperatureSensor, dht22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(Office.HumiditySensor, 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))); office.WithSocket(Office.RemoteSocketDesk, remoteSwitchController.GetOutput(0)); var lightsCouchOnly = office.CombineActuators(Office.CombinedCeilingLightsCouchOnly) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingRearRight)); var lightsDeskOnly = office.CombineActuators(Office.CombinedCeilingLightsDeskOnly) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingFrontMiddle)) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingFrontLeft)) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingMiddleLeft)); var lightsOther = office.CombineActuators(Office.CombinedCeilingLightsOther) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingFrontRight)) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingMiddleMiddle)) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingMiddleRight)) .WithActuator(office.Actuator<Lamp>(Office.LightCeilingRearLeft)); var light = office.AddStateMachine(Office.CombinedCeilingLights) .WithTurnOffIfStateIsAppliedTwice(); light.AddOffState() .WithActuator(lightsDeskOnly, BinaryActuatorState.Off) .WithActuator(lightsCouchOnly, BinaryActuatorState.Off) .WithActuator(lightsOther, BinaryActuatorState.Off); light.AddOnState() .WithActuator(lightsDeskOnly, BinaryActuatorState.On) .WithActuator(lightsCouchOnly, BinaryActuatorState.On) .WithActuator(lightsOther, BinaryActuatorState.On). ConnectApplyStateWith(office.Actuator<Button>(Office.ButtonUpperLeft)); light.AddState("DeskOnly") .WithActuator(lightsDeskOnly, BinaryActuatorState.On) .WithActuator(lightsCouchOnly, BinaryActuatorState.Off) .WithActuator(lightsOther, BinaryActuatorState.Off) .ConnectApplyStateWith(office.Actuator<Button>(Office.ButtonLowerLeft)); light.AddState("CouchOnly") .WithActuator(lightsDeskOnly, BinaryActuatorState.Off) .WithActuator(lightsCouchOnly, BinaryActuatorState.On) .WithActuator(lightsOther, BinaryActuatorState.Off) .ConnectApplyStateWith(office.Actuator<Button>(Office.ButtonLowerRight)); office.Button(Office.ButtonUpperLeft).WithLongAction(() => { light.TurnOff(); office.Socket(Office.SocketRearLeftEdge).TurnOff(); office.Socket(Office.SocketRearLeft).TurnOff(); office.Socket(Office.SocketFrontLeft).TurnOff(); }); }
public void Setup(Home home, CCToolsBoardController ccToolsController, IOBoardManager ioBoardManager, DHT22Accessor dht22Accessor) { var hsrel5 = ccToolsController.CreateHSREL5(Device.BedroomHSREL5, 38); var hsrel8 = ccToolsController.CreateHSREL8(Device.BedroomHSREL8, 21); var input5 = ioBoardManager.GetInputBoard(Device.Input5); var input4 = ioBoardManager.GetInputBoard(Device.Input4); const int SensorPin = 6; //8; var bedroom = home.AddRoom(Room.Bedroom) .WithTemperatureSensor(Bedroom.TemperatureSensor, dht22Accessor.GetTemperatureSensor(SensorPin)) .WithHumiditySensor(Bedroom.HumiditySensor, 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), TimeSpan.FromSeconds(20), 17000) .WithRollerShutter(Bedroom.RollerShutterRight, hsrel8.GetOutput(3), hsrel8.GetOutput(4), TimeSpan.FromSeconds(20), 17000) .WithRollerShutterButtons(Bedroom.RollerShutterButtonsUpper, input5.GetInput(6), input5.GetInput(7)) .WithRollerShutterButtons(Bedroom.RollerShutterButtonsLower, input5.GetInput(4), input5.GetInput(5)) .WithWindow(Bedroom.WindowLeft, w => w.WithCenterCasement(input5.GetInput(2))) .WithWindow(Bedroom.WindowRight, w => w.WithCenterCasement(input5.GetInput(3))); bedroom.RollerShutter(Bedroom.RollerShutterLeft) .ConnectWith(bedroom.RollerShutterButtons(Bedroom.RollerShutterButtonsUpper)); bedroom.RollerShutter(Bedroom.RollerShutterRight) .ConnectWith(bedroom.RollerShutterButtons(Bedroom.RollerShutterButtonsLower)); bedroom.CombineActuators(Bedroom.CombinedCeilingLights) .WithActuator(bedroom.Lamp(Bedroom.LightCeilingWall)) .WithActuator(bedroom.Lamp(Bedroom.LightCeilingWindow)) .ConnectToggleActionWith(bedroom.Button(Bedroom.ButtonDoor)) .ConnectToggleActionWith(bedroom.Button(Bedroom.ButtonWindowUpper)); bedroom.Button(Bedroom.ButtonDoor).WithLongAction(() => { bedroom.Lamp(Bedroom.LampBedLeft).TurnOff(); bedroom.Lamp(Bedroom.LampBedRight).TurnOff(); bedroom.Lamp(Bedroom.CombinedCeilingLights).TurnOff(); }); bedroom.SetupAutomaticRollerShutters() .WithRollerShutter(bedroom.RollerShutter(Bedroom.RollerShutterLeft)) .WithRollerShutter(bedroom.RollerShutter(Bedroom.RollerShutterRight)) .WithDoNotOpenBefore(TimeSpan.FromHours(7).Add(TimeSpan.FromMinutes(15))) .WithCloseIfOutsideTemperatureIsGreaterThan(28); bedroom.SetupAutomaticTurnOnAndOffAction() .WithTrigger(bedroom.MotionDetector(Bedroom.MotionDetector)) .WithTarget(bedroom.Actuator<BinaryStateOutputActuator>(Bedroom.LightCeiling)) .WithOnDuration(TimeSpan.FromSeconds(15)) .WithTurnOnIfAllRollerShuttersClosed(bedroom.RollerShutter(Bedroom.RollerShutterLeft), bedroom.RollerShutter(Bedroom.RollerShutterRight)) .WithEnabledAtNight(home.WeatherStation) .WithSkipIfAnyActuatorIsAlreadyOn(bedroom.Lamp(Bedroom.LampBedLeft), bedroom.Lamp(Bedroom.LampBedRight)); var fanPort1 = hsrel8.GetOutput(0); var fanPort2 = hsrel8.GetOutput(1); var fanPort3 = hsrel8.GetOutput(2); var fan = bedroom.AddStateMachine(Bedroom.Fan); fan.AddOffState() .WithLowPort(fanPort1) .WithLowPort(fanPort2) .WithLowPort(fanPort3); fan.AddState("1").WithHighPort(fanPort1).WithLowPort(fanPort2).WithHighPort(fanPort3); fan.AddState("2").WithHighPort(fanPort1).WithHighPort(fanPort2).WithLowPort(fanPort3); fan.AddState("3").WithHighPort(fanPort1).WithHighPort(fanPort2).WithHighPort(fanPort3); fan.TurnOff(); fan.ConnectMoveNextAndToggleOffWith(bedroom.Button(Bedroom.ButtonWindowLower)); bedroom.Button(Bedroom.ButtonBedLeftInner).WithShortAction(() => bedroom.Lamp(Bedroom.LampBedLeft).Toggle()); bedroom.Button(Bedroom.ButtonBedLeftInner).WithLongAction(() => bedroom.BinaryStateOutput(Bedroom.CombinedCeilingLights).Toggle()); bedroom.Button(Bedroom.ButtonBedLeftOuter).WithShortAction(() => bedroom.StateMachine(Bedroom.Fan).ApplyNextState()); bedroom.Button(Bedroom.ButtonBedLeftOuter).WithLongAction(() => bedroom.StateMachine(Bedroom.Fan).TurnOff()); bedroom.Button(Bedroom.ButtonBedRightInner).WithShortAction(() => bedroom.Lamp(Bedroom.LampBedRight).Toggle()); bedroom.Button(Bedroom.ButtonBedRightInner).WithLongAction(() => bedroom.BinaryStateOutput(Bedroom.CombinedCeilingLights).Toggle()); bedroom.Button(Bedroom.ButtonBedRightOuter).WithShortAction(() => bedroom.StateMachine(Bedroom.Fan).ApplyNextState()); bedroom.Button(Bedroom.ButtonBedRightOuter).WithLongAction(() => bedroom.StateMachine(Bedroom.Fan).TurnOff()); }