Write
Writing to points requires a Control API key.
Write
Writes a value to a writable point. Pass null as the
value to clear a priority hold and release control back to the next
level.
write(point_id, value, { level, expires })| Argument | Default | Description |
|---|---|---|
point_id |
— | Point ID (required) |
value |
— | Numeric value, or null to clear the priority hold
(required) |
level |
16 |
Priority level (1–16) |
expires |
— | Auto-release duration, e.g. "1hr",
"30min", "1day" |
Returns
An object with the result status:
{ proj_id: 4821, status: "ok" }Example
// write a value
const res = await client.write("s.2.4", 72.5);
console.log(res.status); // "ok"
// write at a specific priority level
await client.write("s.2.4", 70.0, { level: 8 });
// write that auto-releases after one hour
await client.write("s.2.4", 70.0, { expires: "1hr" });
// clear the priority hold
await client.write("s.2.4", null);Write Batch
Writes values to multiple points in a single request. Validation is all-or-nothing: if any entry is invalid the entire request is rejected and no writes are committed. See Write for the maximum number of writes per request.
writeBatch(writes)| Argument | Default | Description |
|---|---|---|
writes |
— | Array of write entries (required, non-empty) |
Each entry in writes is an object with the following
fields:
| Field | Required | Description |
|---|---|---|
point_id |
yes | Point ID |
value |
yes | Numeric value, or null to clear the priority hold |
level |
no | Priority level (1–16, defaults to 16) |
expires |
no | Auto-release duration, e.g. "1hr",
"30min", "1day" |
Returns
An object with the result status:
{ proj_id: 4821, status: "ok" }Example
const res = await client.writeBatch([
{ point_id: "s.1.3", value: 25.0, level: 8 },
{ point_id: "s.1.4", value: 20.0, expires: "1hr" },
]);
console.log(res.status); // "ok"