public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) { throw new ArgumentNullException(nameof(motionDetector)); } _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(TurnOnSlow); _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout); return(this); }
public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector) { if (motionDetector == null) { throw new ArgumentNullException(nameof(motionDetector)); } _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(ExecuteAutoTrigger); _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout); _settingsService.CreateSettingsMonitor <MotionDetectorSettings>(motionDetector, CancelTimeoutIfMotionDetectorDeactivated); return(this); }
public static ITrigger CreatePressedLongTrigger(this IButton button, IMessageBrokerService messageBroker) { if (button == null) { throw new ArgumentNullException(nameof(button)); } if (messageBroker == null) { throw new ArgumentNullException(nameof(messageBroker)); } return(messageBroker.CreateTrigger <ButtonPressedLongEvent>(button.Id)); }