public async Task <LocalHueClient> ConnectAsync() { LocalHueClient client = null; if (string.IsNullOrEmpty(Options.Value?.PhilipsHue?.BridgeIp)) { Log.Error("Failed to conect to Philips Hue bridge, ip is null or empty, please register in your docker-compose file."); return(null); } var(appKey, appName, deviceName) = await m_Credentials.GetHueCredentialsAsync(); if (string.IsNullOrEmpty(appKey)) { Log.Information("Failed to load app key for Philips Hue bridge, will try and register ..."); client = await RegisterAsync(appName, deviceName); } try { if (client == null) { client = new LocalHueClient(Options.Value?.PhilipsHue?.BridgeIp); } (appKey, appName, deviceName) = await m_Credentials.GetHueCredentialsAsync(); client.Initialize(appKey); return(client); } catch (Exception exception) { Log.Error(exception, $"Failed to connect to Philips Hue client with ip: '{Options.Value.PhilipsHue.BridgeIp}', '{exception.Message}'"); return(null); } }