Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mi Desklamp Mired Scaling incorrect #1941

Closed
fluffymadness opened this issue Oct 10, 2019 · 6 comments · Fixed by #1945
Closed

Mi Desklamp Mired Scaling incorrect #1941

fluffymadness opened this issue Oct 10, 2019 · 6 comments · Fixed by #1945

Comments

@fluffymadness
Copy link

fluffymadness commented Oct 10, 2019

I notices something when playing around with homeassistant and the fluxer component. The xiaomi desklamp has a color range from 2700k to 6500k (370mired to 153mired)
When using Fluxer to adjust color temperature to 2700k it sends the 370mired to the lamp. However the lamp on the led is still coldish white.
To have correct 2700k warm light I have to move the mired slider all to the right on espurnas webinterface to 500mireds which however equals 2000k.
Are there some settings where the mired range of the light could be adjusted?

@mcspr
Copy link
Collaborator

mcspr commented Oct 11, 2019

Those are generic default values:
https://github.com/xoseperez/espurna/search?q=LIGHT_COLDWHITE_MIRED&unscoped_q=LIGHT_COLDWHITE_MIRED

<input type="range" min="153" max="500" class="slider pure-u-lg-1-4" id="mireds">

// Used when LIGHT_USE_WHITE AND LIGHT_USE_CCT is 1 - (1000000/Kelvin = MiReds)
// Warning! Don't change this yet, NOT FULLY IMPLEMENTED!
#ifndef LIGHT_COLDWHITE_MIRED
#define LIGHT_COLDWHITE_MIRED 153 // Coldwhite Strip, Value must be __BELOW__ W2!! (Default: 6535 Kelvin/153 MiRed)
#endif
#ifndef LIGHT_WARMWHITE_MIRED
#define LIGHT_WARMWHITE_MIRED 500 // Warmwhite Strip, Value must be __ABOVE__ W1!! (Default: 2000 Kelvin/500 MiRed)
#endif
#ifndef LIGHT_COLDWHITE_KELVIN
#define LIGHT_COLDWHITE_KELVIN 6536
#endif
#ifndef LIGHT_WARMWHITE_KELVIN
#define LIGHT_WARMWHITE_KELVIN 2000
#endif

Do you mean that Desklamp defaults should have those set to 2700 and 6500 instead of 2000 and 6553?

@fluffymadness
Copy link
Author

fluffymadness commented Oct 11, 2019

Yes. I think so. According to the product specs https://www.xiaomitoday.com/xiaomi-mijia-mjtd01yl-led-desk-lamp-review/
the lamp has a color range from 2700k-6500k => 370mired to 153mired

 <input type="range" min="153" max="500" class="slider pure-u-lg-1-4" id="mireds"> 
 		                          =6500k     =2000k
 <input type="range" min="153" max="370" class="slider pure-u-lg-1-4" id="mireds"> 
                                          =6500k     =2700k

Right now when I want to have 2700k color temperature with the lamp I have to move the slider to 500mired in the webinterface
which would equal 2000k color temperature in reality.

So the problem is when the color temperature is set externally via mqtt (e.g 370 mireds come in from homeassistant flux or circadian addon)
the lamp does not set 2700k.
It feels more like ~3500k-4000k when looking at the color temperature of the light.
So the mired scale doesn't translate to the color temperature of the lamp atm.

@mcspr
Copy link
Collaborator

mcspr commented Oct 12, 2019

Ok, so the configuration needs to change.

  • mired <-> kelvin defines should be interlinked (probably via mired being the main one and having KELVIN_COLDWHITE = (10 * ((1000000 / MIREDS_COLDWHITE) / 10))
  • webui needs a small adjustment to receive coldwhite and warmwhite limits to modify min=... and max=... attrs on the input=range
  • and, finally, Desklamp should have two new mired defines setting the range to 153...370

Runtime setting could be useful too, lightMiredsCold, lightMiredsWarm?

@fluffymadness
Copy link
Author

Sounds great.
For the runtime settings i think there could be a use case for led strip controllers that have dual white channels like the h801 where its basically the users choice which color temperature the strips have that are connected. e.g one 3000k for the warmwhite and a 5000k for the cold white channel.

@mcspr
Copy link
Collaborator

mcspr commented Oct 16, 2019

espurna/code/espurna/light.ino

Lines 1286 to 1287 in c18490c

_light_cold_mireds = getSetting("lightColdMired", LIGHT_COLDWHITE_MIRED).toInt();
_light_warm_mireds = getSetting("lightWarmMired", LIGHT_WARMWHITE_MIRED).toInt();

Mired cold and warm limits now are read from settings too, things are properly balancing out now
Webui updated too, with a supprisingly small change. I am not sure if depending on these keys ordering is ok in JS, but it seems to work just fine
xiaomi-desklamp builds now use the suggested colortemp values

@fluffymadness
Copy link
Author

thanks. works fine now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants