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);
        }
示例#2
0
        public IntervalTrigger(IHomeAutomationTimer timer, TimeSpan interval)
        {
            if (timer == null)
            {
                throw new ArgumentNullException(nameof(timer));
            }

            timer.Every(interval).Do(Invoke);
        }
        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 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);
        }
示例#5
0
        public DHT22Accessor(Hardware.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);
        }
示例#6
0
        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 void Activate()
 {
     _timer.Every(TimeSpan.FromSeconds(10)).Do(PerformPendingActions);
 }