public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector)); motionDetector.GetMotionDetectedTrigger().Triggered += TurnOn; motionDetector.GetDetectionCompletedTrigger().Triggered += StartTimeout; return this; }
public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) { throw new ArgumentNullException(nameof(motionDetector)); } motionDetector.GetMotionDetectedTrigger().Triggered += TurnOn; motionDetector.GetDetectionCompletedTrigger().Triggered += StartTimeout; return(this); }
public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) { throw new ArgumentNullException(nameof(motionDetector)); } motionDetector.GetMotionDetectedTrigger().Attach(Trigger); motionDetector.GetDetectionCompletedTrigger().Attach(StartTimeout); motionDetector.Settings.ValueChanged += CancelTimeoutIfMotionDetectorDeactivated; return(this); }
private void SetupDemo() { // Get the area from the controller. IArea area = this.GetArea(Room.ExampleRoom); // Get the single motion detector from the controller. IMotionDetector motionDetector = GetComponent <IMotionDetector>(); ITrigger motionDetectedTrigger = motionDetector.GetMotionDetectedTrigger(); // Get the single temperature and humidity sensor from the controller. ITemperatureSensor temperatureSensor = GetComponent <ITemperatureSensor>(); IHumiditySensor humiditySensor = GetComponent <IHumiditySensor>(); // Get the button with the specified ID from the area (not globally). IButton button = area.GetButton(ExampleRoom.Button1); ITrigger buttonTrigger = button.GetPressedShortlyTrigger(); // Get a test lamp from the area (not globally). ILamp lamp2 = area.GetLamp(ExampleRoom.Lamp2); ILamp lamp3 = area.GetLamp(ExampleRoom.Lamp3); // Integrate the twitter client if the configuration file is available. TwitterClient twitterClient; if (TwitterClientFactory.TryCreateFromDefaultConfigurationFile(out twitterClient)) { RegisterService(new TwitterClient()); IAction tweetAction = twitterClient.GetTweetAction($"Someone is here ({DateTime.Now})... @chkratky"); motionDetectedTrigger.Attach(tweetAction); buttonTrigger.Attach(tweetAction); } // An automation is "Fulfilled" per default. ////var automation = new Automation(new AutomationId("DemoAutomation")) //// .WithTrigger(motionDetectedTrigger) //// .WithActionIfConditionsFulfilled(lamp3.GetTurnOnAction()) //// .WithCondition(ConditionRelation.And, new ComponentIsInStateCondition(lamp2, BinaryStateId.Off)) //// .WithCondition(ConditionRelation.And, new NumericValueSensorHasValueGreaterThanCondition(humiditySensor, 80)); //AddAutomation(automation); SetupTelegramBot(); new PersonalAgentToApiDispatcher(this).ExposeToApi(ApiController); }
public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector)); motionDetector.GetMotionDetectedTrigger().Attach(ExecuteAutoTrigger); motionDetector.GetDetectionCompletedTrigger().Attach(StartTimeout); motionDetector.Settings.ValueChanged += (s, e) => CancelTimeoutIfMotionDetectorDeactivated(motionDetector, e); return this; }