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.

scenes(scene_id=None)
Argument Default Description
scene_id None Optional scene ID string to fetch a single scene

Returns

SceneList with the following attribute:

Attribute Type Description
scenes list[Scene] Scenes in the response

Each Scene has:

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

Each SceneMode has:

Attribute Type Description
id str Mode ID
name str Mode name (e.g. occupied)
vals dict[str, Any] Map of point ID to target value

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

Lookups & iteration

Call Returns
iter(scenes) iterate Scene entries
scenes.scene(id) a Scene by ID, or None
scenes.mode(id) resolve a full mode ID ("sn.5.1") to its SceneMode across all scenes, or None
iter(scene) iterate SceneMode entries
scene.mode(id) a SceneMode by full ID ("sn.5.1") or integer suffix (1), or None
iter(mode) iterate point IDs (the keys of vals)
mode[point_id] a target value by point ID (raises KeyError if absent)
mode.vals.get(id) a target value by point ID, or None

Example

# All scenes
for scene in client.scenes():
    print(scene.id, scene.name)
    for mode in scene:
        print(" ", mode.name)
        for point_id, val in mode.vals.items():
            print("   ", point_id, val)

# A single scene, then a specific mode's target for a point.
# A mode can be looked up by full id or by its integer id suffix.
scene = client.scenes(scene_id="sn.5").scene("sn.5")
occ   = scene.mode("sn.5.1")  # same as scene.mode(1)
print(occ.vals["s.5.9"])      # 72.0
print(occ["s.5.9"])           # 72.0

# Resolve a mode ID directly (e.g. one referenced by a schedule's
# active_mode_ids); the parent scene is derived from the ID.
mode = client.scenes().mode("sn.5.1")
print(mode.name)              # "occupied"