public RollerShutterAutomation( AutomationId id, IHomeAutomationTimer timer, IDaylightService daylightService, IWeatherService weatherService, IComponentController componentController) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (daylightService == null) { throw new ArgumentNullException(nameof(daylightService)); } if (weatherService == null) { throw new ArgumentNullException(nameof(weatherService)); } if (componentController == null) { throw new ArgumentNullException(nameof(componentController)); } _timer = timer; _daylightService = daylightService; _weatherService = weatherService; _componentController = componentController; SpecialSettingsWrapper = new RollerShutterAutomationSettingsWrapper(Settings); }
public RollerShutter( ActuatorId id, IBinaryOutput powerOutput, IBinaryOutput directionOutput, IHttpRequestController httpApiController, ILogger logger, IHomeAutomationTimer timer) : base(id, httpApiController, logger) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (powerOutput == null) { throw new ArgumentNullException(nameof(powerOutput)); } if (directionOutput == null) { throw new ArgumentNullException(nameof(directionOutput)); } _powerGpioPin = powerOutput; _directionGpioPin = directionOutput; _timer = timer; timer.Tick += (s, e) => UpdatePosition(e); base.Settings = new RollerShutterSettings(id, logger); }
public ConditionalOnAutomation(AutomationId id, IHomeAutomationTimer timer) : base(id) { _timer = timer; WithTrigger(new IntervalTrigger(TimeSpan.FromMinutes(1), timer)); }
public RollerShutter( string id, IBinaryOutput powerOutput, IBinaryOutput directionOutput, TimeSpan autoOffTimeout, int maxPosition, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpApiController, notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (powerOutput == null) throw new ArgumentNullException(nameof(powerOutput)); if (directionOutput == null) throw new ArgumentNullException(nameof(directionOutput)); _powerGpioPin = powerOutput; _directionGpioPin = directionOutput; _autoOffTimeout = autoOffTimeout; _positionMax = maxPosition; _timer = timer; //TODO: StartMoveUp(); timer.Tick += (s, e) => UpdatePosition(e); }
public Automation(IHomeAutomationTimer timer) { if (timer == null) throw new ArgumentNullException(nameof(timer)); Timer = timer; _conditionsValidator = new ConditionsValidator(Conditions); }
public RollerShutter( ComponentId id, IRollerShutterEndpoint endpoint, IHomeAutomationTimer timer, ISchedulerService schedulerService) : base(id) { if (id == null) { throw new ArgumentNullException(nameof(id)); } if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (schedulerService == null) { throw new ArgumentNullException(nameof(schedulerService)); } _endpoint = endpoint; _timer = timer; _schedulerService = schedulerService; timer.Tick += (s, e) => UpdatePosition(e); _settings = new RollerShutterSettingsWrapper(Settings); _startMoveUpAction = new Action(() => SetState(RollerShutterStateId.MovingUp)); _turnOffAction = new Action(() => SetState(RollerShutterStateId.Off)); _startMoveDownAction = new Action(() => SetState(RollerShutterStateId.MovingDown)); endpoint.Stop(HardwareParameter.ForceUpdateState); }
public TimeRangeCondition(IHomeAutomationTimer timer) { if (timer == null) throw new ArgumentNullException(nameof(timer)); _timer = timer; WithExpression(() => Check()); }
public RollerShutterAutomation(AutomationId id, IHomeAutomationTimer timer, IWeatherStation weatherStation, IHttpRequestController httpApiController, IActuatorController actuatorController, ILogger logger) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (weatherStation == null) { throw new ArgumentNullException(nameof(weatherStation)); } if (actuatorController == null) { throw new ArgumentNullException(nameof(actuatorController)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } _timer = timer; _weatherStation = weatherStation; _actuatorController = actuatorController; _logger = logger; Settings = new RollerShutterAutomationSettings(id, httpApiController, logger); }
public LogicalBinaryStateOutputActuator(string id, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base( id, httpApiController, notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); _timer = timer; }
public DHT22Accessor(I2CHardwareBridge.I2CHardwareBridge i2CHardwareBridge, IHomeAutomationTimer timer) { if (i2CHardwareBridge == null) throw new ArgumentNullException(nameof(i2CHardwareBridge)); if (timer == null) throw new ArgumentNullException(nameof(timer)); _i2CHardwareBridge = i2CHardwareBridge; timer.Every(TimeSpan.FromSeconds(10)).Do(FetchValues); }
public TimedAction(TimeSpan dueTime, TimeSpan interval, IHomeAutomationTimer timer) { _timeout = dueTime; _interval = interval; _timer = timer; _timer.Tick += CheckForTimeout; }
public ConditionalOnAutomation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id, timer, httpApiController, logger) { WithAutoTrigger(TimeSpan.FromMinutes(1)); WithActionIfFulfilled(TurnOn); WithActionIfNotFulfilled(TurnOff); }
public TestRollerShutterFactory(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public TurnOnAndOffAutomation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id) { _timer = timer; WithOnDuration(TimeSpan.FromMinutes(1)); Settings = new AutomationSettings(id, httpApiController, logger); }
public TestMotionDetectorFactory(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public CatLitterBoxTwitterSender(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } timer.Tick += Tick; }
public Button(string id, IBinaryInput input, IHttpRequestController httpApiController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpApiController, notificationHandler) { if (id == null) throw new ArgumentNullException(nameof(id)); if (input == null) throw new ArgumentNullException(nameof(input)); timer.Tick += CheckForTimeout; input.StateChanged += HandleInputStateChanged; }
public RollerShutterButtons(string id, IBinaryInput upInput, IBinaryInput downInput, IHttpRequestController httpRequestController, INotificationHandler notificationHandler, IHomeAutomationTimer timer) : base(id, httpRequestController, notificationHandler) { if (upInput == null) throw new ArgumentNullException(nameof(upInput)); if (downInput == null) throw new ArgumentNullException(nameof(downInput)); Up = new Button(id + "-up", upInput, httpRequestController, notificationHandler, timer); Down = new Button(id + "-down", downInput, httpRequestController, notificationHandler, timer); }
public IntervalTrigger(IHomeAutomationTimer timer, TimeSpan interval) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } timer.Every(interval).Do(Invoke); }
public Animation(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public SchedulerService(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public BathroomFanAutomation(AutomationId id, IHomeAutomationTimer timer) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public TimeRangeCondition(IHomeAutomationTimer timer) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; WithExpression(() => Check()); }
public LogicalBinaryStateActuator(ComponentId id, IHomeAutomationTimer timer) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; }
public TestButton(ComponentId id, TestButtonEndpoint endpoint, IHomeAutomationTimer timer) : base(id, endpoint, timer) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } Endpoint = endpoint; }
public IsNightCondition(IDaylightService daylightService, IHomeAutomationTimer timer) : base(timer) { if (daylightService == null) { throw new ArgumentNullException(nameof(daylightService)); } WithStart(daylightService.GetSunset); WithEnd(daylightService.GetSunrise); }
public IsDayCondition(IWeatherStation weatherStation, IHomeAutomationTimer timer) : base(timer) { if (weatherStation == null) { throw new ArgumentNullException(nameof(weatherStation)); } WithStart(() => weatherStation.Daylight.Sunrise); WithEnd(() => weatherStation.Daylight.Sunset); }
public TestRollerShutter(ComponentId id, TestRollerShutterEndpoint endpoint, IHomeAutomationTimer timer, ISchedulerService schedulerService) : base(id, endpoint, timer, schedulerService) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } Endpoint = endpoint; }
public TurnOnAndOffAutomation(AutomationId id, IHomeAutomationTimer timer) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; _wrappedSettings = new TurnOnAndOffAutomationSettingsWrapper(Settings); }
public RemoteSwitchController(LPD433MHzSignalSender sender, IHomeAutomationTimer timer) { if (sender == null) throw new ArgumentNullException(nameof(sender)); if (timer == null) throw new ArgumentNullException(nameof(timer)); _sender = sender; // Ensure that the state of the remote switch is restored if the original remote is used // or the switch has been removed from the socket and plugged in at another place. timer.Every(TimeSpan.FromSeconds(5)).Do(RefreshStates); }
public MotionDetector(string id, IBinaryInput input, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler) : base(id, httpApiController, notificationHandler) { if (input == null) throw new ArgumentNullException(nameof(input)); input.StateChanged += (s, e) => HandleInputStateChanged(e); IsEnabledChanged += (s, e) => { HandleIsEnabledStateChanged(timer, notificationHandler); }; }
private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer, ILogger logger) { if (!Settings.IsEnabled.Value) { logger.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(() => Settings.IsEnabled.Value = true); } else { _autoEnableAction?.Cancel(); } }
private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer) { if (!this.GetIsEnabled()) { Log.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(this.Enable); } else { _autoEnableAction?.Cancel(); } }
public LogicalBinaryStateOutputActuator(ActuatorId id, IHttpRequestController apiController, ILogger logger, IHomeAutomationTimer timer) : base( id, apiController, logger) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _timer = timer; Settings = new ActuatorSettings(id, logger); }
public Automation(AutomationId id, IHomeAutomationTimer timer, IHttpRequestController httpApiController, ILogger logger) : base(id) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } Timer = timer; _conditionsValidator = new ConditionsValidator(Conditions); Settings = new AutomationSettings(id, httpApiController, logger); }
public CatLitterBoxTwitterSender(IHomeAutomationTimer timer, ILogger log) { if (timer == null) { throw new ArgumentNullException(nameof(timer)); } if (log == null) { throw new ArgumentNullException(nameof(log)); } _log = log; timer.Tick += Tick; }
public AutomaticRollerShutterAutomation(IHomeAutomationTimer timer, IWeatherStation weatherStation) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (weatherStation == null) throw new ArgumentNullException(nameof(weatherStation)); _timer = timer; _weatherStation = weatherStation; SunriseDiff = TimeSpan.FromMinutes(-30); SunsetDiff = TimeSpan.FromMinutes(30); IsEnabled = true; timer.Every(TimeSpan.FromSeconds(10)).Do(Check); }
public HealthMonitor(GpioPin statusLed, IHomeAutomationTimer timer, IHttpRequestController httpApiController) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); _statusLed = statusLed; if (statusLed != null) { _ledTimeout.Start(TimeSpan.FromMilliseconds(1)); } timer.Tick += Tick; httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(ApiGet())); httpApiController.Handle(HttpMethod.Post, "health").WithSegment("reset").Using(c => ResetStatistics()); }
public Home(IHomeAutomationTimer timer, HealthMonitor healthMonitor, IWeatherStation weatherStation, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Timer = timer; _healthMonitor = healthMonitor; WeatherStation = weatherStation; HttpApiController = httpApiController; NotificationHandler = notificationHandler; httpApiController.Handle(HttpMethod.Get, "configuration").Using(c => c.Response.Body = new JsonBody(GetConfigurationAsJSON())); httpApiController.Handle(HttpMethod.Get, "status").Using(HandleStatusRequest); httpApiController.Handle(HttpMethod.Get, "health").Using(c => c.Response.Body = new JsonBody(_healthMonitor.ApiGet())); }
public MotionDetector(ActuatorId id, IBinaryInput input, IHomeAutomationTimer timer, IHttpRequestController api, ILogger logger) : base(id, api, logger) { if (input == null) { throw new ArgumentNullException(nameof(input)); } input.StateChanged += (s, e) => HandleInputStateChanged(e); base.Settings = new ActuatorSettings(id, logger); Settings.IsEnabled.ValueChanged += (s, e) => { HandleIsEnabledStateChanged(timer, logger); }; }
public I2CHardwareBridge(I2CSlaveAddress address, II2CBus i2cBus, IHomeAutomationTimer timer) { if (i2cBus == null) { throw new ArgumentNullException(nameof(i2cBus)); } if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _address = address; _i2CBus = i2cBus; DHT22Accessor = new DHT22Accessor(this, timer); }
public RemoteSocketController(LPD433MHzSignalSender sender, IHomeAutomationTimer timer) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } if (timer == null) { throw new ArgumentNullException(nameof(timer)); } _sender = sender; // Ensure that the state of the remote switch is restored if the original remote is used // or the switch has been removed from the socket and plugged in at another place. timer.Every(TimeSpan.FromSeconds(5)).Do(RefreshStates); }
public OWMWeatherStation(double lat, double lon, string appId, IHomeAutomationTimer timer, IHttpRequestController httpApiController, INotificationHandler notificationHandler) { if (timer == null) throw new ArgumentNullException(nameof(timer)); if (httpApiController == null) throw new ArgumentNullException(nameof(httpApiController)); if (notificationHandler == null) throw new ArgumentNullException(nameof(notificationHandler)); Temperature = _temperature; Humidity = _humidity; _notificationHandler = notificationHandler; _weatherDataSourceUrl = new Uri(string.Format("http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&APPID={2}&units=metric", lat, lon, appId)); httpApiController.Handle(HttpMethod.Get, "weatherStation").Using(c => c.Response.Body = new JsonBody(ApiGet())); httpApiController.Handle(HttpMethod.Post, "weatherStation").WithRequiredJsonBody().Using(c => ApiPost(c.Request)); LoadPersistedValues(); timer.Every(TimeSpan.FromMinutes(2.5)).Do(Update); }
public Animation(IHomeAutomationTimer timer) { if (timer == null) throw new ArgumentNullException(nameof(timer)); _timer = timer; }
public AutomaticTurnOnAndOffAutomation(IHomeAutomationTimer timer) { _timer = timer; WithOnDuration(TimeSpan.FromMinutes(1)); }
private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer, INotificationHandler notificationHandler) { if (!IsEnabled) { notificationHandler.PublishFrom(this, NotificationType.Info, "'{0}' disabled for 1 hour.", Id); _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(() => IsEnabled = true); } else { _autoEnableAction?.Cancel(); } }
public DirectionAnimation(IHomeAutomationTimer timer) : base(timer) { }