public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IYeelightService yeelightService, ICustomApiService customApiService, IOptionsMonitor <ConfigWrapper> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper) { InitializeComponent(); System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding); LoadAboutMe(); _graphservice = graphService; _yeelightService = yeelightService; _lifxService = lifxService; _hueService = hueService; _customApiService = customApiService; _options = optionsAccessor.CurrentValue; _lIFXOAuthHelper = lifxOAuthHelper; LoadSettings().ContinueWith( t => { if (t.IsFaulted) { } this.Dispatcher.Invoke(() => { LoadApp(); var tbContext = notificationIcon.DataContext; DataContext = Config; notificationIcon.DataContext = tbContext; }); }); }
public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IOptionsMonitor <ConfigWrapper> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper) { InitializeComponent(); LoadAboutMe(); _graphservice = graphService; _lifxService = lifxService; _hueService = hueService; _options = optionsAccessor.CurrentValue; _lIFXOAuthHelper = lifxOAuthHelper; LoadSettings().ContinueWith( t => { if (t.IsFaulted) { } this.Dispatcher.Invoke(() => { LoadApp(); var tbContext = notificationIcon.DataContext; DataContext = Config; notificationIcon.DataContext = tbContext; }); }); }
private async Task <bool> UpdateLights(Schedule schedule) { var _lifxService = new LIFXService(schedule.LIFXApiKey); try { var lights = await _lifxService.GetAllLightsAsync(); var groups = await _lifxService.GetAllGroupsAsync(); if ((groups == null || groups.Count == 0) && (lights == null || lights.Count == 0)) { _logger.LogInformation($"No lights configured for LIFX"); return(true); } foreach (var light in lights) { if ($"id:{light.Id}" == schedule.SelectedLIFXItemId) { _logger.LogInformation($"Ok to Wake {schedule.ScheduleName} Linked to {light.Label}"); } } foreach (var group in groups) { if ($"group_id:{group.Id}" == schedule.SelectedLIFXItemId) { _logger.LogInformation($"Ok to Wake Linked to {group.Label} Group"); } } } catch (Exception e) { _logger.LogError(e.Message); } try { foreach (TimeInterval interval in schedule.TimeIntervals) { if (IsInRange(interval.TimeIntervalStartAsDate.TimeOfDay.ToString(), interval.TimeIntervalEndAsDate.TimeOfDay.ToString())) { await _lifxService.SetColor(interval.TimeColor, schedule.Brightness, (Selector)schedule.SelectedLIFXItemId); _logger.LogInformation($"Scedule: {schedule.ScheduleName} Current time is : {DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}, interval: {interval.TimeIntervalName}, range: {interval.TimeIntervalStartAsDate.TimeOfDay.ToString()} - {interval.TimeIntervalEndAsDate.TimeOfDay.ToString()}, light updated to {interval.TimeColor}"); return(true); } } } catch (Exception e) { _logger.LogError(e.Message); } return(true); }
public LightController(IHueService hueService, IOptionsMonitor <BaseConfig> optionsAccessor, AppState appState, LIFXService lifxService) { Config = optionsAccessor.CurrentValue; _hueService = hueService; _lifxService = lifxService; _appState = appState; }
public Worker(IHueService hueService, ILogger <Worker> logger, IOptionsMonitor <BaseConfig> optionsAccessor, AppState appState, LIFXService lifxService, ICustomApiService customApiService) { Config = optionsAccessor.CurrentValue; _hueService = hueService; _lifxService = lifxService; _customApiService = customApiService; _logger = logger; _appState = appState; }
public Worker(IHueService hueService, ILogger <Worker> logger, IOptionsMonitor <ConfigWrapper> optionsAccessor, AppState appState, LIFXService lifxService, UserAuthService userAuthService) { Config = optionsAccessor.CurrentValue; _hueService = hueService; _lifxService = lifxService; _logger = logger; _appState = appState; _userAuthService = userAuthService; _graphClient = new GraphServiceClient(userAuthService); }
public MainWindow(IGraphService graphService, IHueService hueService, LIFXService lifxService, IYeelightService yeelightService, IRemoteHueService remoteHueService, ICustomApiService customApiService, IOptionsMonitor <BaseConfig> optionsAccessor, LIFXOAuthHelper lifxOAuthHelper, DiagnosticsClient diagClient, ILogger <MainWindow> logger, ISettingsService settingsService) { _logger = logger; InitializeComponent(); System.Windows.Application.Current.SessionEnding += new SessionEndingCancelEventHandler(Current_SessionEnding); LoadAboutMe(); _graphservice = graphService; _yeelightService = yeelightService; _lifxService = lifxService; _hueService = hueService; _remoteHueService = remoteHueService; _customApiService = customApiService; _options = optionsAccessor != null ? optionsAccessor.CurrentValue : throw new NullReferenceException("Options Accessor is null"); _lIFXOAuthHelper = lifxOAuthHelper; _diagClient = diagClient; _settingsService = settingsService; LoadSettings().ContinueWith( t => { if (t.IsFaulted) { } this.Dispatcher.Invoke(() => { LoadApp(); var tbContext = notificationIcon.DataContext; DataContext = Config; notificationIcon.DataContext = tbContext; }); }, TaskScheduler.Current); }
public GetAllLightsHandler(LIFXService service) { _service = service; }
public InitializeHandler(LIFXService service) { _service = service; }
public GetAllGroupsHandler(LIFXService service) { _service = service; }
public SetColorHandler(LIFXService service) { _service = service; }