Schedules
Returns the schedules configured for this project. A schedule defines
occupancy rules (when it is active) and the scene modes applied when it
is active or inactive. Pass schedule_id to fetch a single
schedule. To add or update schedules, see importSchedules.
schedules({ schedule_id })| Option | Default | Description |
|---|---|---|
schedule_id |
— | Optional schedule ID to fetch a single schedule |
Returns
ScheduleList with the following fields:
| Field | Type | Description |
|---|---|---|
proj_id |
number |
Project ID |
schedules |
Schedule[] |
Schedules in the response |
Each Schedule has:
| Field | Type | Description |
|---|---|---|
id |
string |
Schedule ID |
name |
string |
Schedule name |
schedule |
string |
Schedule rules,
e.g. "weekdays 8:00-17:00, sat 9:00-12:00" |
active_mode_ids |
string[] |
Scene mode IDs applied when active |
inactive_mode_ids |
string[] |
Scene mode IDs applied when inactive |
The schedule string is a comma-separated list of
"<days> hh:mm-hh:mm" rules, where
<days> is weekdays, a single day
(mon..sun), or a contiguous range
(mon-fri). Ranges may wrap across the week, e.g.
fri-mon.
Evaluating Active State
scheduleActive(schedule, { now, tz, toleranceMs }) // -> booleanReturns true if now falls within any of the
schedule’s rules (start inclusive, end exclusive). schedule
may be a Schedule object or a raw schedule string.
| Option | Default | Description |
|---|---|---|
now |
new Date() |
Time to evaluate |
tz |
— | Timezone to evaluate in; defaults to the host’s local time |
toleranceMs |
— | Shifts each rule’s start earlier by this many milliseconds; the end is unchanged |
Schedules are defined in project local time, so pass the project’s
tz to evaluate them correctly from a server in another
timezone. tz accepts the project timezone
(e.g. New_York) or an IANA name
(e.g. America/New_York).
To decode the rules yourself,
parseSchedule(schedule.schedule) returns an array of
ScheduleRule objects with start_day and
end_day (0=Sun .. 6=Sat), and start and
end in minutes since midnight.
Example
import { scheduleActive } from "@novant/sdk";
const { tz } = await client.project();
const { schedules } = await client.schedules();
// is each schedule active right now, in project local time?
for (const sched of schedules) {
console.log(sched.name, scheduleActive(sched, { tz }));
}
// evaluate at a specific time
const sched = schedules.find((s) => s.id === "sch.1");
const when = new Date("2026-06-24T14:00:00Z"); // Wed 10:00 in New York
console.log(scheduleActive(sched, { now: when, tz: "New_York" })); // true
// with 30 minutes of tolerance (start shifted earlier; end unchanged)
scheduleActive(sched, { tz, toleranceMs: 30 * 60 * 1000 });
// the scene modes to apply based on state
const { scenes } = await client.scenes();
const modes = scenes.flatMap((s) => s.modes);
const ids = scheduleActive(sched, { tz })
? sched.active_mode_ids
: sched.inactive_mode_ids;
for (const id of ids) {
const mode = modes.find((m) => m.id === id);
console.log(mode.name, mode.vals);
}