First, I'd like to thank you for your HueApi. I'm using it since some years for my own home automation - and it works great. :)
There might be a bug in HueColorConverter.HexColorFromState(State state, string model) in 486: The R, G and B values range from 0-1, not from 0-255. Therefore the HEX conversion failes.
But the color object already has it's own ToHex() function, so it's easy to fix.
But even if it's working, it does ignore the brightness. For me I changed the function a little so that it does not ignore the state objects brightness for the light:
public static string HexColorFromState(State state, string model)
{
if (state == null)
throw new ArgumentNullException(nameof(state));
if (state.On == false || state.Brightness <= 1) //Off or low brightness (changed from 5 to 1)
return "000000";
if (state.ColorCoordinates != null && state.ColorCoordinates.Length == 2) //Based on XY value
{
RGBColor color = ColorFromXY(new CGPoint(state.ColorCoordinates[0], state.ColorCoordinates[1]), model);
//Brightness of state (0.0-1.0)
double b = Convert.ToDouble(state.Brightness) / 255;
//color with brightness
RGBColor colorWithB = new RGBColor(color.R * b, color.G * b, color.B * b);
//ToHex() because it works :)
return colorWithB.ToHex();
}
return "FFFFFF"; //White
}
Hi!
First, I'd like to thank you for your HueApi. I'm using it since some years for my own home automation - and it works great. :)
There might be a bug in HueColorConverter.HexColorFromState(State state, string model) in 486: The R, G and B values range from 0-1, not from 0-255. Therefore the HEX conversion failes.
But the color object already has it's own ToHex() function, so it's easy to fix.
But even if it's working, it does ignore the brightness. For me I changed the function a little so that it does not ignore the state objects brightness for the light: