public async Task Refresh()
 {
     if (client != null)
     {
         lights = await client.ListLights(this);
     }
 }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
        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;
            }
        }