/// <summary> /// Changes the color of the light device /// </summary> /// <param name="device">A <see cref="TradfriDevice"/></param> /// <param name="r">Red component, 0-255</param> /// <param name="g">Green component, 0-255</param> /// <param name="b">Blue component, 0-255</param> /// <returns></returns> public async Task SetColor(TradfriDevice device, int r, int g, int b, int?transition = null) { (int x, int y) = ColorExtension.CalculateCIEFromRGB(r, g, b); int intensity = ColorExtension.CalculateIntensity(r, g, b); await SetColor(device.ID, x, y, intensity, transition); if (HasLight(device)) { device.LightControl[0].ColorX = x; device.LightControl[0].ColorY = y; } }