Files
node-intellicenter/messages/set-object-status.ts
Parnic abe9ba7d95 Rename Item to Object
The API all calls these objects so best to go with the flow.

This is a breaking change.
2025-01-05 11:56:53 -06:00

36 lines
852 B
TypeScript

import { ICParam } from "./param.js";
import { GetRequest, ICRequest, ICRequestObj } from "./request.js";
/**
* Requests to change the status of objects known to this controller.
*
* Turns one or more objects on or off. Use the `objnam` of the circuit to be set.
*
* @returns the object used to issue this request
*/
export function SetObjectStatus(
object: string | string[],
status: boolean,
): ICRequest {
const req = GetRequest();
req.command = "SetParamList";
req.objectList = [];
let objects: string[];
if (Array.isArray(object)) {
objects = object;
} else {
objects = [object];
}
for (const i of objects) {
const reqObj = new ICRequestObj();
reqObj.objnam = i;
reqObj.params = new ICParam();
reqObj.params.STATUS = status ? "ON" : "OFF";
req.objectList.push(reqObj);
}
return req;
}