Example #1
0
        public static RollerShutterAutomation WithDoNotOpenBefore(this RollerShutterAutomation automation, TimeSpan minTime)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            automation.Settings.SkipBeforeTimestampIsEnabled = true;
            automation.Settings.SkipBeforeTimestamp          = minTime;

            return(automation);
        }
Example #2
0
        public RollerShutterAutomation RegisterRollerShutterAutomation(IArea area, Enum id)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var automation = new RollerShutterAutomation(
                $"{area.Id}.{id}",
                _notificationService,
                _schedulerService,
                _dateTimeService,
                _daylightService,
                _outdoorTemperatureService,
                _componentService,
                _settingsService,
                _resourceService);

            area.RegisterAutomation(automation);

            return automation;
        }
        public static RollerShutterAutomation SetupRollerShutterAutomation(this IArea area)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var automation = new RollerShutterAutomation(
                AutomationIdFactory.CreateIdFrom <RollerShutterAutomation>(area),
                area.Controller.Timer,
                area.Controller.GetService <IDaylightService>(),
                area.Controller.GetService <IWeatherService>(),
                area.Controller);

            automation.Activate();

            area.AddAutomation(automation);

            return(automation);
        }
Example #4
0
        public RollerShutterAutomation RegisterRollerShutterAutomation(IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var automation = new RollerShutterAutomation(
                AutomationIdGenerator.Generate(area, id),
                _notificationService,
                _schedulerService,
                _dateTimeService,
                _daylightService,
                _outdoorTemperatureService,
                _componentService,
                _settingsService,
                _resourceService);

            area.AddAutomation(automation);

            return(automation);
        }
Example #5
0
        public static RollerShutterAutomation WithCloseIfOutsideTemperatureIsGreaterThan(this RollerShutterAutomation automation, float maxOutsideTemperature)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            automation.Settings.AutoCloseIfTooHotIsEnabled  = true;
            automation.Settings.AutoCloseIfTooHotTemperaure = maxOutsideTemperature;

            return(automation);
        }
Example #6
0
        public static RollerShutterAutomation WithDoNotOpenIfOutsideTemperatureIsBelowThan(this RollerShutterAutomation automation, float minOutsideTemperature)
        {
            if (automation == null)
            {
                throw new ArgumentNullException(nameof(automation));
            }

            automation.Settings.SkipIfFrozenIsEnabled   = true;
            automation.Settings.SkipIfFrozenTemperature = minOutsideTemperature;

            return(automation);
        }
        public RollerShutterAutomation RegisterRollerShutterAutomation(IArea area, Enum id)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var automation = new RollerShutterAutomation(
                AutomationIdGenerator.Generate(area, id),
                _notificationService,
                _schedulerService,
                _dateTimeService,
                _daylightService,
                _outdoorTemperatureService,
                _componentService,
                _settingsService,
                _resourceService);

            area.AddAutomation(automation);

            return automation;
        }
        private void Setup()
        {
            _controller = new TestController();
            _controller.SetTime(TimeSpan.Parse("12:00"));

            var testRollerShutterFactory = new TestRollerShutterFactory(_controller.TimerService, _controller.SchedulerService, new SettingsService(new BackupService(), new StorageService()));

            _weatherStation = new TestWeatherStation();
            _weatherStation.OutdoorTemperature = 20;

            _rollerShutter = testRollerShutterFactory.CreateTestRollerShutter();
            _controller.ComponentService.AddComponent(_rollerShutter);

            _automation = new RollerShutterAutomation(
                AutomationIdGenerator.EmptyId,
                _controller.NotificationService,
                _controller.SchedulerService,
                _controller.DateTimeService,
                _controller.DaylightService,
                _weatherStation,
                _controller.ComponentService,
                new SettingsService(new BackupService(), new StorageService()), new ResourceService(new BackupService(), new StorageService(), new SettingsService(new BackupService(), new StorageService())));

            _automation.WithRollerShutters(_rollerShutter);
        }