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

Dim to warm #452

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9dfb839
untested
th3w1zard1 Mar 18, 2023
f3b2e20
don't update brightness if dim_to_warm is set
th3w1zard1 Mar 18, 2023
314d49d
ensure brightness is a feature of lightbulb
th3w1zard1 Mar 18, 2023
0f7fb92
fixed equation
th3w1zard1 Mar 18, 2023
256bb5d
fixed a typo
th3w1zard1 Mar 18, 2023
aebe5d5
fixed a typo
th3w1zard1 Mar 18, 2023
2fb5010
changed source for max/min brightness
th3w1zard1 Mar 18, 2023
e1b9a28
derp moment
th3w1zard1 Mar 18, 2023
bf49721
formatting
th3w1zard1 Mar 18, 2023
e17a89b
formatting
th3w1zard1 Mar 18, 2023
c4d8499
Update strings.json
th3w1zard1 Mar 22, 2023
8c56bc7
Update strings.json
th3w1zard1 Mar 22, 2023
dbcb154
Ran pre-commit
th3w1zard1 Mar 22, 2023
b7520bd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 22, 2023
6ba511b
More pre-commit nonsense.
th3w1zard1 Mar 22, 2023
afbe85a
Merge branch 'dim-to-warm' of https://github.com/th3w1zard1/adaptive-…
th3w1zard1 Mar 22, 2023
7d6064e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 22, 2023
e27c5d5
More pre-commit nonsense
th3w1zard1 Mar 22, 2023
ab96ac0
Merge branch 'dim-to-warm' of https://github.com/th3w1zard1/adaptive-…
th3w1zard1 Mar 22, 2023
94064fc
Fix variable scope.
th3w1zard1 Mar 25, 2023
4f1312c
use update_entity for ensured functionality
th3w1zard1 Mar 25, 2023
7589ea3
merge upstream/master
th3w1zard1 Mar 25, 2023
8731b2f
Merge branch 'master' into dim-to-warm
th3w1zard1 Mar 27, 2023
d0f6810
Merge remote-tracking branch 'upstream/master' into dim-to-warm
th3w1zard1 Mar 27, 2023
8549525
Fix brightness being null while light is off.
th3w1zard1 Mar 28, 2023
c24c553
Added `dim_to_warm_brightness_check`
th3w1zard1 Mar 30, 2023
efdc652
Use difference of both ct calcs.
th3w1zard1 Mar 30, 2023
22356a8
brightness check is more strict
th3w1zard1 Mar 30, 2023
5b018bb
merge upstream/master
th3w1zard1 Mar 30, 2023
98f4c36
merge origin/main
th3w1zard1 Apr 10, 2023
89f131b
pass the flake8 test
th3w1zard1 Apr 10, 2023
2cd478c
fixes and cleanup
th3w1zard1 Apr 10, 2023
5d0352f
Update switch.py
th3w1zard1 Apr 10, 2023
be9defb
fix everything
th3w1zard1 Apr 10, 2023
5dbadcd
cleanup
th3w1zard1 Apr 10, 2023
28364bf
whoops
th3w1zard1 Apr 10, 2023
5237735
Update switch.py
th3w1zard1 Apr 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use difference of both ct calcs.
  • Loading branch information
th3w1zard1 committed Mar 30, 2023
commit efdc652885182d2b15be8f07e8da3cbbc1c255fe
11 changes: 9 additions & 2 deletions custom_components/adaptive_lighting/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ async def _adapt_light(
min_ct = (
self._sun_light_settings.min_color_temp
) # pylint: disable=protected-access
max_ct = color_temp_kelvin
max_ct = max_kelvin
max_brightness = (
self._sun_light_settings.max_brightness
) # pylint: disable=protected-access
Expand All @@ -1023,9 +1023,16 @@ async def _adapt_light(
# a = (min_ct-max_ct)/(min_brightness-max_brightness)^2
# check: y = (1000-6500)/((1-h)^2)*(x-255)^2+6500 if x=2 then y=1043.221836
# ^ when min_brightness=1,max_brightness(h)=255,max_ct=6500,min_ct=1000 ^
color_temp_kelvin = (
color_temp_kelvin2 = (
(min_ct - max_ct) / (min_brightness - max_brightness) ** 2
) * (brightness - max_brightness) ** 2 + max_ct
color_temp_kelvin = max(
min(
color_temp_kelvin + (color_temp_kelvin2 - color_temp_kelvin),
max_ct,
),
min_ct,
)
service_data[ATTR_COLOR_TEMP_KELVIN] = color_temp_kelvin
elif "color" in features and adapt_color:
_LOGGER.debug("%s: Setting rgb_color of light %s", self._name, light)
Expand Down