Beispiel #1
0
        private void HandleIsEnabledStateChanged()
        {
            _autoEnableAction?.Cancel();

            if (!Settings.IsEnabled)
            {
                _autoEnableAction = _schedulerService.In(Settings.AutoEnableAfter, () => _settingsService.SetComponentEnabledState(this, true));
            }
        }
        private void StartTimeout()
        {
            lock (_syncRoot)
            {
                if (!GetConditionsAreFulfilled())
                {
                    return;
                }

                _turnOffTimeout?.Cancel();
                _turnOffTimeout = _schedulerService.In(Settings.Duration, TurnOff);
            }
        }
        private void StartBathode(IArea bathroom)
        {
            var motionDetector = bathroom.GetMotionDetector(LowerBathroom.MotionDetector);

            _settingsService.SetComponentEnabledState(motionDetector, false);

            bathroom.GetLamp(LowerBathroom.LightCeilingDoor).TryTurnOn();
            bathroom.GetLamp(LowerBathroom.LightCeilingMiddle).TryTurnOff();
            bathroom.GetLamp(LowerBathroom.LightCeilingWindow).TryTurnOff();
            bathroom.GetLamp(LowerBathroom.LampMirror).TryTurnOff();

            _bathmodeResetDelayedAction?.Cancel();
            _bathmodeResetDelayedAction = _schedulerService.In(TimeSpan.FromHours(1), () => _settingsService.SetComponentEnabledState(motionDetector, true));
        }
        private void StartTimeout()
        {
            _delayedAction?.Cancel();

            _delayedAction = _schedulerService.In(Settings.SlowDuration, () =>
            {
                if (_fan.GetFeatures().Extract <LevelFeature>().MaxLevel > 1)
                {
                    _fan.TrySetLevel(2);
                    _delayedAction = _schedulerService.In(Settings.FastDuration, () => _fan.TryTurnOff());
                }
                else
                {
                    _fan.TryTurnOff();
                }
            });
        }
Beispiel #5
0
 public void AddDelayedAction(IDelayedAction action)
 {
     actionList.Add(action);
 }