Ensure all messages populate the response senderId

Fixed `addClient` and `removeClient` events returning `SLCancelDelay` objects. This shouldn't really make a difference as there are no properties to worry about on one or the other, but it was still incorrect and could cause bugs if stuff was added to those messages in the future.
This commit is contained in:
2020-08-12 08:51:44 -05:00
parent 8294947f8c
commit 27bdf0380e
11 changed files with 100 additions and 57 deletions

View File

@ -438,7 +438,7 @@ Passed as an argument to the emitted `saltCellConfig` event handler.
### SLSetSaltCellConfigMessage ### SLSetSaltCellConfigMessage
Passed as an argument to the emitted `setSaltCellConfig` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Passed as an argument to the emitted `setSaltCellConfig` event.
#### Properties #### Properties
@ -527,7 +527,7 @@ Returns the `bodyArray` entry for the circuit matching the given device id. This
### SLSetCircuitStateMessage ### SLSetCircuitStateMessage
Passed as an argument to the emitted `circuitStateChanged` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Passed as an argument to the emitted `circuitStateChanged` event.
#### Properties #### Properties
@ -539,7 +539,7 @@ Passed as an argument to the emitted `circuitStateChanged` event. The passed ver
### SLSetHeatSetPointMessage ### SLSetHeatSetPointMessage
Passed as an argument to the emitted `setPointChanged` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Passed as an argument to the emitted `setPointChanged` event.
#### Properties #### Properties
@ -550,7 +550,7 @@ Passed as an argument to the emitted `setPointChanged` event. The passed version
### SLSetHeatModeMessage ### SLSetHeatModeMessage
Passed as an argument to the emitted `heatModeChanged` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Passed as an argument to the emitted `heatModeChanged` event.
#### Properties #### Properties
@ -566,7 +566,7 @@ Passed as an argument to the emitted `heatModeChanged` event. The passed version
### SLLightControlMessage ### SLLightControlMessage
Passed as an argument to the emitted `sentLightCommand` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the light command. Passed as an argument to the emitted `sentLightCommand` event.
#### Properties #### Properties
@ -656,7 +656,7 @@ Passed as an argument to the emitted `setScheduleEventById` event. Configures an
### SLSetCircuitRuntimeById ### SLSetCircuitRuntimeById
Passed as an argument to the emitted `setCircuitRuntimebyId` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Configures default run-time of a circuit, usually referred to as the 'egg timer'. This also applies to 'run-once' programs as this will set the length of the program. Passed as an argument to the emitted `setCircuitRuntimebyId` event. Configures default run-time of a circuit, usually referred to as the 'egg timer'. This also applies to 'run-once' programs as this will set the length of the program.
#### Properties #### Properties
@ -690,7 +690,7 @@ Passed as an argument to the emitted `getPumpStatus` event. Gets information abo
### SLSetPumpFlow ### SLSetPumpFlow
Passed as an argument to the emitted `setPumpFlow` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Sets flow setting for a pump/circuit combination. Passed as an argument to the emitted `setPumpFlow` event. Sets flow setting for a pump/circuit combination.
#### Properties #### Properties
@ -701,12 +701,12 @@ Passed as an argument to the emitted `setPumpFlow` event. The passed version is
### SLCancelDelay ### SLCancelDelay
Passed as an argument to the emitted `cancelDelay` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the set command. Passed as an argument to the emitted `cancelDelay` event.
### SLAddClient ### SLAddClient
Passed as an argument to the emitted `addClient` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the command. Passed as an argument to the emitted `addClient` event.
### SLRemoveClient ### SLRemoveClient
Passed as an argument to the emitted `removeClient` event. The passed version is empty, however, since the response is just an acknowledgement of receipt of the command. Passed as an argument to the emitted `removeClient` event.

View File

@ -336,23 +336,23 @@ class UnitConnection extends EventEmitter {
break; break;
case messages.SLSetCircuitStateMessage.getResponseId(): case messages.SLSetCircuitStateMessage.getResponseId():
debugUnit(" it's circuit toggle ack"); debugUnit(" it's circuit toggle ack");
this.emit('circuitStateChanged', new messages.SLSetCircuitStateMessage()); this.emit('circuitStateChanged', new messages.SLSetCircuitStateMessage(msg));
break; break;
case messages.SLSetHeatSetPointMessage.getResponseId(): case messages.SLSetHeatSetPointMessage.getResponseId():
debugUnit(" it's a setpoint ack"); debugUnit(" it's a setpoint ack");
this.emit('setPointChanged', new messages.SLSetHeatSetPointMessage()); this.emit('setPointChanged', new messages.SLSetHeatSetPointMessage(msg));
break; break;
case messages.SLSetHeatModeMessage.getResponseId(): case messages.SLSetHeatModeMessage.getResponseId():
debugUnit(" it's a heater mode ack"); debugUnit(" it's a heater mode ack");
this.emit('heatModeChanged', new messages.SLSetHeatModeMessage()); this.emit('heatModeChanged', new messages.SLSetHeatModeMessage(msg));
break; break;
case messages.SLLightControlMessage.getResponseId(): case messages.SLLightControlMessage.getResponseId():
debugUnit(" it's a light control ack"); debugUnit(" it's a light control ack");
this.emit('sentLightCommand', new messages.SLLightControlMessage()); this.emit('sentLightCommand', new messages.SLLightControlMessage(msg));
break; break;
case messages.SLSetSaltCellConfigMessage.getResponseId(): case messages.SLSetSaltCellConfigMessage.getResponseId():
debugUnit(" it's a set salt cell config ack"); debugUnit(" it's a set salt cell config ack");
this.emit('setSaltCellConfig', new messages.SLSetSaltCellConfigMessage()); this.emit('setSaltCellConfig', new messages.SLSetSaltCellConfigMessage(msg));
break; break;
case messages.SLEquipmentConfigurationMessage.getResponseId(): case messages.SLEquipmentConfigurationMessage.getResponseId():
debugUnit(" it's equipment configuration"); debugUnit(" it's equipment configuration");
@ -376,7 +376,7 @@ class UnitConnection extends EventEmitter {
break; break;
case messages.SLSetCircuitRuntimeById.getResponseId(): case messages.SLSetCircuitRuntimeById.getResponseId():
debugUnit(" it's a set circuit runtime ack"); debugUnit(" it's a set circuit runtime ack");
this.emit('setCircuitRuntimebyId', new messages.SLSetCircuitRuntimeById()); this.emit('setCircuitRuntimebyId', new messages.SLSetCircuitRuntimeById(msg));
break; break;
case messages.SLGetPumpStatus.getResponseId(): case messages.SLGetPumpStatus.getResponseId():
debugUnit(" it's pump status"); debugUnit(" it's pump status");
@ -384,19 +384,19 @@ class UnitConnection extends EventEmitter {
break; break;
case messages.SLSetPumpFlow.getResponseId(): case messages.SLSetPumpFlow.getResponseId():
debugUnit(" it's a set pump flow ack"); debugUnit(" it's a set pump flow ack");
this.emit('setPumpFlow', new messages.SLSetPumpFlow()); this.emit('setPumpFlow', new messages.SLSetPumpFlow(msg));
break; break;
case messages.SLCancelDelay.getResponseId(): case messages.SLCancelDelay.getResponseId():
debugUnit(" it's a cancel delay ack"); debugUnit(" it's a cancel delay ack");
this.emit('cancelDelay', new messages.SLCancelDelay()); this.emit('cancelDelay', new messages.SLCancelDelay(msg));
break; break;
case messages.SLAddClient.getResponseId(): case messages.SLAddClient.getResponseId():
debugUnit(" it's an add client ack"); debugUnit(" it's an add client ack");
this.emit('addClient', new messages.SLCancelDelay()); this.emit('addClient', new messages.SLAddClient(msg));
break; break;
case messages.SLRemoveClient.getResponseId(): case messages.SLRemoveClient.getResponseId():
debugUnit(" it's a remove client ack"); debugUnit(" it's a remove client ack");
this.emit('removeClient', new messages.SLCancelDelay()); this.emit('removeClient', new messages.SLRemoveClient(msg));
break; break;
case messages.SLPoolStatusMessage.getAsyncResponseId(): case messages.SLPoolStatusMessage.getAsyncResponseId():
debugUnit(" it's async pool status"); debugUnit(" it's async pool status");

View File

@ -6,9 +6,14 @@ const MSG_ID = 12522;
exports.SLAddClient = class SLAddClient extends SLMessage { exports.SLAddClient = class SLAddClient extends SLMessage {
constructor(clientId, senderId) { constructor(clientId, senderId) {
super(senderId, MSG_ID); if (typeof clientId === 'object') {
var size = clientId.readInt32LE(4) + 8;
super(clientId, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.clientId = clientId; this.clientId = clientId;
}
} }
encode() { encode() {

View File

@ -6,10 +6,15 @@ const MSG_ID = 12556;
exports.SLLightControl = class SLLightControl extends SLMessage { exports.SLLightControl = class SLLightControl extends SLMessage {
constructor(controllerIndex, command, senderId) { constructor(controllerIndex, command, senderId) {
super(senderId, MSG_ID); if (typeof controllerIndex === 'object') {
var size = controllerIndex.readInt32LE(4) + 8;
super(controllerIndex, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.controllerIndex = controllerIndex; this.controllerIndex = controllerIndex;
this.command = command; this.command = command;
}
} }
encode() { encode() {

View File

@ -6,9 +6,14 @@ const MSG_ID = 12524;
exports.SLRemoveClient = class SLRemoveClient extends SLMessage { exports.SLRemoveClient = class SLRemoveClient extends SLMessage {
constructor(clientId, senderId) { constructor(clientId, senderId) {
super(senderId, MSG_ID); if (typeof clientId === 'object') {
var size = clientId.readInt32LE(4) + 8;
super(clientId, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.clientId = clientId; this.clientId = clientId;
}
} }
encode() { encode() {

View File

@ -7,10 +7,15 @@ const MSG_ID = 12550;
exports.SLSetCircuitRuntimeById = class SLSetCircuitRuntimeById extends SLMessage { exports.SLSetCircuitRuntimeById = class SLSetCircuitRuntimeById extends SLMessage {
constructor(circuitId, runTime, senderId) { constructor(circuitId, runTime, senderId) {
super(senderId, MSG_ID); if (typeof circuitId === 'object') {
var size = circuitId.readInt32LE(4) + 8;
super(circuitId, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.circuitId = circuitId; this.circuitId = circuitId;
this.runTime = runTime; this.runTime = runTime;
}
} }
encode() { encode() {

View File

@ -6,11 +6,16 @@ const MSG_ID = 12530;
exports.SLSetCircuitStateMessage = class SLSetCircuitStateMessage extends SLMessage { exports.SLSetCircuitStateMessage = class SLSetCircuitStateMessage extends SLMessage {
constructor(controllerId, circuitId, circuitState, senderId) { constructor(controllerId, circuitId, circuitState, senderId) {
super(senderId, MSG_ID); if (typeof controllerId === 'object') {
var size = controllerId.readInt32LE(4) + 8;
super(controllerId, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.controllerId = controllerId; this.controllerId = controllerId;
this.circuitId = circuitId; this.circuitId = circuitId;
this.circuitState = circuitState; this.circuitState = circuitState;
}
} }
encode() { encode() {

View File

@ -6,13 +6,16 @@ const MSG_ID = 12538;
exports.SLSetHeatMode = class SLSetHeatMode extends SLMessage { exports.SLSetHeatMode = class SLSetHeatMode extends SLMessage {
constructor(controllerIndex, bodyType, heatMode, senderId) { constructor(controllerIndex, bodyType, heatMode, senderId) {
super(senderId, MSG_ID); if (typeof controllerIndex === 'object') {
var size = controllerIndex.readInt32LE(4) + 8;
super(controllerIndex, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.controllerIndex = controllerIndex; this.controllerIndex = controllerIndex;
this.bodyType = bodyType; this.bodyType = bodyType;
this.heatMode = heatMode; this.heatMode = heatMode;
// heatmodes: }
// 0: "Off", 1: "Solar", 2 : "Solar Preferred", 3 : "Heat Pump", 4: "Don't Change"
} }
encode() { encode() {

View File

@ -6,11 +6,16 @@ const MSG_ID = 12528;
exports.SLSetHeatSetPoint = class SLSetHeatSetPoint extends SLMessage { exports.SLSetHeatSetPoint = class SLSetHeatSetPoint extends SLMessage {
constructor(controllerIndex, bodyType, temperature, senderId) { constructor(controllerIndex, bodyType, temperature, senderId) {
super(senderId, MSG_ID); if (typeof controllerIndex === 'object') {
var size = controllerIndex.readInt32LE(4) + 8;
super(controllerIndex, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.controllerIndex = controllerIndex; this.controllerIndex = controllerIndex;
this.bodyType = bodyType; this.bodyType = bodyType;
this.temperature = temperature; this.temperature = temperature;
}
} }
encode() { encode() {

View File

@ -6,16 +6,21 @@ const MSG_ID = 12586;
exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage { exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage {
constructor(pumpId, circuitId, setPoint, isRPMs, senderId) { constructor(pumpId, circuitId, setPoint, isRPMs, senderId) {
super(senderId, MSG_ID); if (typeof pumpId === 'object') {
var size = pumpId.readInt32LE(4) + 8;
this.pumpId = pumpId; super(pumpId, MSG_ID, size);
this.circuitId = circuitId;
this.setPoint = setPoint;
if (isRPMs === true) {
this.isRPMs = 1;
} else { } else {
this.isRPMs = 0; super(senderId, MSG_ID);
this.pumpId = pumpId;
this.circuitId = circuitId;
this.setPoint = setPoint;
if (isRPMs === true) {
this.isRPMs = 1;
} else {
this.isRPMs = 0;
}
} }
} }

View File

@ -6,11 +6,16 @@ const MSG_ID = 12576;
exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage { exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage {
constructor(controllerIndex, poolOutput, spaOutput, senderId) { constructor(controllerIndex, poolOutput, spaOutput, senderId) {
super(senderId, MSG_ID); if (typeof controllerIndex === 'object') {
var size = controllerIndex.readInt32LE(4) + 8;
super(controllerIndex, MSG_ID, size);
} else {
super(senderId, MSG_ID);
this.controllerIndex = controllerIndex; this.controllerIndex = controllerIndex;
this.poolOutput = poolOutput; this.poolOutput = poolOutput;
this.spaOutput = spaOutput; this.spaOutput = spaOutput;
}
} }
encode() { encode() {