hencou / esphome_components

Collection of own ESPhome components
25 stars 15 forks source link

Support for setting color temperature range #17

Closed Henri-J-Norden closed 1 year ago

Henri-J-Norden commented 1 year ago

Problem: the color temperature in HA is not correct. MiLight LED strip controllers can be paired with arbitrary LED strips, but theoretically the MiLight bulbs should should have the same color temp range, which could be hard-coded based on the model, so the user would just have to specify their bulb model. This is not supported in this pull request though

Solution: add cold_white_color_temperature and warm_white_color_temperature yaml options.

Originally simply based on the color_temperature component, but I noticed this also changed the reachable color temp range in HA. So I assumed that the hard-coded [153, 370] mireds range is the internal range used by MiBoxer (please correct me if wrong here). I added a mapping between the user-defined range and the [153, 370] range, which seems to work now.

PS. I don't have a very accuracy way of measuring the color temperature, but I just got an app from Play Store (Color Temperature Meter), which seems to give reasonable readings with my phone (camera AWB can completely break this) when looking at diffuse light on white paper (only the measured light turned on, no bright spots on the paper). I think the values may be dependent on the environment (color of your light fixture, walls, etc.), but I got these ranges for my two bulbs (which didn't match with the stock values):

hencou commented 1 year ago

Hi Henri, Thank you, merged and tested here. Seems working fine!