Skip to content

Commit

Permalink
scheduler: v2
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mcspr committed May 15, 2024
1 parent 58a4cc4 commit e4b6929
Show file tree
Hide file tree
Showing 9 changed files with 4,025 additions and 480 deletions.
27 changes: 21 additions & 6 deletions code/espurna/config/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -1382,19 +1382,34 @@
// -----------------------------------------------------------------------------

#ifndef SCHEDULER_SUPPORT
#define SCHEDULER_SUPPORT 1 // Enable scheduler (2.45Kb)
#define SCHEDULER_SUPPORT 1 // Enable scheduler (~13.7Kb)
#endif

#ifndef SCHEDULER_MAX_SCHEDULES
#define SCHEDULER_MAX_SCHEDULES 10 // Max schedules allowed
#define SCHEDULER_MAX_SCHEDULES 10 // Maximum number of configured schedules (both enabled or disabled)
#endif

#ifndef SCHEDULER_RESTORE_LAST_SCHEDULE
#define SCHEDULER_RESTORE_LAST_SCHEDULE 0 // Restore the last schedule state on the device boot
#ifndef SCHEDULER_RESTORE_DAYS
#define SCHEDULER_RESTORE_DAYS 1 // By default, restore routine would check 00:00..NOW and previous day 00:00..23:59
// When set to 0, would check only the 00:00..NOW
// (checks today and one day before by default)
#endif

#ifndef SCHEDULER_WEEKDAYS
#define SCHEDULER_WEEKDAYS "1,2,3,4,5,6,7" // (Default - Run the schedules every day)
#ifndef SCHEDULER_SUN_SUPPORT
#define SCHEDULER_SUN_SUPPORT 0 // Support 'sunrise' and 'sunset' time keywords
// (disabled by default, modify values below for device location)
#endif

#ifndef SCHEDULER_LATITUDE
#define SCHEDULER_LATITUDE 51.503399 // Required for sunrise and sunset calculation to work
#endif

#ifndef SCHEDULER_LONGITUDE
#define SCHEDULER_LONGITUDE -0.119519 // Required for sunrise and sunset calculation to work
#endif

#ifndef SCHEDULER_ALTITUDE
#define SCHEDULER_ALTITUDE 0.0 // Not necessary, but usually this produces a more precise time.
#endif

// -----------------------------------------------------------------------------
Expand Down
9 changes: 0 additions & 9 deletions code/espurna/config/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@
#define LIGHT_PROVIDER_DIMMER 2
#define LIGHT_PROVIDER_CUSTOM 3

// -----------------------------------------------------------------------------
// SCHEDULER
// -----------------------------------------------------------------------------

#define SCHEDULER_TYPE_NONE scheduler::Type::None
#define SCHEDULER_TYPE_RELAY scheduler::Type::Relay
#define SCHEDULER_TYPE_CHANNEL scheduler::Type::Channel
#define SCHEDULER_TYPE_CURTAIN scheduler::Type::Curtain

// -----------------------------------------------------------------------------
// IR
// -----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion code/espurna/config/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
#endif

#ifndef CFG_VERSION
#define CFG_VERSION 14
#define CFG_VERSION 15
#endif
Loading

0 comments on commit e4b6929

Please sign in to comment.