Skip to content

Instantly share code, notes, and snippets.

@jasonwaters
Last active March 23, 2017 18:54
Show Gist options
  • Save jasonwaters/994dc36bc15a9a88a443df013720d117 to your computer and use it in GitHub Desktop.
Save jasonwaters/994dc36bc15a9a88a443df013720d117 to your computer and use it in GitHub Desktop.
blossom advanced schedule ideas
// right now i just get /weekly-recurring-blackouts/
// which returns an array of [12] arrays. Each sub array an array with 7 truthy values representing true if blacked out, false if scheduled
let blackout_response = [
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, true, true],
[false, true, false, true, false, false, true],
[false, true, false, true, false, false, true],
[false, true, false, true, false, false, true],
[false, true, false, false, true, false, true]
];
//we need an api to request schedule information for a date range /scheduled-zones-by-week/
//that api can just return an array of arrays again, like the blackouts endpoint
// OR we could write utilities to calculate watering days on client side?
// each zone needs a schedule object
const SCHEDULE_TYPE = {
FIXED: "Fixed",
INTERVAL: "Interval",
ODDEVEN: "OddEven"
};
let zoneSchedule = {
type: SCHEDULE_TYPE.FIXED,
blackouts: [false, true, false, true, false, false, true],
interval: {
every: 10,
startDate: '2016-10-12'
},
parity: 'ODD'
};
// Restrict watering times per controller
// controller.sch_start = '23:00' <-- used to set the schedule start time
// controller.sch_restrict = true/false
// controller.sch_restrict_time_start = '11:00
// controller.sch_restrict_time_end = '11:00
controller.sch_restrictions = [
{start: '11:00', end: '12:00'},
{start: '11:00', end: '12:00'},
];
// zone.next_watering_scheduled
// zone.last_watering_completed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment