Skip to content

Commit

Permalink
avoids a float division by zero for tasmota lights, when light is dim…
Browse files Browse the repository at this point in the history
…med off (diyhue#1013)
  • Loading branch information
GerdZanker authored Apr 3, 2024
1 parent 9ac8161 commit 408652b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions BridgeEmulator/functions/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ def convert_rgb_xy(red, green, blue):
Z = red * 0.000088 + green * 0.072310 + blue * 0.986039

#Calculate the xy values from the XYZ values
x = X / (X + Y + Z)
y = Y / (X + Y + Z)
div = X + Y + Z
if div < 0.000001:
# set values to zero in case of div by zero
x = 0
y = 0
else:
x = X / div
y = Y / div
return [x, y]

def convert_xy(x, y, bri): #needed for milight hub that don't work with xy values
Expand Down

0 comments on commit 408652b

Please sign in to comment.