private void StartTimeout(object sender, EventArgs e)
 {
     _timeout = _timer.In(_slowDuration).Do(() =>
     {
         _actuator.SetState(new StatefulComponentState("2"));
         _timeout = _timer.In(_fastDuration).Do(() => _actuator.TryTurnOff());
     });
 }
Пример #2
0
        private void RestartTracking()
        {
            _movingDuration.Restart();

            _autoOffTimer?.Cancel();
            _autoOffTimer = _timer.In(_settings.AutoOffTimeout).Do(() => SetState(RollerShutterStateId.Off));
        }
Пример #3
0
        private void Start()
        {
            _powerGpioPin.Write(BinaryState.High);
            _movingDuration.Restart();

            _autoOffTimer?.Cancel();
            _autoOffTimer = _timer.In(Settings.AutoOffTimeout.Value).Do(() => SetState(RollerShutterState.Stopped));
        }
Пример #4
0
        private void StartTimeout()
        {
            if (!GetConditionsAreFulfilled())
            {
                return;
            }

            _turnOffTimeout = _timer.In(_wrappedSettings.Duration).Do(TurnOff);
        }
Пример #5
0
 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();
     }
 }
Пример #6
0
 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, 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();
     }
 }