private void CancelTimeoutIfMotionDetectorDeactivated(SettingsChangedEventArgs <MotionDetectorSettings> e)
 {
     if (!e.NewSettings.IsEnabled)
     {
         lock (_syncRoot)
         {
             _turnOffTimeout?.Cancel();
         }
     }
 }
Exemple #2
0
        private void StartTimeout()
        {
            _delayedAction?.Cancel();

            _delayedAction = ScheduledAction.Schedule(Settings.SlowDuration, () =>
            {
                if (_fan.GetFeatures().Extract <LevelFeature>().MaxLevel > 1)
                {
                    _fan.TrySetLevel(2);
                    _delayedAction = ScheduledAction.Schedule(Settings.FastDuration, () => _fan.TryTurnOff());
                }
                else
                {
                    _fan.TryTurnOff();
                }
            });
        }
Exemple #3
0
        private void HandleIsEnabledStateChanged()
        {
            _autoEnableAction?.Cancel();

            if (!Settings.IsEnabled)
            {
                _autoEnableAction = ScheduledAction.Schedule(Settings.AutoEnableAfter, () => _settingsService.SetComponentEnabledState(this, true));
            }
        }
        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 = ScheduledAction.Schedule(TimeSpan.FromHours(1), () =>
            {
                bathroom.GetLamp(LowerBathroom.LightCeilingDoor).TryTurnOff();
                _settingsService.SetComponentEnabledState(motionDetector, true);
            });
        }