diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

hsv_to_rgb() not factoring in m component #946

Open hre999 opened 8 months ago

hre999 commented 8 months ago

Issue does not already exist?

I have searched and found no existing issue

Select Environment

Install Script

Home Assistant related?

No

Description

/BridgeEmulator/functions/colors.py: hsv_to_rgb sets m component correctly, yet does not factor it into the return value. On RGB lights this produces wrong color output.

Possible fix: Line 99 return clampRGB([r * 255, g * 255, b * 255]) -> return clampRGB([(r+m) * 255, (g+m) * 255, (b+m) * 255])

Though I do not know if the existing function is used by RGBW lights which compensate this with their W channel or something similar, bugging them in turn.

Errorlog:

pprint(hsv_to_rgb(0, 255, 255)) # [255, 0, 0]
pprint(hsv_to_rgb(0, 128, 255)) # [129, 0, 0]
pprint(hsv_to_rgb(0, 0, 255)) # [0, 0, 0] 

Steps to reproduce

Please enter your operating system details here

Linux 6.1.21 armv7l

What DiyHue version(branch) are you using?

master (latest)