esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
418 stars 26 forks source link

minimum/maximum brightness on light #920

Open docteurzoidberg opened 4 years ago

docteurzoidberg commented 4 years ago

Describe the problem you have/What new integration you would like

I would like to be able to set the minimum, and maximum brightness in a light component.

For the maximum brightness, I actually use color_correct: [50,50,50] in my config but a generic 'maximum brightness" option would be fine too.

Nothings exists yet for the minimum.

Please describe your use case for this integration and alternatives you've tried:

Actually, when I set the maximum brightness to 50% on all channels with the color_correct option in a light component, my leds doesn't light on when set to under 20% brightness when turn_on.

I would like to have a minimum 20% set in config so the light will be on when turned on

jmvaz commented 4 years ago

I have the same problem. Just setup one arilux LC06 module, and above 7% the LEDs just turn off, I need to set up that the minimum allowed brightness is 7 %, otherwise, the leds will be shutdown.

gitolicious commented 3 years ago

For my LED strip, values below 10% are "off", would be awesome to have this! I could imagine something similar to min_power of the Output Component.

xuefer commented 3 years ago

For my LED strip, values below 10% are "off", would be awesome to have this! I could imagine something similar to min_power of the Output Component.

same problem here. can't solve with min_power of Output Component since it remove 0 (off) output

RAYs3T commented 3 years ago

Also running into this. Would be really nice to be able to set a minimum, because my strips start to flicker if they run under 14%

xuefer commented 3 years ago

the only way is to patch min_power code to skip applying min_power on zero value

jmvaz commented 3 years ago

the only way is to patch min_power code to skip applying min_power on zero value

@xuefer How can we do that? :)

xuefer commented 3 years ago

0001-allow-turn-off-output-even-for-non-zero-min_power.patch.gz

From e5c060cd30f049a5f68b4b90ba9c2a6991a9b0c7 Mon Sep 17 00:00:00 2001
From: Xuefer <xuefer@gmail.com>
Date: Thu, 7 Jan 2021 22:26:26 +0800
Subject: [PATCH] allow turn off output even for non zero min_power

Signed-off-by: Xuefer <xuefer@gmail.com>

diff --git a/esphome/components/output/float_output.cpp b/esphome/components/output/float_output.cpp
index 0d536d0..ef4c787 100644
--- a/esphome/components/output/float_output.cpp
+++ b/esphome/components/output/float_output.cpp
@@ -30,7 +30,7 @@ void FloatOutput::set_level(float state) {
   }
 #endif

-  float adjusted_value = (state * (this->max_power_ - this->min_power_)) + this->min_power_;
+  float adjusted_value = state > 0.0f ? (state * (this->max_power_ - this->min_power_)) + this->min_power_ : 0;
   if (this->is_inverted())
     adjusted_value = 1.0f - adjusted_value;
   this->write_state(adjusted_value);
-- 
2.29.2
pmannk commented 3 years ago

Ran into this issue myself tonight too. LED turns off < 10% and flickers under 20%. Thanks for the proposed patch @xuefer !

WeekendWarrior1 commented 3 years ago

Should work without xuefer's patch now.

robertvorthman commented 3 years ago

Still hoping the min_power parameter gets added to the Light component because my fastled_clockless platform lights flicker below 15%. Xuefer's patch seems to only apply to PWM lights that use the Output component.

WeekendWarrior1 commented 3 years ago

@robertvorthman what hardware are you using? (out of curiosity)

robertvorthman commented 3 years ago

@WeekendWarrior1 Wemos D1 mini

WeekendWarrior1 commented 3 years ago

@WeekendWarrior1 Wemos D1 mini

Sorry, what lights?

robertvorthman commented 3 years ago

@WeekendWarrior1 Wemos D1 mini

Sorry, what lights?

WS2811 light strip. This one: https://www.amazon.com/dp/B07PJZR3MZ/

Joshfindit commented 2 years ago

I support this for all lights: PWM, LEDC, Addressable, etc. Especially as it relates to HomeAssistant: 0% = off, 1% = defined_minimum, 100% = defined_maximum

WeekendWarrior1 commented 2 years ago

I support this for all lights: PWM, LEDC, Addressable, etc. Especially as it relates to HomeAssistant: 0% = off, 1% = defined_minimum, 100% = defined_maximum

https://esphome.io/components/output/index.html?highlight=zero_means_zero The functionality works within ESPHome, requires the zero_means_zero flag set to true on the output component

Joshfindit commented 2 years ago

Yes, that works for the Output component, but not any other type of light.

WeekendWarrior1 commented 2 years ago

Yes, that works for the Output component, but not any other type of light.

Apologies, you are totally correct.

burnbabyburn commented 2 years ago

i hereby support this feature-req. All my ws2812b have this problem with esphome. I'll revert back to mclightning and/or wled as they work fine! Since this issue celebrates his second year of existance there will probably never be a fix :(

mbrevda commented 1 year ago

Seeing a seemingly similar issue with Athom bulbs: < 10% in HA turns off the led.

spartan117aut commented 1 year ago

+1

Janldeboer commented 1 year ago

I'm currently working on this feature. What I found out during this, is that (at least when using WS2812b), the gamma correction is responsible for the flickering. Setting the parameter gamma_correct to 1 (defaults to 2.8 when using addressable LED-strips) leads to clean colors on every level of brightness.

xuefer commented 1 year ago

Should the effect of gamma correction be compress to 1 when brightness is closing to low?

On Fri, Dec 9, 2022 at 05:16 Jan de Boer @.***> wrote:

I'm currently working on this feature. What I found out during this, is that (at least when using WS2812b), the gamma correction is responsible for the flickering. Setting the parameter gamma_correct to 1 (defaults to 2.8 when using addressable LED-strips) leads to clean colors on every level of brightness.

— Reply to this email directly, view it on GitHub https://github.com/esphome/feature-requests/issues/920#issuecomment-1343365628, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANJEABBIELAP4ER4VIU6H3WMJF3BANCNFSM4R6DO32Q . You are receiving this because you were mentioned.Message ID: @.***>

Janldeboer commented 1 year ago

Should the effect of gamma correction be compress to 1 when brightness is closing to low?

I did try that at some point, but then colors like an almost pure red with just a little bit blue will turn into purple when to turn down the brightness.

Janldeboer commented 1 year ago

On this branch I have implemented min and max brightness in the same way that gamma correction is implemented. But I'm unhappy about the result: Pure Red, Green and Blue are barely existing anymore, unless you increase gamma_correct which then again leads to flickering when the brightness is low.

Janldeboer commented 1 year ago

A bigger issue that I see here is that we have an ESPColorCorrection class which is only used by AddressableLight, while other light components accomplish color correction by using the current_color_as_... methods provided by the LightState.

To implement min/max brightness, we currently would have to implement that into both. That doesn't sound like a good practice to me, so I will try to combine the too concepts into one. In my opinion, the ESPColorCorrection should be used everywhere as is works with pre-calculated tables that save a lot of computational.

1Reed commented 1 year ago

Any updates here? I use a WS2812b LED-Matrix for a coustom light and have the Problem that the light only turns on, if the brighness is settt to 11% (or higher). Hope it will be implemented and an UP for working on it @Janldeboer!