mirror of
https://github.com/parnic/node-intellicenter.git
synced 2025-06-16 18:20:14 -05:00
Getting a feel for how the development experience is with this setup. With the previous idea of abstracting the request into a getSystemInfo() function on the Unit itself, the documentation for what to expect from GetSystemInfo either had to live in two places or be presented as a link to the canonical location. Neither felt great, so I think the caller can just call send(GetRequest()) themselves. Also added the first "set" message which is capable of toggling a body or circuit.
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { ICParam } from "./param.js";
|
|
import { GetRequest, ICRequest, ICRequestObj } from "./request.js";
|
|
|
|
/**
|
|
* Requests the status of bodies known to this controller.
|
|
*
|
|
* The response contains the list of bodies in the `params` field. Each body has
|
|
* an `objnam` that should be used to reference that body for future requests.
|
|
* When `params`.`STATUS` is `"OFF"`, use `params`.`LSTTMP` to get the temperature
|
|
* of the body the last time it was on, or `params`.`TEMP` to get the temperature
|
|
* if the `STATUS` is `"ON"`. `LSTTMP` seems to always be accurate, however, whether
|
|
* the body is currently on or off.
|
|
*
|
|
* @returns the object used to issue this request
|
|
*/
|
|
export function SetItemStatus(item: string, status: boolean): ICRequest {
|
|
const req = GetRequest();
|
|
req.command = "SetParamList";
|
|
req.objectList = [];
|
|
|
|
const reqObj = new ICRequestObj();
|
|
reqObj.objnam = item;
|
|
reqObj.params = new ICParam();
|
|
reqObj.params.STATUS = status ? "ON" : "OFF";
|
|
req.objectList.push(reqObj);
|
|
|
|
return req;
|
|
}
|