Skip to content

Commit 64383bb

Browse files
committed
✨ Allow setting lights to be on overnight
Remove restriction, do some smarter calculations
1 parent 632791d commit 64383bb

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

octoprint_ws281x_led_status/runner/timer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, settings, callback):
3131
if settings["enabled"]:
3232
# Only create the timer if necessary, as minimal logic as possible
3333
self.timer = self.timer = RepeatedTimer(
34-
30, # TODO reduce to 30
34+
30,
3535
self.check_times,
3636
run_first=True,
3737
)
@@ -59,10 +59,10 @@ def check_times(self):
5959
end = datetime.now().replace(hour=self.end_time[0], minute=self.end_time[1])
6060

6161
if not (end - start).total_seconds() > 0:
62-
# If start is not before end, this is not supported & lights will always be on
63-
# Don't even bother trying to calculate it..
64-
self.switch(True)
65-
return
62+
# If end is before start,
63+
# then the lights are configured to be on overnight
64+
# so we will subtract one day from the start and call it yesterday
65+
start = start.replace(day=start.day - 1)
6666

6767
current = datetime.now()
6868

octoprint_ws281x_led_status/templates/settings/features.jinja2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
</label>
2222
</div>
2323
<p class="help-block">The LED strip will turn on at the start time, off at the end time. Potentially useful if you don't want them on overnight.</p>
24-
<p data-bind="visible: {{ binding.bind_setting("features.active_times.enabled") }}" class="help-block">Note this currently doesn't support the start time being later than end time(eg. 19:00 to 13:00), your LEDs will always be off.</p>
2524
<div class="alert alert-block" data-bind="visible: {{ binding.bind_setting("features.active_times.enabled") }}">
2625
<h4>Heads up!</h4>
2726
<p>The plugin uses your system time, so this depends on a correct timezone which may not have been changed from the default.

0 commit comments

Comments
 (0)