-
Notifications
You must be signed in to change notification settings - Fork 638
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
Use Sunrise/Sunset for scheduler #2417
Comments
I just read that the geo location API might only be available via HTTPS which is not the case for espurna, manual entry seems like the only option. |
Specific to this issue, idk if code actually does the correct thing. Given: double latitude { 55.752546226498275 };
double longitude { 37.61737956002365 }; float localT = calculateSunrise(2021, 1, 17, latitude, longitude, 0, 0); Output is:
Which is correct for the specified date (UTC, idk if it actually needs the correct 'timezone offset' for the coordinates), but swapping for the setting alternative (see comments), it does not work as well and shows 9:44 as sunset I'll try to implement wikipedia page at least locally. |
Another alternative would be the Arduino library SunRise, which seems to work fine in a quick test. |
It does work with current (2.7.4) gcc-4.8.2 toolchain, |
On topic, it matches the real (Google, same lat / long as above) values with -1 minute diff
|
Any new on this? I'd really need it! (for now I'm manually editing my schedlings every months or so to adjust opening and closing times for my roller shutter) |
Just a lack of time and focus on the issue. iirc, library above has the 'shortest' algorithm (loc wise :) Also see https://github.com/mfreeborn/heliocron |
Are you open to contributions for this point ? Thanks |
@brunetton Sure |
Alternativ you could have a look at ESPHome, which I have been using: Implementation here: |
thanks for link, I do remember looking at that too but forgot to include some reference here
this also reminds me of the mistake I made originally w/ SunRise, since that one definitely does not try to 'stabilize' the input timestamp and can't be expected to return the same value during the day |
- allow to specify year, month and day in addition to weekdays and time 2024-05-15 Monday 00:00 <=> runs *only* on May 15th 2024 year is optional, 05-15 <=> any May 15th on any year - last day of month, Nth week, reversed day-of-month (starting from last) *-W1 00:00 <==> run at midnight on the first week of month 01-L2 6:00 <==> run at six, but only on the second to last day of January 05-L 12:00 <==> run at twelve, but only on the last day of May - allow multiple time settings per schedule specified as ranges 12,13,14:00 <=> run at 12:00, 13:00 and 14:00 Friday..Sunday 12:00 <=> run at 12:00, but only only on Friday, Saturday and Sunday - similar to weekdays default, allow asterisk (*) to avoid using exact value *:30 <=> every hour at 30 minutes 10:* <=> every minute at 10 o'clock - repetition value for more control over steps between runs *:0/5 <==> every 5 minutes, starting with 0 0/2:00 <==> every 2 hours, starting with 0 - rework api and settings storage to use 1 key for time setting type and 'enabled' state moved into one - implement sunrise & sunset suggested in #2417 should be specified instead of HH:MM
btw I have scrapped that idea and just rewritten the scheduler based on systemd calendar spec. Sunrise/Sunset calc is disabled in default build, but added through
sry @brunetton if you intended to work on this (or used the original scheduler types, events, etc.) :) Since it is a pretty big slab of code all at once, have to test it a bit more before building the .bin Calc is taken from https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calculation_on_Earth, but as implemented in https://github.com/nathan-osman/go-sunrise (since it included code tests and saved me the work on those as well) For time strings, test/unit/src/scheduler/scheduler.cpp should give a general idea. At least for now. |
No problem, I didn't took time to solve this problem for now. Very happy to
see that something is being started :) Can't wait to use it from UI !
Thank you !
Le jeu. 16 mai 2024 à 00:45, Max Prokhorov ***@***.***> a
écrit :
… The idea is still to not re-write the schedule, but to create a new event
type that will replace the time of day one.
btw I have scrapped that idea and just rewritten the scheduler based on
systemd calendar spec. Disabled in default build, but added through
SCHEDULER_SUN_SUPPORT flag. Time specified would look something like this
for weekend sunrise action
schTime0 => Sat,Sun Sunrise
sry @brunetton <https://github.com/brunetton> if you intended to work on
this (or used the original scheduler types, events, etc.) :)
Since it is a pretty big slap of code all at once, have to test it a bit
more before building the .bin
Mind the size increase as well and missing documentation. WebUI also
missing, only build or manually setting schLat (latitude), schLong
(longitude) and schAlt (altitude)
test/unit/src/scheduler/scheduler.cpp
<https://github.com/xoseperez/espurna/blob/dev/code/test/unit/src/scheduler/scheduler.cpp>
strings should give a general idea, though.
Or, referencing systemd docs (base cases at least, not everything is the
same for last-day-of-week, etc.)
https://www.freedesktop.org/software/systemd/man/latest/systemd.time.html#Calendar%20Events
—
Reply to this email directly, view it on GitHub
<#2417 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAVCMXWPXMO3LXTMI37ZEDZCPQPHAVCNFSM4WF7U6K2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJRGM3DAMRYGIZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Wiki updated, WebUI updated. Optional restore flag also taken into an account, looping back N days and N sunrises and sunsets to check. Linked issues also describe offset for sunrise and sunset like 30min before, 1h after, etc., but pretty sure that would blow up the 'OnCalendar=...' time string chosen currently. Relative events like 'BOOT' maybe make sense to also add as a different type, but the list of such possible events does seem pretty short atm |
Hi,
It would be nice to have an option for the scheduler component based on sunrise/sunset with an additional offset like sunset +30 minutes.
Based on a quick search it should be possible to calculate sunrise/sunset in C++ with minimal code, stackoverlow example.
Is your feature request related to a problem? Please describe.
No
Describe the solution you'd like
The user enters the gps coordinates or maybe espurna uses the location api of the browser to allow additional scheduler options based on sunrise/sunset with an offset.
The precision of the gps does not need to be super accurate,
Describe alternatives you've considered
A possible alternative is to use homeassistant or another external component and trigger the switch via mqtt. But it would be nice for standalone solutions without external home automation components.
Thanks
The text was updated successfully, but these errors were encountered: