private void StartBathode(IArea bathroom) { bathroom.MotionDetector().Settings.IsEnabled.Value = false; bathroom.Lamp(LowerBathroom.LightCeilingDoor).TurnOn(); bathroom.Lamp(LowerBathroom.LightCeilingMiddle).TurnOff(); bathroom.Lamp(LowerBathroom.LightCeilingWindow).TurnOff(); bathroom.Lamp(LowerBathroom.LampMirror).TurnOff(); _bathmodeResetTimer?.Cancel(); _bathmodeResetTimer = bathroom.Controller.Timer.In(TimeSpan.FromHours(1)).Do(() => bathroom.MotionDetector().Settings.IsEnabled.Value = true); }
private void SetupStairsLamps(IArea floor, IWeatherStation weatherStation, HSPE16OutputOnly hspe16FloorAndLowerBathroom) { var output = new LogicalBinaryOutput() .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO8]) .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO9]) .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO10]) .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO11]) .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO13]) .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO12]) .WithInvertedState(); floor.WithLamp(Floor.LampStairs, output); floor.SetupConditionalOnAutomation() .WithActuator(floor.Lamp(Floor.LampStairs)) .WithOnAtNightRange(weatherStation) .WithOffBetweenRange(TimeSpan.FromHours(23), TimeSpan.FromHours(4)); }
private void SetupStairsCeilingLamps(IArea floor, HSPE8OutputOnly hspe8UpperFloor) { var output = new LogicalBinaryOutput() .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO4]) .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO5]) .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO7]) .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO6]) .WithInvertedState(); floor.WithLamp(Floor.LampStairsCeiling, output); floor.SetupTurnOnAndOffAutomation() .WithTrigger(floor.MotionDetector(Floor.StairsLowerMotionDetector), new AnimateParameter()) .WithTrigger(floor.MotionDetector(Floor.StairsUpperMotionDetector)) //.WithTrigger(floor.Button(Floor.ButtonStairsUpper)) .WithTarget(floor.BinaryStateOutput(Floor.LampStairsCeiling)) .WithOnDuration(TimeSpan.FromSeconds(10)); var lamp = floor.Lamp(Floor.LampStairsCeiling); floor.Button(Floor.ButtonStairsUpper).GetPressedShortlyTrigger().Triggered += (s, e) => { if (lamp.GetState() == BinaryActuatorState.On) { lamp.TurnOff(new AnimateParameter().WithReversedOrder()); } else { lamp.TurnOn(new AnimateParameter()); } }; floor.Button(Floor.ButtonStairsLowerUpper).GetPressedShortlyTrigger().Triggered += (s, e) => { if (lamp.GetState() == BinaryActuatorState.On) { lamp.TurnOff(new AnimateParameter()); } else { lamp.TurnOn(new AnimateParameter().WithReversedOrder()); } }; }
private void SetupLight(StateMachine light, IArea room) { var lightsCouchOnly = room.CombineActuators(Office.CombinedCeilingLightsCouchOnly) .WithActuator(room.Lamp(Office.LightCeilingRearRight)); var lightsDeskOnly = room.CombineActuators(Office.CombinedCeilingLightsDeskOnly) .WithActuator(room.Lamp(Office.LightCeilingFrontMiddle)) .WithActuator(room.Lamp(Office.LightCeilingFrontLeft)) .WithActuator(room.Lamp(Office.LightCeilingMiddleLeft)); var lightsOther = room.CombineActuators(Office.CombinedCeilingLightsOther) .WithActuator(room.Lamp(Office.LightCeilingFrontRight)) .WithActuator(room.Lamp(Office.LightCeilingMiddleMiddle)) .WithActuator(room.Lamp(Office.LightCeilingMiddleRight)) .WithActuator(room.Lamp(Office.LightCeilingRearLeft)); light.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(room.Button(Office.ButtonUpperLeft)); light.AddState("DeskOnly") .WithActuator(lightsDeskOnly, BinaryActuatorState.On) .WithActuator(lightsCouchOnly, BinaryActuatorState.Off) .WithActuator(lightsOther, BinaryActuatorState.Off) .ConnectApplyStateWith(room.Button(Office.ButtonLowerLeft)); light.AddState("CouchOnly") .WithActuator(lightsDeskOnly, BinaryActuatorState.Off) .WithActuator(lightsCouchOnly, BinaryActuatorState.On) .WithActuator(lightsOther, BinaryActuatorState.Off) .ConnectApplyStateWith(room.Button(Office.ButtonLowerRight)); }
private void SetupStateMachine(StateMachine stateMachine, IArea garden) { stateMachine.AddOffState() .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("Te") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("G") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("W") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("D") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("Ti") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.On); stateMachine.AddState("G+W") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("Te+G+W") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.Off) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.Off); stateMachine.AddState("Te+G+W+D+Ti") .WithActuator(garden.Lamp(Garden.LampTerrace), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampGarage), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampTap), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.SpotlightRoof), BinaryActuatorState.On) .WithActuator(garden.Lamp(Garden.LampRearArea), BinaryActuatorState.On); }