From 7daf47ac189041d6e0383454d5600d164b1b097b Mon Sep 17 00:00:00 2001 From: Parnic Date: Fri, 3 Jan 2025 16:01:58 -0600 Subject: [PATCH] Fleshing out more messages 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. --- connection-logs/turn-body-on.log | 2 + dist/index.js | 20 ++++- dist/index.js.map | 2 +- dist/messages/body-status.d.ts | 14 ++++ dist/messages/body-status.js | 27 ++++++ dist/messages/body-status.js.map | 1 + dist/messages/configuration.d.ts | 15 ++++ dist/messages/configuration.js | 22 +++++ dist/messages/configuration.js.map | 1 + dist/messages/param.d.ts | 123 ++++++++++++++++++++++++++++ dist/messages/param.js | 125 ++++++++++++++++++++++++++++ dist/messages/param.js.map | 1 + dist/messages/request.d.ts | 2 + dist/messages/request.js | 1 + dist/messages/request.js.map | 2 +- dist/messages/response.d.ts | 126 +--------------------------- dist/messages/response.js | 124 ---------------------------- dist/messages/response.js.map | 2 +- dist/messages/set-status.d.ts | 14 ++++ dist/messages/set-status.js | 26 ++++++ dist/messages/set-status.js.map | 1 + dist/unit.d.ts | 1 - dist/unit.js | 5 -- dist/unit.js.map | 2 +- index.ts | 27 +++++- messages/body-status.ts | 29 +++++++ messages/configuration.ts | 23 ++++++ messages/param.ts | 124 ++++++++++++++++++++++++++++ messages/request.ts | 2 + messages/response.ts | 127 +---------------------------- messages/set-status.ts | 28 +++++++ unit.ts | 6 -- 32 files changed, 634 insertions(+), 391 deletions(-) create mode 100644 connection-logs/turn-body-on.log create mode 100644 dist/messages/body-status.d.ts create mode 100644 dist/messages/body-status.js create mode 100644 dist/messages/body-status.js.map create mode 100644 dist/messages/configuration.d.ts create mode 100644 dist/messages/configuration.js create mode 100644 dist/messages/configuration.js.map create mode 100644 dist/messages/param.d.ts create mode 100644 dist/messages/param.js create mode 100644 dist/messages/param.js.map create mode 100644 dist/messages/set-status.d.ts create mode 100644 dist/messages/set-status.js create mode 100644 dist/messages/set-status.js.map create mode 100644 messages/body-status.ts create mode 100644 messages/configuration.ts create mode 100644 messages/param.ts create mode 100644 messages/set-status.ts diff --git a/connection-logs/turn-body-on.log b/connection-logs/turn-body-on.log new file mode 100644 index 0000000..edd0881 --- /dev/null +++ b/connection-logs/turn-body-on.log @@ -0,0 +1,2 @@ +[OUTGOING] {"command":"SetParamList","objectList":[{"objnam":"B1101","params":{"STATUS":"ON"}}],"messageID":"B1101"} +[INCOMING] {"command":"SetParamList","messageID":"B1101","response":"200"} diff --git a/dist/index.js b/dist/index.js index dbf1be6..debf2e8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,9 @@ "use strict"; import { FindUnits } from "./finder.js"; +import { GetBodyStatus } from "./messages/body-status.js"; +import { GetSystemConfiguration } from "./messages/configuration.js"; +// import { SetItemStatus } from "./messages/set-status.js"; +import { GetSystemInfoRequest } from "./messages/system-info.js"; import { Unit } from "./unit.js"; console.log("searching..."); const f = new FindUnits(); @@ -14,12 +18,26 @@ if (units.length > 1) { } const endpoint = units[0].addressStr; const port = units[0].port; +// const endpoint = "10.0.0.41"; +// const port = 6680; console.log("connecting to intellicenter device at", endpoint, "port", port); const unit = new Unit(endpoint, port); await unit.connect(); console.log("connected"); console.log("sending Get System Info request..."); -const resp = await unit.getSystemInfo(); +let resp = await unit.send(GetSystemInfoRequest()); console.log("got response:", JSON.stringify(resp, null, 2)); +console.log("sending Get System Config request..."); +resp = await unit.send(GetSystemConfiguration()); +console.log("got response:", JSON.stringify(resp, null, 2)); +console.log("sending Get Body Status request..."); +resp = await unit.send(GetBodyStatus()); +console.log("got response:", JSON.stringify(resp, null, 2)); +// console.log("turning off pool..."); +// resp = await unit.send(SetItemStatus("B1101", false)); +// console.log("got response:", JSON.stringify(resp, null, 2)); +// console.log("turning off water feature..."); +// resp = await unit.send(SetItemStatus("C0003", false)); +// console.log("got response:", JSON.stringify(resp, null, 2)); unit.close(); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index e3807d3..f7ebfea 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AAC5B,MAAM,CAAC,GAAG,IAAI,SAAS,EAAE,CAAC;AAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC,CAAC,KAAK,EAAE,CAAC;AACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;AAExC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IACvB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC;AAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IACrB,MAAM,IAAI,KAAK,CACb,oEAAoE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAC5F,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAE3B,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAC7E,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACtC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;AACrB,OAAO,C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"} \ No newline at end of file diff --git a/dist/messages/body-status.d.ts b/dist/messages/body-status.d.ts new file mode 100644 index 0000000..d2996fb --- /dev/null +++ b/dist/messages/body-status.d.ts @@ -0,0 +1,14 @@ +import { ICRequest } 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 declare function GetBodyStatus(): ICRequest; diff --git a/dist/messages/body-status.js b/dist/messages/body-status.js new file mode 100644 index 0000000..f20b291 --- /dev/null +++ b/dist/messages/body-status.js @@ -0,0 +1,27 @@ +import { GetRequest, 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 GetBodyStatus() { + const req = GetRequest(); + req.command = "GetParamList"; + req.condition = "OBJTYP = BODY"; + req.objectList = []; + const reqObj = new ICRequestObj(); + reqObj.objnam = "ALL"; + reqObj.keys = [ + "OBJTYP: SUBTYP: SNAME: LISTORD: FILTER: LOTMP: TEMP: HITMP: HTSRC: PRIM: SEC: ACT1: ACT2: ACT3: ACT4: CIRCUIT: SPEED: BOOST: SELECT: STATUS: HTMODE : LSTTMP : HEATER : VOL : MANUAL : HNAME : MODE", + ]; + req.objectList.push(reqObj); + return req; +} +//# sourceMappingURL=body-status.js.map \ No newline at end of file diff --git a/dist/messages/body-status.js.map b/dist/messages/body-status.js.map new file mode 100644 index 0000000..247b921 --- /dev/null +++ b/dist/messages/body-status.js.map @@ -0,0 +1 @@ +{"version":3,"file":"body-status.js","sourceRoot":"","sources":["../../messages/body-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,GAAG,CAAC,OAAO,GAAG,cAAc,CAAC;IAC7B,GAAG,CAAC,SAAS,GAAG,eAAe,CAAC;IAChC,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC;IAEpB,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;IAClC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,MAAM,CAAC,IAAI,GAAG;QACZ,qMAAqM;KACtM,CAAC;IACF,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file diff --git a/dist/messages/configuration.d.ts b/dist/messages/configuration.d.ts new file mode 100644 index 0000000..6184aa1 --- /dev/null +++ b/dist/messages/configuration.d.ts @@ -0,0 +1,15 @@ +import { ICRequest } from "./request.js"; +/** + * Requests the configuration of bodies and circuits available to this controller. + * + * The response contains the list of bodies and circuits under the `answer` field. + * Each item has an `objnam` that should be used to reference that item for future requests, + * and `params`.`SNAME` is the user-entered friendly name that can be displayed for the item. + * `params`.`OBJTYP` will be either BODY or CIRCUIT depending on the item it's describing. + * + * Some items, such as the Pool body, will have the `params`.`OBJLIST` array populated with + * a series of attached items such as a chlorinator device. + * + * @returns the object used to issue this request + */ +export declare function GetSystemConfiguration(): ICRequest; diff --git a/dist/messages/configuration.js b/dist/messages/configuration.js new file mode 100644 index 0000000..af08f9f --- /dev/null +++ b/dist/messages/configuration.js @@ -0,0 +1,22 @@ +import { GetRequest } from "./request.js"; +/** + * Requests the configuration of bodies and circuits available to this controller. + * + * The response contains the list of bodies and circuits under the `answer` field. + * Each item has an `objnam` that should be used to reference that item for future requests, + * and `params`.`SNAME` is the user-entered friendly name that can be displayed for the item. + * `params`.`OBJTYP` will be either BODY or CIRCUIT depending on the item it's describing. + * + * Some items, such as the Pool body, will have the `params`.`OBJLIST` array populated with + * a series of attached items such as a chlorinator device. + * + * @returns the object used to issue this request + */ +export function GetSystemConfiguration() { + const req = GetRequest(); + req.command = "GetQuery"; + req.queryName = "GetConfiguration"; + req.arguments = ""; + return req; +} +//# sourceMappingURL=configuration.js.map \ No newline at end of file diff --git a/dist/messages/configuration.js.map b/dist/messages/configuration.js.map new file mode 100644 index 0000000..4ce2545 --- /dev/null +++ b/dist/messages/configuration.js.map @@ -0,0 +1 @@ +{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../messages/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC;IACzB,GAAG,CAAC,SAAS,GAAG,kBAAkB,CAAC;IACnC,GAAG,CAAC,SAAS,GAAG,EAAE,CAAC;IAEnB,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file diff --git a/dist/messages/param.d.ts b/dist/messages/param.d.ts new file mode 100644 index 0000000..eb40ffb --- /dev/null +++ b/dist/messages/param.d.ts @@ -0,0 +1,123 @@ +export declare class ICParam { + ABSMAX?: string; + ABSMIN?: string; + ACT?: string; + ACT1?: string; + ACT2?: string; + ACT3?: string; + ACT4?: string; + ADDRESS?: string; + ALK?: string; + AVAIL?: "AVAIL" | "ON" | "OFF"; + BADGE?: string; + BODY?: string; + BOOST?: string; + CALC?: string; + CALIB?: string; + CHILD?: string; + CIRCUIT?: string; + CITY?: string; + CLK24A?: string; + COMUART?: string; + COOL?: string; + COUNT?: string; + COUNTRY?: string; + CYACID?: string; + DAY?: string; + DLSTIM?: "DLSTIM" | "ON" | "OFF"; + DLY?: string; + DNTSTP?: string; + EMAIL?: string; + EMAIL2?: string; + ENABLE?: "ENABLE" | "ON" | "OFF"; + FEATR?: string; + FILTER?: string; + FREEZE?: string; + GPM?: string; + HEATER?: string; + HEATING?: "HEATING" | "ON" | "OFF"; + HITMP?: string; + HNAME?: string; + HTMODE?: string; + HTSRC?: string; + IN?: string; + LIMIT?: string; + LISTORD?: string; + LOCX?: string; + LOCY?: string; + LOTMP?: string; + LSTTMP?: string; + MANHT?: "MANHT" | "ON" | "OFF"; + MANOVR?: "MANOVR" | "ON" | "OFF"; + MANUAL?: string; + MAX?: string; + MAXF?: string; + MIN?: string; + MINF?: string; + MODE?: string; + NAME?: string; + OBJLIST?: ICParam[]; + OBJNAM?: string; + OBJTYP?: string; + OFFSET?: string; + ORPSET?: string; + ORPTNK?: string; + ORPVAL?: string; + PARENT?: string; + PARTY?: string; + PASSWRD?: string; + PERMIT?: string; + PHONE?: string; + PHONE2?: string; + PHSET?: string; + PHTNK?: string; + PHVAL?: string; + PRIM?: string; + PRIMFLO?: string; + PRIMTIM?: string; + PRIOR?: string; + PROBE?: string; + PROPNAME?: string; + PWR?: string; + QUALTY?: string; + READY?: string; + RLY?: string; + RPM?: string; + SALT?: string; + SEC?: string; + SELECT?: string; + SERVICE?: "SERVICE" | "AUTO" | "TIMEOUT"; + SETTMP?: string; + SETTMPNC?: string; + SHARE?: string; + SHOMNU?: string; + SINDEX?: string; + SNAME?: string; + SOURCE?: string; + SPEED?: string; + SRIS?: string; + SSET?: string; + START?: string; + STATE?: string; + STATIC?: string; + STATUS?: "STATUS" | "ON" | "OFF"; + STOP?: string; + SUBTYP?: string; + SUPER?: "SUPER" | "ON" | "OFF"; + SWIM?: string; + SYNC?: string; + SYSTIM?: string; + TEMP?: string; + TIME?: string; + TIMOUT?: string; + TIMZON?: string; + UPDATE?: string; + USAGE?: string; + USE?: string; + VACFLO?: "VACFLO" | "ON" | "OFF"; + VACTIM?: "VACTIM" | "ON" | "OFF"; + VALVE?: "VALVE" | "ON" | "OFF"; + VER?: string; + VOL?: string; + ZIP?: string; +} diff --git a/dist/messages/param.js b/dist/messages/param.js new file mode 100644 index 0000000..3e3bb8b --- /dev/null +++ b/dist/messages/param.js @@ -0,0 +1,125 @@ +export class ICParam { + // "": "PROGRESS"; + ABSMAX; + ABSMIN; + ACT; + ACT1; + ACT2; + ACT3; + ACT4; + ADDRESS; + ALK; + AVAIL; + BADGE; + BODY; + BOOST; + CALC; + CALIB; + CHILD; + CIRCUIT; + CITY; + CLK24A; + COMUART; + COOL; + COUNT; + COUNTRY; + CYACID; + DAY; + DLSTIM; + DLY; + DNTSTP; + EMAIL; + EMAIL2; + ENABLE; + FEATR; + FILTER; + FREEZE; + GPM; + HEATER; + HEATING; + HITMP; + HNAME; + HTMODE; + HTSRC; + IN; + LIMIT; + LISTORD; + LOCX; + LOCY; + LOTMP; + LSTTMP; + MANHT; + MANOVR; + MANUAL; + MAX; + MAXF; + MIN; + MINF; + MODE; + NAME; + OBJLIST; + OBJNAM; + OBJTYP; + OFFSET; + ORPSET; + ORPTNK; + ORPVAL; + PARENT; + PARTY; + PASSWRD; + PERMIT; + PHONE; + PHONE2; + PHSET; + PHTNK; + PHVAL; + PRIM; + PRIMFLO; + PRIMTIM; + PRIOR; + PROBE; + PROPNAME; + PWR; + QUALTY; + READY; + RLY; + RPM; + SALT; + SEC; + SELECT; + SERVICE; + SETTMP; + SETTMPNC; + SHARE; + SHOMNU; + SINDEX; + SNAME; + SOURCE; + SPEED; + SRIS; + SSET; + START; + STATE; + STATIC; + STATUS; + STOP; + SUBTYP; + SUPER; + SWIM; + SYNC; + SYSTIM; + TEMP; + TIME; + TIMOUT; + TIMZON; + UPDATE; + USAGE; + USE; + VACFLO; + VACTIM; + VALVE; + VER; + VOL; + ZIP; +} +//# sourceMappingURL=param.js.map \ No newline at end of file diff --git a/dist/messages/param.js.map b/dist/messages/param.js.map new file mode 100644 index 0000000..85c0151 --- /dev/null +++ b/dist/messages/param.js.map @@ -0,0 +1 @@ +{"version":3,"file":"param.js","sourceRoot":"","sources":["../../messages/param.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IAClB,kBAAkB;IACX,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,GAAG,CAAU;IACb,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,OAAO,CAAU;IACjB,GAAG,CAAU;IACb,KAAK,CAA0B;IAC/B,KAAK,CAAU;IACf,IAAI,CAAU;IACd,KAAK,CAAU;IACf,IAAI,CAAU;IACd,KAAK,CAAU;IACf,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,OAAO,CAAU;IACjB,IAAI,CAAU;IACd,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,MAAM,CAAU;IAChB,GAAG,CAAU;IACb,MAAM,CAA2B;IACjC,GAAG,CAAU;IACb,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAA2B;IACjC,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,GAAG,CAAU;IACb,MAAM,CAAU;IAChB,OAAO,CAA4B;IACnC,KAAK,CAAU;IACf,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,EAAE,CAAU;IACZ,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,IAAI,CAAU;IACd,IAAI,CAAU;IACd,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,KAAK,CAA0B;IAC/B,MAAM,CAA2B;IACjC,MAAM,CAAU;IAChB,GAAG,CAAU;IACb,IAAI,CAAU;IACd,GAAG,CAAU;IACb,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,OAAO,CAAa;IACpB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,KAAK,CAAU;IACf,KAAK,CAAU;IACf,IAAI,CAAU;IACd,OAAO,CAAU;IACjB,OAAO,CAAU;IACjB,KAAK,CAAU;IACf,KAAK,CAAU;IACf,QAAQ,CAAU;IAClB,GAAG,CAAU;IACb,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,GAAG,CAAU;IACb,GAAG,CAAU;IACb,IAAI,CAAU;IACd,GAAG,CAAU;IACb,MAAM,CAAU;IAChB,OAAO,CAAkC;IACzC,MAAM,CAAU;IAChB,QAAQ,CAAU;IAClB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,IAAI,CAAU;IACd,IAAI,CAAU;IACd,KAAK,CAAU;IACf,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAA2B;IACjC,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,KAAK,CAA0B;IAC/B,IAAI,CAAU;IACd,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,GAAG,CAAU;IACb,MAAM,CAA2B;IACjC,MAAM,CAA2B;IACjC,KAAK,CAA0B;IAC/B,GAAG,CAAU;IACb,GAAG,CAAU;IACb,GAAG,CAAU;CACrB"} \ No newline at end of file diff --git a/dist/messages/request.d.ts b/dist/messages/request.d.ts index bdc2416..4823bcc 100644 --- a/dist/messages/request.d.ts +++ b/dist/messages/request.d.ts @@ -1,6 +1,8 @@ +import { ICParam } from "./param.js"; export declare class ICRequestObj { objnam: string; keys: string[]; + params?: ICParam; } export declare class ICRequest { condition?: string; diff --git a/dist/messages/request.js b/dist/messages/request.js index fa45b00..546a68a 100644 --- a/dist/messages/request.js +++ b/dist/messages/request.js @@ -2,6 +2,7 @@ import { v4 as uuidv4 } from "uuid"; export class ICRequestObj { objnam = ""; keys = []; + params; } export class ICRequest { condition; diff --git a/dist/messages/request.js.map b/dist/messages/request.js.map index 68e57e5..eda5746 100644 --- a/dist/messages/request.js.map +++ b/dist/messages/request.js.map @@ -1 +1 @@ -{"version":3,"file":"request.js","sourceRoot":"","sources":["../../messages/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,OAAO,YAAY;IAChB,MAAM,GAAG,EAAE,CAAC;IACZ,IAAI,GAAa,EAAE,CAAC;CAC5B;AAED,MAAM,OAAO,SAAS;IACb,SAAS,CAAU;IACnB,UAAU,CAAkB;IAC5B,SAAS,CAAU;IACnB,SAAS,CAAqB;IAC9B,OAAO,GAAG,EAAE,CAAC;IACb,SAAS,GAAG,EAAE,CAAC;CACvB;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;IAC5B,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file +{"version":3,"file":"request.js","sourceRoot":"","sources":["../../messages/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpC,MAAM,OAAO,YAAY;IAChB,MAAM,GAAG,EAAE,CAAC;IACZ,IAAI,GAAa,EAAE,CAAC;IACpB,MAAM,CAAW;CACzB;AAED,MAAM,OAAO,SAAS;IACb,SAAS,CAAU;IACnB,UAAU,CAAkB;IAC5B,SAAS,CAAU;IACnB,SAAS,CAAqB;IAC9B,OAAO,GAAG,EAAE,CAAC;IACb,SAAS,GAAG,EAAE,CAAC;CACvB;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,GAAG,GAAG,IAAI,SAAS,EAAE,CAAC;IAC5B,GAAG,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file diff --git a/dist/messages/response.d.ts b/dist/messages/response.d.ts index 4f6986d..2feeeb9 100644 --- a/dist/messages/response.d.ts +++ b/dist/messages/response.d.ts @@ -1,129 +1,7 @@ -export declare class ICResponseParam { - ABSMAX?: string; - ABSMIN?: string; - ACT?: string; - ACT1?: string; - ACT2?: string; - ACT3?: string; - ACT4?: string; - ADDRESS?: string; - ALK?: string; - AVAIL?: "AVAIL" | "ON" | "OFF"; - BADGE?: string; - BODY?: string; - BOOST?: string; - CALC?: string; - CALIB?: string; - CHILD?: string; - CIRCUIT?: string; - CITY?: string; - CLK24A?: string; - COMUART?: string; - COOL?: string; - COUNT?: string; - COUNTRY?: string; - CYACID?: string; - DAY?: string; - DLSTIM?: "DLSTIM" | "ON" | "OFF"; - DLY?: string; - DNTSTP?: string; - EMAIL?: string; - EMAIL2?: string; - ENABLE?: "ENABLE" | "ON" | "OFF"; - FEATR?: string; - FILTER?: string; - FREEZE?: string; - GPM?: string; - HEATER?: string; - HEATING?: "HEATING" | "ON" | "OFF"; - HITMP?: string; - HNAME?: string; - HTMODE?: string; - HTSRC?: string; - IN?: string; - LIMIT?: string; - LISTORD?: string; - LOCX?: string; - LOCY?: string; - LOTMP?: string; - LSTTMP?: string; - MANHT?: "MANHT" | "ON" | "OFF"; - MANOVR?: "MANOVR" | "ON" | "OFF"; - MANUAL?: string; - MAX?: string; - MAXF?: string; - MIN?: string; - MINF?: string; - MODE?: string; - NAME?: string; - OBJLIST?: ICResponseParam[]; - OBJNAM?: string; - OBJTYP?: string; - OFFSET?: string; - ORPSET?: string; - ORPTNK?: string; - ORPVAL?: string; - PARENT?: string; - PARTY?: string; - PASSWRD?: string; - PERMIT?: string; - PHONE?: string; - PHONE2?: string; - PHSET?: string; - PHTNK?: string; - PHVAL?: string; - PRIM?: string; - PRIMFLO?: string; - PRIMTIM?: string; - PRIOR?: string; - PROBE?: string; - PROPNAME?: string; - PWR?: string; - QUALTY?: string; - READY?: string; - RLY?: string; - RPM?: string; - SALT?: string; - SEC?: string; - SELECT?: string; - SERVICE?: "SERVICE" | "AUTO" | "TIMEOUT"; - SETTMP?: string; - SETTMPNC?: string; - SHARE?: string; - SHOMNU?: string; - SINDEX?: string; - SNAME?: string; - SOURCE?: string; - SPEED?: string; - SRIS?: string; - SSET?: string; - START?: string; - STATE?: string; - STATIC?: string; - STATUS?: string; - STOP?: string; - SUBTYP?: string; - SUPER?: "SUPER" | "ON" | "OFF"; - SWIM?: string; - SYNC?: string; - SYSTIM?: string; - TEMP?: string; - TIME?: string; - TIMOUT?: string; - TIMZON?: string; - UPDATE?: string; - USAGE?: string; - USE?: string; - VACFLO?: "VACFLO" | "ON" | "OFF"; - VACTIM?: "VACTIM" | "ON" | "OFF"; - VALVE?: "VALVE" | "ON" | "OFF"; - VER?: string; - VOL?: string; - ZIP?: string; -} +import { ICParam } from "./param.js"; export declare class ICResponseObj { objnam: string; - params?: ICResponseParam; + params?: ICParam; } export declare class ICResponse { command: string; diff --git a/dist/messages/response.js b/dist/messages/response.js index cfc269d..7d68c3a 100644 --- a/dist/messages/response.js +++ b/dist/messages/response.js @@ -1,127 +1,3 @@ -export class ICResponseParam { - // "": "PROGRESS"; - ABSMAX; - ABSMIN; - ACT; - ACT1; - ACT2; - ACT3; - ACT4; - ADDRESS; - ALK; - AVAIL; - BADGE; - BODY; - BOOST; - CALC; - CALIB; - CHILD; - CIRCUIT; - CITY; - CLK24A; - COMUART; - COOL; - COUNT; - COUNTRY; - CYACID; - DAY; - DLSTIM; - DLY; - DNTSTP; - EMAIL; - EMAIL2; - ENABLE; - FEATR; - FILTER; - FREEZE; - GPM; - HEATER; - HEATING; - HITMP; - HNAME; - HTMODE; - HTSRC; - IN; - LIMIT; - LISTORD; - LOCX; - LOCY; - LOTMP; - LSTTMP; - MANHT; - MANOVR; - MANUAL; - MAX; - MAXF; - MIN; - MINF; - MODE; - NAME; - OBJLIST; - OBJNAM; - OBJTYP; - OFFSET; - ORPSET; - ORPTNK; - ORPVAL; - PARENT; - PARTY; - PASSWRD; - PERMIT; - PHONE; - PHONE2; - PHSET; - PHTNK; - PHVAL; - PRIM; - PRIMFLO; - PRIMTIM; - PRIOR; - PROBE; - PROPNAME; - PWR; - QUALTY; - READY; - RLY; - RPM; - SALT; - SEC; - SELECT; - SERVICE; - SETTMP; - SETTMPNC; - SHARE; - SHOMNU; - SINDEX; - SNAME; - SOURCE; - SPEED; - SRIS; - SSET; - START; - STATE; - STATIC; - STATUS; - STOP; - SUBTYP; - SUPER; - SWIM; - SYNC; - SYSTIM; - TEMP; - TIME; - TIMOUT; - TIMZON; - UPDATE; - USAGE; - USE; - VACFLO; - VACTIM; - VALVE; - VER; - VOL; - ZIP; -} export class ICResponseObj { objnam = ""; params; diff --git a/dist/messages/response.js.map b/dist/messages/response.js.map index 785c902..0a356ff 100644 --- a/dist/messages/response.js.map +++ b/dist/messages/response.js.map @@ -1 +1 @@ -{"version":3,"file":"response.js","sourceRoot":"","sources":["../../messages/response.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAC1B,kBAAkB;IACX,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,GAAG,CAAU;IACb,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,IAAI,CAAU;IACd,OAAO,CAAU;IACjB,GAAG,CAAU;IACb,KAAK,CAA0B;IAC/B,KAAK,CAAU;IACf,IAAI,CAAU;IACd,KAAK,CAAU;IACf,IAAI,CAAU;IACd,KAAK,CAAU;IACf,KAAK,CAAU;IACf,OAAO,CAAU;IACjB,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,OAAO,CAAU;IACjB,IAAI,CAAU;IAC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;IACf,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,IAAI,CAAU;IACd,IAAI,CAAU;IACd,KAAK,CAAU;IACf,KAAK,CAAU;IACf,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,KAAK,CAA0B;IAC/B,IAAI,CAAU;IACd,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,IAAI,CAAU;IACd,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,GAAG,CAAU;IACb,MAAM,CAA2B;IACjC,MAAM,CAA2B;IACjC,KAAK,CAA0B;IAC/B,GAAG,CAAU;IACb,GAAG,CAAU;IACb,GAAG,CAAU;CACrB;AAED,MAAM,OAAO,aAAa;IACjB,MAAM,GAAG,EAAE,CAAC;IACZ,MAAM,CAAmB;CACjC;AAED,MAAM,OAAO,UAAU;IACd,OAAO,GAAG,EAAE,CAAC;IACb,SAAS,GAAG,EAAE,CAAC;IACf,QAAQ,GAAG,EAAE,CAAC;IACd,UAAU,CAAmB;IAC7B,SAAS,CAAU;IACnB,MAAM,CAAmB;IACzB,SAAS,CAAU;IACnB,OAAO,CAAU;CACzB"} \ No newline at end of file +{"version":3,"file":"response.js","sourceRoot":"","sources":["../../messages/response.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACjB,MAAM,GAAG,EAAE,CAAC;IACZ,MAAM,CAAW;CACzB;AAED,MAAM,OAAO,UAAU;IACd,OAAO,GAAG,EAAE,CAAC;IACb,SAAS,GAAG,EAAE,CAAC;IACf,QAAQ,GAAG,EAAE,CAAC;IACd,UAAU,CAAmB;IAC7B,SAAS,CAAU;IACnB,MAAM,CAAmB;IACzB,SAAS,CAAU;IACnB,OAAO,CAAU;CACzB"} \ No newline at end of file diff --git a/dist/messages/set-status.d.ts b/dist/messages/set-status.d.ts new file mode 100644 index 0000000..5822394 --- /dev/null +++ b/dist/messages/set-status.d.ts @@ -0,0 +1,14 @@ +import { ICRequest } 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 declare function SetItemStatus(item: string, status: boolean): ICRequest; diff --git a/dist/messages/set-status.js b/dist/messages/set-status.js new file mode 100644 index 0000000..53073f7 --- /dev/null +++ b/dist/messages/set-status.js @@ -0,0 +1,26 @@ +import { ICParam } from "./param.js"; +import { GetRequest, 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, status) { + 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; +} +//# sourceMappingURL=set-status.js.map \ No newline at end of file diff --git a/dist/messages/set-status.js.map b/dist/messages/set-status.js.map new file mode 100644 index 0000000..9166ae2 --- /dev/null +++ b/dist/messages/set-status.js.map @@ -0,0 +1 @@ +{"version":3,"file":"set-status.js","sourceRoot":"","sources":["../../messages/set-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AAEnE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,MAAe;IACzD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,GAAG,CAAC,OAAO,GAAG,cAAc,CAAC;IAC7B,GAAG,CAAC,UAAU,GAAG,EAAE,CAAC;IAEpB,MAAM,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;IAClC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7C,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,GAAG,CAAC;AACb,CAAC"} \ No newline at end of file diff --git a/dist/unit.d.ts b/dist/unit.d.ts index 9b656c6..666a3b9 100644 --- a/dist/unit.d.ts +++ b/dist/unit.d.ts @@ -12,5 +12,4 @@ export declare class Unit extends EventEmitter { private heartbeat; private onClientMessage; send(request: ICRequest): Promise; - getSystemInfo(): Promise; } diff --git a/dist/unit.js b/dist/unit.js index 61bbfde..5f2d198 100644 --- a/dist/unit.js +++ b/dist/unit.js @@ -1,6 +1,5 @@ import { EventEmitter } from "events"; import { WebSocket } from "ws"; -import { GetSystemInfoRequest } from "./messages/system-info.js"; export class Unit extends EventEmitter { endpoint; port; @@ -54,9 +53,5 @@ export class Unit extends EventEmitter { }); }); } - async getSystemInfo() { - const req = GetSystemInfoRequest(); - return await this.send(req); - } } //# sourceMappingURL=unit.js.map \ No newline at end of file diff --git a/dist/unit.js.map b/dist/unit.js.map index a9dd71b..2e4e605 100644 --- a/dist/unit.js.map +++ b/dist/unit.js.map @@ -1 +1 @@ -{"version":3,"file":"unit.js","sourceRoot":"","sources":["../unit.ts"],"names":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AAC,OAAO,EAAE,EAAE;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,IAAgB,EAAE,EAAE;gBAC9D,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"} \ No newline at end of file diff --git a/index.ts b/index.ts index 491be01..1141012 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,10 @@ "use strict"; import { FindUnits } from "./finder.js"; +import { GetBodyStatus } from "./messages/body-status.js"; +import { GetSystemConfiguration } from "./messages/configuration.js"; +// import { SetItemStatus } from "./messages/set-status.js"; +import { GetSystemInfoRequest } from "./messages/system-info.js"; import { Unit } from "./unit.js"; console.log("searching..."); @@ -22,11 +26,32 @@ if (units.length > 1) { const endpoint = units[0].addressStr; const port = units[0].port; +// const endpoint = "10.0.0.41"; +// const port = 6680; + console.log("connecting to intellicenter device at", endpoint, "port", port); const unit = new Unit(endpoint, port); await unit.connect(); console.log("connected"); + console.log("sending Get System Info request..."); -const resp = await unit.getSystemInfo(); +let resp = await unit.send(GetSystemInfoRequest()); console.log("got response:", JSON.stringify(resp, null, 2)); + +console.log("sending Get System Config request..."); +resp = await unit.send(GetSystemConfiguration()); +console.log("got response:", JSON.stringify(resp, null, 2)); + +console.log("sending Get Body Status request..."); +resp = await unit.send(GetBodyStatus()); +console.log("got response:", JSON.stringify(resp, null, 2)); + +// console.log("turning off pool..."); +// resp = await unit.send(SetItemStatus("B1101", false)); +// console.log("got response:", JSON.stringify(resp, null, 2)); + +// console.log("turning off water feature..."); +// resp = await unit.send(SetItemStatus("C0003", false)); +// console.log("got response:", JSON.stringify(resp, null, 2)); + unit.close(); diff --git a/messages/body-status.ts b/messages/body-status.ts new file mode 100644 index 0000000..3ecba53 --- /dev/null +++ b/messages/body-status.ts @@ -0,0 +1,29 @@ +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 GetBodyStatus(): ICRequest { + const req = GetRequest(); + req.command = "GetParamList"; + req.condition = "OBJTYP = BODY"; + req.objectList = []; + + const reqObj = new ICRequestObj(); + reqObj.objnam = "ALL"; + reqObj.keys = [ + "OBJTYP: SUBTYP: SNAME: LISTORD: FILTER: LOTMP: TEMP: HITMP: HTSRC: PRIM: SEC: ACT1: ACT2: ACT3: ACT4: CIRCUIT: SPEED: BOOST: SELECT: STATUS: HTMODE : LSTTMP : HEATER : VOL : MANUAL : HNAME : MODE", + ]; + req.objectList.push(reqObj); + + return req; +} diff --git a/messages/configuration.ts b/messages/configuration.ts new file mode 100644 index 0000000..2e9e9e5 --- /dev/null +++ b/messages/configuration.ts @@ -0,0 +1,23 @@ +import { GetRequest, ICRequest } from "./request.js"; + +/** + * Requests the configuration of bodies and circuits available to this controller. + * + * The response contains the list of bodies and circuits under the `answer` field. + * Each item has an `objnam` that should be used to reference that item for future requests, + * and `params`.`SNAME` is the user-entered friendly name that can be displayed for the item. + * `params`.`OBJTYP` will be either BODY or CIRCUIT depending on the item it's describing. + * + * Some items, such as the Pool body, will have the `params`.`OBJLIST` array populated with + * a series of attached items such as a chlorinator device. + * + * @returns the object used to issue this request + */ +export function GetSystemConfiguration(): ICRequest { + const req = GetRequest(); + req.command = "GetQuery"; + req.queryName = "GetConfiguration"; + req.arguments = ""; + + return req; +} diff --git a/messages/param.ts b/messages/param.ts new file mode 100644 index 0000000..7fc7ed2 --- /dev/null +++ b/messages/param.ts @@ -0,0 +1,124 @@ +export class ICParam { + // "": "PROGRESS"; + public ABSMAX?: string; + public ABSMIN?: string; + public ACT?: string; + public ACT1?: string; + public ACT2?: string; + public ACT3?: string; + public ACT4?: string; + public ADDRESS?: string; + public ALK?: string; + public AVAIL?: "AVAIL" | "ON" | "OFF"; + public BADGE?: string; + public BODY?: string; + public BOOST?: string; + public CALC?: string; + public CALIB?: string; + public CHILD?: string; + public CIRCUIT?: string; + public CITY?: string; + public CLK24A?: string; + public COMUART?: string; + public COOL?: string; + public COUNT?: string; + public COUNTRY?: string; + public CYACID?: string; + public DAY?: string; + public DLSTIM?: "DLSTIM" | "ON" | "OFF"; + public DLY?: string; + public DNTSTP?: string; + public EMAIL?: string; + public EMAIL2?: string; + public ENABLE?: "ENABLE" | "ON" | "OFF"; + public FEATR?: string; + public FILTER?: string; + public FREEZE?: string; + public GPM?: string; + public HEATER?: string; + public HEATING?: "HEATING" | "ON" | "OFF"; + public HITMP?: string; + public HNAME?: string; + public HTMODE?: string; + public HTSRC?: string; + public IN?: string; + public LIMIT?: string; + public LISTORD?: string; + public LOCX?: string; + public LOCY?: string; + public LOTMP?: string; + public LSTTMP?: string; + public MANHT?: "MANHT" | "ON" | "OFF"; + public MANOVR?: "MANOVR" | "ON" | "OFF"; + public MANUAL?: string; + public MAX?: string; + public MAXF?: string; + public MIN?: string; + public MINF?: string; + public MODE?: string; + public NAME?: string; + public OBJLIST?: ICParam[]; + public OBJNAM?: string; + public OBJTYP?: string; + public OFFSET?: string; + public ORPSET?: string; + public ORPTNK?: string; + public ORPVAL?: string; + public PARENT?: string; + public PARTY?: string; + public PASSWRD?: string; + public PERMIT?: string; + public PHONE?: string; + public PHONE2?: string; + public PHSET?: string; + public PHTNK?: string; + public PHVAL?: string; + public PRIM?: string; + public PRIMFLO?: string; + public PRIMTIM?: string; + public PRIOR?: string; + public PROBE?: string; + public PROPNAME?: string; + public PWR?: string; + public QUALTY?: string; + public READY?: string; + public RLY?: string; + public RPM?: string; + public SALT?: string; + public SEC?: string; + public SELECT?: string; + public SERVICE?: "SERVICE" | "AUTO" | "TIMEOUT"; + public SETTMP?: string; + public SETTMPNC?: string; + public SHARE?: string; + public SHOMNU?: string; + public SINDEX?: string; + public SNAME?: string; + public SOURCE?: string; + public SPEED?: string; + public SRIS?: string; + public SSET?: string; + public START?: string; + public STATE?: string; + public STATIC?: string; + public STATUS?: "STATUS" | "ON" | "OFF"; + public STOP?: string; + public SUBTYP?: string; + public SUPER?: "SUPER" | "ON" | "OFF"; + public SWIM?: string; + public SYNC?: string; + public SYSTIM?: string; + public TEMP?: string; + public TIME?: string; + public TIMOUT?: string; + public TIMZON?: string; + public UPDATE?: string; + public USAGE?: string; + public USE?: string; + public VACFLO?: "VACFLO" | "ON" | "OFF"; + public VACTIM?: "VACTIM" | "ON" | "OFF"; + public VALVE?: "VALVE" | "ON" | "OFF"; + public VER?: string; + public VOL?: string; + public ZIP?: string; +} diff --git a/messages/request.ts b/messages/request.ts index 6a16e6f..244a2c2 100644 --- a/messages/request.ts +++ b/messages/request.ts @@ -1,8 +1,10 @@ import { v4 as uuidv4 } from "uuid"; +import { ICParam } from "./param.js"; export class ICRequestObj { public objnam = ""; public keys: string[] = []; + public params?: ICParam; } export class ICRequest { diff --git a/messages/response.ts b/messages/response.ts index cceb28c..bc35fec 100644 --- a/messages/response.ts +++ b/messages/response.ts @@ -1,131 +1,8 @@ -export class ICResponseParam { - // "": "PROGRESS"; - public ABSMAX?: string; - public ABSMIN?: string; - public ACT?: string; - public ACT1?: string; - public ACT2?: string; - public ACT3?: string; - public ACT4?: string; - public ADDRESS?: string; - public ALK?: string; - public AVAIL?: "AVAIL" | "ON" | "OFF"; - public BADGE?: string; - public BODY?: string; - public BOOST?: string; - public CALC?: string; - public CALIB?: string; - public CHILD?: string; - public CIRCUIT?: string; - public CITY?: string; - public CLK24A?: string; - public COMUART?: string; - public COOL?: string; - public COUNT?: string; - public COUNTRY?: string; - public CYACID?: string; - public DAY?: string; - public DLSTIM?: "DLSTIM" | "ON" | "OFF"; - public DLY?: string; - public DNTSTP?: string; - public EMAIL?: string; - public EMAIL2?: string; - public ENABLE?: "ENABLE" | "ON" | "OFF"; - public FEATR?: string; - public FILTER?: string; - public FREEZE?: string; - public GPM?: string; - public HEATER?: string; - public HEATING?: "HEATING" | "ON" | "OFF"; - public HITMP?: string; - public HNAME?: string; - public HTMODE?: string; - public HTSRC?: string; - public IN?: string; - public LIMIT?: string; - public LISTORD?: string; - public LOCX?: string; - public LOCY?: string; - public LOTMP?: string; - public LSTTMP?: string; - public MANHT?: "MANHT" | "ON" | "OFF"; - public MANOVR?: "MANOVR" | "ON" | "OFF"; - public MANUAL?: string; - public MAX?: string; - public MAXF?: string; - public MIN?: string; - public MINF?: string; - public MODE?: string; - public NAME?: string; - public OBJLIST?: ICResponseParam[]; - public OBJNAM?: string; - public OBJTYP?: string; - public OFFSET?: string; - public ORPSET?: string; - public ORPTNK?: string; - public ORPVAL?: string; - public PARENT?: string; - public PARTY?: string; - public PASSWRD?: string; - public PERMIT?: string; - public PHONE?: string; - public PHONE2?: string; - public PHSET?: string; - public PHTNK?: string; - public PHVAL?: string; - public PRIM?: string; - public PRIMFLO?: string; - public PRIMTIM?: string; - public PRIOR?: string; - public PROBE?: string; - public PROPNAME?: string; - public PWR?: string; - public QUALTY?: string; - public READY?: string; - public RLY?: string; - public RPM?: string; - public SALT?: string; - public SEC?: string; - public SELECT?: string; - public SERVICE?: "SERVICE" | "AUTO" | "TIMEOUT"; - public SETTMP?: string; - public SETTMPNC?: string; - public SHARE?: string; - public SHOMNU?: string; - public SINDEX?: string; - public SNAME?: string; - public SOURCE?: string; - public SPEED?: string; - public SRIS?: string; - public SSET?: string; - public START?: string; - public STATE?: string; - public STATIC?: string; - public STATUS?: string; - public STOP?: string; - public SUBTYP?: string; - public SUPER?: "SUPER" | "ON" | "OFF"; - public SWIM?: string; - public SYNC?: string; - public SYSTIM?: string; - public TEMP?: string; - public TIME?: string; - public TIMOUT?: string; - public TIMZON?: string; - public UPDATE?: string; - public USAGE?: string; - public USE?: string; - public VACFLO?: "VACFLO" | "ON" | "OFF"; - public VACTIM?: "VACTIM" | "ON" | "OFF"; - public VALVE?: "VALVE" | "ON" | "OFF"; - public VER?: string; - public VOL?: string; - public ZIP?: string; -} +import { ICParam } from "./param.js"; export class ICResponseObj { public objnam = ""; - public params?: ICResponseParam; + public params?: ICParam; } export class ICResponse { diff --git a/messages/set-status.ts b/messages/set-status.ts new file mode 100644 index 0000000..c25ca32 --- /dev/null +++ b/messages/set-status.ts @@ -0,0 +1,28 @@ +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; +} diff --git a/unit.ts b/unit.ts index 5edf05b..de9528d 100644 --- a/unit.ts +++ b/unit.ts @@ -2,7 +2,6 @@ import { EventEmitter } from "events"; import { WebSocket } from "ws"; import { ICRequest } from "./messages/request.js"; import { ICResponse } from "./messages/response.js"; -import { GetSystemInfoRequest } from "./messages/system-info.js"; export class Unit extends EventEmitter { private client?: WebSocket; @@ -69,9 +68,4 @@ export class Unit extends EventEmitter { }); }); } - - public async getSystemInfo(): Promise { - const req = GetSystemInfoRequest(); - return await this.send(req); - } }