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

Issue/2914 #3930

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added FEUP-CES/Issue 2914 Documentation.pdf
Binary file not shown.
Binary file added FEUP-CES/code1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FEUP-CES/code2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FEUP-CES/diagram.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FEUP-CES/example-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions FEUP-CES/report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Issue: #2914 Sunrise/Sunset for all time-controlled presets

The issue #2914 is tracked in the WLED project's issue management system. The feature
request is for the WLED user interface to support dynamic lighting control based on the
sunrise and sunset times. Specifically, users want to set lights to turn on or off at a
specified offset from sunrise or sunset times, accommodating the changing daylight
hours throughout the year.

## Requirements
### Application Context

The issue pertains to the WLED web interface used for controlling LED lighting. The web-
based configuration tool needs to offer users the ability to define lighting presets that
automatically adjust based on local sunrise and sunset times.

## User Story
As a user, I want to set my holiday lights to turn on 30 minutes after sunset and turn off
at sunrise each day within a specified date range, so the lights operate autonomously
according to natural light conditions, enhancing the ambiance and saving energy.

## Use Case

1. The user navigates to the 'Time-controlled presets' section in the WLED settings.
2. The user selects 'Sunrise' or 'Sunset' from a dropdown menu within the presets
table.
3. The user sets an offset by entering the number of minutes before or after sunrise
or sunset.
4. The system calculates the switch-on and switch-off times based on the user's
local sunset and sunrise times, adjusted by the user-defined offset.

![Figure 1 - Proposed UI](example-ui.png)

## Changes to the source code files

The changes on the source code can be checked on the Pull Request #3929.
The fix was applied in the `wled00/data/settings_time.htm` file.
1. Changed the data transfer object so that it can contain sunset and sunrise data
2. Changed the interface so that it has two new selectors for sunset and sunrise
3. Added a validation so that if sunset and sunrise are not empty or null, the
automation time to be considered will be theirs

![Figure 2 - Code examples](code1.png)
![Figure 3 - Code examples](code2.png)


## Design of the Fix
### Sequence diagram

This diagram represents the interactions between the user interface elements, the
server-side API (for retrieving location-based sunrise and sunset times), and the system
that processes these settings to control the LED lights.
We aim to constitute in the user interface for the time settings in the WLED project. It
includes new form elements for sunrise and sunset time selection, along with JavaScript
functions for dynamically generating UI elements and handling form submissions.

![Figure 4 - Sequence Diagram of WLED Sunrise/Sunset Time-Controlled Presets Configuration](diagram.jpeg)



2 changes: 1 addition & 1 deletion wled00/data/settings_time.htm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
function Cs() { gId("cac").style.display=(gN("OL").checked)?"block":"none"; }
function BTa()
{
var ih="<thead><tr><th>En.</th><th>Hour</th><th>Minute</th><th>Preset</th><th></th></tr></thead>";
var ih="<thead><tr><th>En.</th><th>Hour</th><th>Minute</th><th>Preset</th><th>Sunset</th><th>Sunrise</th><th></th></tr></thead>";
for (i=0;i<8;i++) {
ih+=`<tr><td><input name="W${i}" id="W${i}" type="hidden"><input id="W${i}0" type="checkbox"></td>
<td><input name="H${i}" class="xs" type="number" min="0" max="24"></td>
Expand Down