public async Task Refresh() { if (client != null) { lights = await client.ListLights(this); } }
public async Task <List <Light> > GetAllLightsAsync() { if (!_options.IsLIFXEnabled || string.IsNullOrEmpty(_options.LIFXApiKey)) { return(new List <Light>()); } _client = await LifxCloudClient.CreateAsync(_options.LIFXApiKey); return(await _client.ListLights(Selector.All)); }
public async Task <List <Light> > GetAllLightsAsync() { if (string.IsNullOrEmpty(_apiKey)) { return(new List <Light>()); } _client = await LifxCloudClient.CreateAsync(_apiKey); var loadedLights = await _client.ListLights(Selector.All); loadedLights = loadedLights.Where(a => !string.IsNullOrEmpty(a.Label)).ToList(); return(loadedLights); }
public async Task <List <Light> > GetAllLights(string apiKey = null) { try { if (!string.IsNullOrEmpty(apiKey)) { _options.LightSettings.LIFX.LIFXApiKey = apiKey; } if (!_options.LightSettings.LIFX.IsEnabled || string.IsNullOrEmpty(_options.LightSettings.LIFX.LIFXApiKey)) { return(new List <Light>()); } _client = await LifxCloudClient.CreateAsync(_options.LightSettings.LIFX.LIFXApiKey); return(await _client.ListLights(Selector.All)); } catch (Exception e) { _logger.LogError(e, "Error Getting Lights"); throw; } }