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

Dim to warm #452

wants to merge 37 commits into from

Conversation

th3w1zard1
Copy link
Collaborator

@th3w1zard1 th3w1zard1 commented Mar 18, 2023

Set color temp based on sun position AND current brightness. see #78
Calculates color_temp first, then uses that value as a max to then calculate again based on brightness in the following eq:
color_temp_kelvin = ((min_ct-max_ct)/(min_brightness-max_brightness)**2)*(brightness-max_brightness)**2+max_ct
when brightness is the current brightness.

Just set dim_to_warm: true in the config to get started.

Created from version 1.8.0

** is exponent not ^
for real this time
remotes can possibly set brightness higher than predefined max/min brightness, use those as sources instead if they're greater/lower than what's set. May affect the curve.
# y = a(x-h)^2+k where h,k is the vertex (255,6500) or (max_brightness,max_ct)
# 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 = ((min_ct-max_ct)/(min_brightness-max_brightness)**2)*(brightness-max_brightness)**2+max_ct
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reasoning behind this equation?

Do you perhaps have a graph or something that we can add to the README?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! please look at the issue #78 I have a graph posted toward the bottom of the thread

@th3w1zard1
Copy link
Collaborator Author

@basnijholt Why are the pre-commit filters so strict on formatting?

Example: custom_components/adaptive_lighting/switch.py:836:101: E501 line too long (106 > 100)

Do I need to fix all of these?

@basnijholt
Copy link
Owner

basnijholt commented Mar 22, 2023

The strict formatting is such that one never needs to have discussions about style. The filters dictate the style and that's it 😄

I just fixed the line lengths for you. that was in a different PR

@th3w1zard1
Copy link
Collaborator Author

@basnijholt I don't quite understand these workflow actions. I'm confused by how to effectively use pre-commits but I'll figure it out as I get accustomed.

My main concern is: why is pytest failing on all commits we are pushing? I went back in the timeline and it seems to even be failing on the master branch - spanning back several months?

@basnijholt
Copy link
Owner

just run pre-commit install once in your repo and you should be set up for life 😄

@th3w1zard1
Copy link
Collaborator Author

just run pre-commit install once in your repo and you should be set up for life 😄

I don't quite understand where I can run that command? I'm using GitHub desktop, but even when I open the terminal and try that command, I get:

C:\Users\*****\Documents\GitHub\adaptive-lighting>pre-commit install
'pre-commit' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\*****\Documents\GitHub\adaptive-lighting>git pre-commit install
git: 'pre-commit' is not a git command. See 'git --help'.

The most similar command is
        verify-commit

C:\Users\*****\Documents\GitHub\adaptive-lighting>

@basnijholt
Copy link
Owner

You first need to install pre-commit itself with pip install pre-commit.

@basnijholt
Copy link
Owner

My main concern is: why is pytest failing on all commits we are pushing? I went back in the timeline and it seems to even be failing on the master branch - spanning back several months?

Yes there are 3 tests that are failing, which I want to get to. I am not sure whether the features that it is testing are actually broken or if it is because the test is bad.

@basnijholt
Copy link
Owner

One thing we could do, is to approximate the equation that Adaptive Lighting is using in Apple HomeKit.

I personally have an unused Philips Hue Hub which I can set up with one of my Hue lights.

Then I would let a light run for 24h at 100% brightness and poll the light each minute for its state with https://github.com/studioimaginaire/phue.
Then I would set the light to 85% brightness and repeat.
Repeat again with decreasing brightness.

We would then have a dataset which with we can determine how to implement this as in HomeKit.

@basnijholt
Copy link
Owner

I can actually also come up with a scheme to sample all the brightnesses in a single day.

I just need to program the sampling and experiment a bit.

@th3w1zard1
Copy link
Collaborator Author

Brilliant!!

@basnijholt basnijholt force-pushed the master branch 4 times, most recently from 6974e9c to c05e0cc Compare March 27, 2023 16:05
@th3w1zard1 th3w1zard1 marked this pull request as draft April 4, 2023 01:31
@jacob3089
Copy link

This functionality is similar to what I posted in #127 the intent is to allow parts of the day to change both brightness and color temp together instead of changing one or the other if the sun is above or below the horizon.

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

Successfully merging this pull request may close these issues.

Suggestion: Dim to warm mode
3 participants