GetPumpStatus / SetPumpFlow commands (#28)

* added GetPumpStatus / SetPumpFlow commands

* Updated README.md with GetPumpStatus / SetPumpFlow information

* rename `setPointType` to `isRPMs`

* renamed val0 to pumpType and val1 to isRunning

* added `unknown command` case

* fixed lint error

* Renamed unknown values to pumpUnknown1 and pumpUnknown2

* renamed 30 to unknownCommand
This commit is contained in:
Bruce Sheplan
2020-06-09 07:49:24 -05:00
committed by GitHub
parent 219ce110ea
commit 75d642cbfc
5 changed files with 139 additions and 1 deletions

View File

@ -534,4 +534,37 @@ Configures default run-time of a circuit, usually referred to as the 'egg timer'
### Properties
* `circuitId` - id of the circuit to which this event applies to
* `runTime` - integer specifying the minutes of runTime
* `runTime` - integer specifying the minutes of runTime
## SLGetPumpStatus
Gets information about indicated pump
### Properties
* `pumpId` - id of pump to get information about, first pump is 0
### Return Values
* `isRunning` - boolean that says if pump is running
* `pumpType` - 1 for IntelliFloVF (presumably), 2 for IntelliflowVS, 3 for IntelliflowVSF
* `pumpWatts` - current Watts usage of the pump
* `pumpRPMs` - current RPMs of the pump
* `pumpGPMs` - current GPMs of the pump
* `pumpSetting` - Array of 8 items each containing
* `circuitId` - Circuit Id ( CirctuiId matched data returned by [`SLControllerConfigMessage`](#slcontrollerconfigmessage) bodyArray[i].deviceId)
* `pumpSetPoint` = the setPoint for this pump/circuit combo
* `isRPMs` = 1 for RPMs; 0 for GPMs
* `pumpUnknown1` - unknown data -- always 0
* `pumpUnknown2` - unknown data -- always 255
## SLSetPumpFlow
Sets Flow Setting for a Pump/Circuit combination
### Properties
* `pumpId` - id of pump to get information about, first pump is 0
* `circuitId` - index of circuit for which to change the setpoint ( index is relative to data returned by [`SLGetPumpStatus`](#slgetpumpstatus) )
* `setPoint` - the value for which to set the pump/circuit combo
* `isRPMs` - boolean, TRUE for RPMs, FALSE for GPMs

View File

@ -253,6 +253,14 @@ class UnitConnection extends EventEmitter {
this.client.write(new messages.SLSetCircuitRuntimeById(circuitId, runTime).toBuffer());
}
getPumpStatus(pumpId) {
this.client.write(new messages.SLGetPumpStatus(null, pumpId).toBuffer());
}
setPumpFlow(pumpId, circuitId, setPoint, isRPMs) {
this.client.write(new messages.SLSetPumpFlow(pumpId, circuitId, setPoint, isRPMs).toBuffer());
}
onClientMessage(msg) {
// console.log('received message of length ' + msg.length);
if (msg.length < 4) {
@ -328,10 +336,20 @@ class UnitConnection extends EventEmitter {
case messages.SLSetCircuitRuntimeById.getResponseId():
this.emit('setCircuitRuntimebyId', new messages.SLSetCircuitRuntimeById());
break;
case messages.SLGetPumpStatus.getResponseId():
this.emit('getPumpStatus', new messages.SLGetPumpStatus(msg));
break;
case messages.SLSetPumpFlow.getResponseId():
this.emit('setPumpFlow', new messages.SLSetPumpFlow());
break;
case 13:
// console.log(" it's a login failure.");
this.emit('loginFailed');
break;
case 30:
// console.log("unknown command");
this.emit('unknownCommand');
break;
case 31:
// console.log(" it's a parameter failure.");
this.emit('badParameter');

View File

@ -0,0 +1,50 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12584;
exports.SLGetPumpStatus = class SLGetPumpStatus extends SLMessage {
constructor(buf, pumpId) {
var size;
if (buf) {
size = buf.readInt32LE(4) + 8;
}
super(0, MSG_ID, size);
if (!buf) {
this.writeInt32LE(0);
this.writeInt32LE(pumpId);
} else {
this._wroteSize = true;
this.writeBuffer(buf, 0);
this.decode();
}
}
decode() {
super.decode();
this.pumpSetting = new Array(8);
this.pumpType = this.readUInt32LE();
this.isRunning = this.readUInt32LE() !== 0; // Sometimes 1, sometimes 4294967295 (FF FF FF FF)
this.pumpWatts = this.readUInt32LE();
this.pumpRPMs = this.readUInt32LE();
this.pumpUnknown1 = this.readUInt32LE(); // Always 0
this.pumpGPMs = this.readUInt32LE();
this.pumpUnknown2 = this.readUInt32LE(); // Always 255
for (var i = 0; i < 8; i++) {
this.pumpSetting[i] = {};
this.pumpSetting[i].circuitId = this.readUInt32LE();
this.pumpSetting[i].pumpSetPoint = this.readUInt32LE();
this.pumpSetting[i].isRPMs = this.readUInt32LE(); // 1 for RPMs; 0 for GPMs
}
}
static getResponseId() {
return MSG_ID + 1;
}
};

35
messages/SLSetPumpFlow.js Normal file
View File

@ -0,0 +1,35 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12586;
exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage {
constructor(pumpId, circuitId, setPoint, isRPMs) {
super(0, MSG_ID);
this.pumpId = pumpId;
this.circuitId = circuitId;
this.setPoint = setPoint;
if (isRPMs === true) {
this.isRPMs = 1;
} else {
this.isRPMs = 0;
}
}
encode() {
this.writeInt32LE(0); // Always 0 in my case
this.writeInt32LE(this.pumpId); // presumably pumpId, always 0 in my case
this.writeInt32LE(this.circuitId); // This is indexed to the array of circuits returned in GetPumpStatus
this.writeInt32LE(this.setPoint);
this.writeInt32LE(this.isRPMs); // 0 for GPM, 1 for RPMs
super.encode();
}
static getResponseId() {
return MSG_ID + 1;
}
};

View File

@ -20,3 +20,5 @@ exports.SLAddNewScheduleEvent = require('./SLAddNewScheduleEvent.js').SLAddNewSc
exports.SLDeleteScheduleEventById = require('./SLDeleteScheduleEventById.js').SLDeleteScheduleEventById;
exports.SLSetScheduleEventById = require('./SLSetScheduleEventById.js').SLSetScheduleEventById;
exports.SLSetCircuitRuntimeById = require('./SLSetCircuitRuntimeById.js').SLSetCircuitRuntimeById;
exports.SLGetPumpStatus = require('./SLGetPumpStatus.js').SLGetPumpStatus;
exports.SLSetPumpFlow = require('./SLSetPumpFlow.js').SLSetPumpFlow;