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

Add Wake and Sleep times for issue #437 and maybe #218 (and me) #632

Closed

Conversation

backcountrymountains
Copy link

Added Wake and Sleep times. AL now transitions brightness from minimum at wake to max at sunrise and from max at sunset to minimum at sleep. Brightness is minimum from wake to sleep.

AL increases brightness starting at midnight but the sun doesn't rise until sunrise. This PR makes allows users to set a time for brightness to start increasing.

AL also transitions brightness all the way to midnight, long after the sun has set. This PR allows a user to set a time for AL to achieve minimum brightness while preserving a smooth transition instead of and abrupt change with sleep_mode

I have no idea how to code or what I'm doing, but this seems to work on my system.
Also, I don't know how to do PR's or anything with github, really.

Sorry if this isn't done correctly.

Added Wake and Sleep times. AL now transitions brightness from minimum at wake to max at sunrise and from max at sunset to minimum at sleep. Brightness is minimum from wake to sleep
Added Wake and Sleep times. AL now transitions brightness from minimum at wake to max at sunrise and from max at sunset to minimum at sleep. Brightness is minimum from wake to sleep
@backcountrymountains backcountrymountains changed the title Add Wake and Sleep times for issue #437 (and me) Add Wake and Sleep times for issue #437 and maybe #218 (and me) Jul 7, 2023
@basnijholt
Copy link
Owner

@backcountrymountains, thanks a lot! This seems to be a feature that many folks are interested in.

I have tried fixing the merge conflicts but a lot of tests are failing, so I am not sure whether I did it correct.

I will try to look at the implementation later.

@backcountrymountains
Copy link
Author

Sorry it wasn't ready for merging! It's really a hack and I didn't know how else to make it available for others that could accept it as "good enough."

I have no idea what I'm doing; I'm not any kind of programmer and don't know any languages. I can try and see what I'd need to change to make it work for everyone.

I think I'd ideally like to use HA input_datetime entites/helpers so that users can easily program what times changes start and end. That way users can use all of HAs templating functionality to make specific times for brightness/color changing like "make sunset 15 microseconds after the sun elevation goes below 2.194 degrees but only when the moon is waxing and not on a weekend or when Venus is in retrograde."

Adaptive lighting is my number 1 integration and what I always tell people about when I blather about Home Assistant!

@basnijholt
Copy link
Owner

basnijholt commented Aug 4, 2023

@backcountrymountains would #699 work for you?

@basnijholt
Copy link
Owner

In #699 you can set different brightness_modes. Either "default" (current behavior), "linear", or "tanh". Additionally, when not using "default", you can set brightness_mode_time_dark and brightness_mode_time_light.

with "linear":

  • During sunset the brightness will start adapting constantly from max_brightness at time=sunset_time - brightness_mode_time_light to min_brightness at time=sunset_time + brightness_mode_time_dark.
  • During sunrise the brightness will start adapting constantly from min_brightness at time=sunrise_time - brightness_mode_time_dark to max_brightness at time=sunrise_time + brightness_mode_time_light.

with "tanh" it uses the smooth shape of a hyperbolic tangent function:

  • During sunset the brightness will start adapting from 95% of the max_brightness at time=sunset_time - brightness_mode_time_light to 5% of the min_brightness at time=sunset_time + brightness_mode_time_dark.
  • During sunrise the brightness will start adapting from 5% of the min_brightness at time=sunrise_time - brightness_mode_time_dark to 95% of the max_brightness at time=sunrise_time + brightness_mode_time_light.

@basnijholt
Copy link
Owner

@backcountrymountains thank you so much for this initial implementation. It showed that people are really wanted this feature.

I hope you can try 1.19.0b1 to try out the new brightness_mode option.

I'll close this PR because it's superseded by the other work.

Repository owner locked and limited conversation to collaborators Aug 6, 2023
Repository owner unlocked this conversation Aug 6, 2023
@basnijholt basnijholt closed this Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants