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
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
@ -527,7 +527,7 @@ Returns the `bodyArray` entry for the circuit matching the given device id. This
### 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
@ -539,7 +539,7 @@ Passed as an argument to the emitted `circuitStateChanged` event. The passed ver
### 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
@ -550,7 +550,7 @@ Passed as an argument to the emitted `setPointChanged` event. The passed version
### 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
@ -566,7 +566,7 @@ Passed as an argument to the emitted `heatModeChanged` event. The passed version
### 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
@ -656,7 +656,7 @@ Passed as an argument to the emitted `setScheduleEventById` event. Configures an
### 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
@ -690,7 +690,7 @@ Passed as an argument to the emitted `getPumpStatus` event. Gets information abo
### 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
@ -701,12 +701,12 @@ Passed as an argument to the emitted `setPumpFlow` event. The passed version is
### 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
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
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;
case messages.SLSetCircuitStateMessage.getResponseId():
debugUnit(" it's circuit toggle ack");
this.emit('circuitStateChanged', new messages.SLSetCircuitStateMessage());
this.emit('circuitStateChanged', new messages.SLSetCircuitStateMessage(msg));
break;
case messages.SLSetHeatSetPointMessage.getResponseId():
debugUnit(" it's a setpoint ack");
this.emit('setPointChanged', new messages.SLSetHeatSetPointMessage());
this.emit('setPointChanged', new messages.SLSetHeatSetPointMessage(msg));
break;
case messages.SLSetHeatModeMessage.getResponseId():
debugUnit(" it's a heater mode ack");
this.emit('heatModeChanged', new messages.SLSetHeatModeMessage());
this.emit('heatModeChanged', new messages.SLSetHeatModeMessage(msg));
break;
case messages.SLLightControlMessage.getResponseId():
debugUnit(" it's a light control ack");
this.emit('sentLightCommand', new messages.SLLightControlMessage());
this.emit('sentLightCommand', new messages.SLLightControlMessage(msg));
break;
case messages.SLSetSaltCellConfigMessage.getResponseId():
debugUnit(" it's a set salt cell config ack");
this.emit('setSaltCellConfig', new messages.SLSetSaltCellConfigMessage());
this.emit('setSaltCellConfig', new messages.SLSetSaltCellConfigMessage(msg));
break;
case messages.SLEquipmentConfigurationMessage.getResponseId():
debugUnit(" it's equipment configuration");
@ -376,7 +376,7 @@ class UnitConnection extends EventEmitter {
break;
case messages.SLSetCircuitRuntimeById.getResponseId():
debugUnit(" it's a set circuit runtime ack");
this.emit('setCircuitRuntimebyId', new messages.SLSetCircuitRuntimeById());
this.emit('setCircuitRuntimebyId', new messages.SLSetCircuitRuntimeById(msg));
break;
case messages.SLGetPumpStatus.getResponseId():
debugUnit(" it's pump status");
@ -384,19 +384,19 @@ class UnitConnection extends EventEmitter {
break;
case messages.SLSetPumpFlow.getResponseId():
debugUnit(" it's a set pump flow ack");
this.emit('setPumpFlow', new messages.SLSetPumpFlow());
this.emit('setPumpFlow', new messages.SLSetPumpFlow(msg));
break;
case messages.SLCancelDelay.getResponseId():
debugUnit(" it's a cancel delay ack");
this.emit('cancelDelay', new messages.SLCancelDelay());
this.emit('cancelDelay', new messages.SLCancelDelay(msg));
break;
case messages.SLAddClient.getResponseId():
debugUnit(" it's an add client ack");
this.emit('addClient', new messages.SLCancelDelay());
this.emit('addClient', new messages.SLAddClient(msg));
break;
case messages.SLRemoveClient.getResponseId():
debugUnit(" it's a remove client ack");
this.emit('removeClient', new messages.SLCancelDelay());
this.emit('removeClient', new messages.SLRemoveClient(msg));
break;
case messages.SLPoolStatusMessage.getAsyncResponseId():
debugUnit(" it's async pool status");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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