jomwells / ambilight-yeelight

A switch component which mimics the functionality of Ambilight+Hue for all Yeelight lights/bulbs
26 stars 8 forks source link

Average values do not work #2

Open samvanh opened 4 years ago

samvanh commented 4 years ago

'left-average' option does not seem to work, 'right-average' option does work. Suppose that it has something to do with the different implementation.

This does work: elif position == 'right-average': pixels = layer1['right'] r_sum, g_sum, b_sum = 0,0,0 for i in range(0,len(pixels)): pixel = str(int(i)) r_sum = r_sum + ((pixels[pixel]['r']) ** 2) g_sum = g_sum + ((pixels[pixel]['g']) ** 2) b_sum = b_sum + ((pixels[pixel]['b']) ** 2) r = int((r_sum/len(pixels))**(1/2)) g = int((g_sum/len(pixels))**(1/2)) b = int((b_sum/len(pixels))**(1/2))

This does not: elif position == 'left-average': pixels = layer1['left'] r_sum, g_sum, b_sum = 0,0,0 for pixel in pixels: r_sum = r_sum + ((pixel['r']) ** 2) g_sum = g_sum + ((pixel['g']) ** 2) b_sum = b_sum + ((pixel['b']) ** 2) r = int((r_sum/len(pixels))*(1/2)) g = int((g_sum/len(pixels))*(1/2)) b = int((b_sum/len(pixels))*(1/2))