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

Brightness follow sun #4485

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

yangminglong
Copy link

The brightness of the lights can be automatically adjusted according to the sunrise-suntop-sunset

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 12, 2025

thanks for contributing.
what is the difference of using this instead of sunrise/sunset prest or playlist?

@yangminglong
Copy link
Author

yangminglong commented Jan 13, 2025

thanks for contributing. what is the difference of using this instead of sunrise/sunset prest or playlist?

This UserMod can set brightness by mapping [minimum-maximum-minimum] from [sunrise-suntop-sunset], I use this UserMod to adjust the brightness of my plant growth light (pwm led), and I think it will make my plants happy.

Usermod Settings :

Enable - Active the Usermode
Update Interval Sec - update interval for change brightness
Min Brightness - set brightness by map of min-max-min : sunrise-suntop-sunset
Max Brightness - as up
Relax Hour - before sunrise and after sunset, maintain the min brightness for several hours

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 13, 2025

and using presets/playlists and transition times to do that will not work?

@yangminglong
Copy link
Author

yangminglong commented Jan 13, 2025

and using presets/playlists and transition times to do that will not work?
Yes, I think so. According to the Playlists Doc, it is not possible to implement this feature of Usermod.

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 13, 2025

what limits the implementation using the scheduler and presets/playlists?

@yangminglong
Copy link
Author

presets/playlists

My needs are:
Linear adjustment of brightness starting from sunrise, ending at sunset, and reaching maximum brightness at the zenith of the sun. It is best to maintain low brightness for a period of time before sunrise and after sunset.
I don't know how to achieve such a requirement using presets/paylists. If possible, please let me know. Thank you.

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 15, 2025

I checked, its difficult to do that with presets and playlists.
Any reason you are doing linear instead of a more realistic sinusoidal curve?
I have a few minor tweaks (like avoid floats if possible) but apart from that it seems ok to me.
A bit more details in the readme on what it's intended use are and and an example description of settings you use and what those result to would be helpful.

@yangminglong
Copy link
Author

I checked, its difficult to do that with presets and playlists. Any reason you are doing linear instead of a more realistic sinusoidal curve? I have a few minor tweaks (like avoid floats if possible) but apart from that it seems ok to me. A bit more details in the readme on what it's intended use are and and an example description of settings you use and what those result to would be helpful.

more realistic sinusoidal curve ? I haven't considered that much,'linear' seems enough for me.
I checked The existing 'float' in the code is necessary.

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 16, 2025

floats are not necessary at all, you can use fixed point math, but for just the calculation you do its ok to use floats.
I think if your mod is called "brightness follow sun" it should follow the sun's brightness correctly. at least think about it.
image

@DedeHai
Copy link
Collaborator

DedeHai commented Jan 21, 2025

you really need to update that readme, it is not clear what each parameter does and what the outcome is, also how much is "several hours" or how much is the increase step? you would not want to have to experiment and wait 5 hours to see the result, then change parameters and wait again.

Copy link
Author

@yangminglong yangminglong left a comment

Choose a reason for hiding this comment

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

Change the brightness calculation algorithm from linear to sin

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