Novant

Documentation

Sign in

Scenes

Returns the scenes configured for this project. A scene is a named set of point target values organized into one or more modes (e.g. occupied / unoccupied). Pass scene_id to fetch a single scene. To add or update a scene, see importScene.

scenes({ scene_id })
Option Default Description
scene_id — Optional scene ID to fetch a single scene

Returns

SceneList with the following fields:

Field Type Description
proj_id number Project ID
scenes Scene[] Scenes in the response

Each Scene has:

Field Type Description
id string Scene ID
name string Scene name
point_ids string[] Point IDs associated with the scene
modes SceneMode[] Modes defined for the scene

Each SceneMode has:

Field Type Description
id string Mode ID, e.g. "sn.5.1"
name string Mode name (e.g. occupied)
vals object Map of point ID to target value

vals is a plain object keyed by point ID, so a target value is reached directly with mode.vals["s.5.9"].

Example

// all scenes
const { scenes } = await client.scenes();
for (const scene of scenes) {
  console.log(scene.id, scene.name);
  for (const mode of scene.modes) {
    console.log(" ", mode.name);
    for (const [pointId, val] of Object.entries(mode.vals)) {
      console.log("   ", pointId, val);
    }
  }
}

// a single scene, then a specific mode's target for a point
const res = await client.scenes({ scene_id: "sn.5" });
const occ = res.scenes[0].modes.find((m) => m.id === "sn.5.1");
console.log(occ.vals["s.5.9"]);   // 72.0

// resolve a mode ID (e.g. one referenced by a schedule's active_mode_ids)
const modes = scenes.flatMap((s) => s.modes);
const mode = modes.find((m) => m.id === "sn.5.1");
console.log(mode.name);           // "occupied"