diff --git a/README.md b/README.md index bc5f4ac..1cf384d 100755 --- a/README.md +++ b/README.md @@ -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. diff --git a/index.js b/index.js index a3f9281..a8fe18d 100644 --- a/index.js +++ b/index.js @@ -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"); diff --git a/messages/SLAddClient.js b/messages/SLAddClient.js index b69b96a..f117253 100644 --- a/messages/SLAddClient.js +++ b/messages/SLAddClient.js @@ -6,9 +6,14 @@ const MSG_ID = 12522; exports.SLAddClient = class SLAddClient extends SLMessage { 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() { diff --git a/messages/SLLightControl.js b/messages/SLLightControl.js index f711c98..84216a1 100644 --- a/messages/SLLightControl.js +++ b/messages/SLLightControl.js @@ -6,10 +6,15 @@ const MSG_ID = 12556; exports.SLLightControl = class SLLightControl extends SLMessage { 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.command = command; + this.controllerIndex = controllerIndex; + this.command = command; + } } encode() { diff --git a/messages/SLRemoveClient.js b/messages/SLRemoveClient.js index e5dfc2c..c4b8de5 100644 --- a/messages/SLRemoveClient.js +++ b/messages/SLRemoveClient.js @@ -6,9 +6,14 @@ const MSG_ID = 12524; exports.SLRemoveClient = class SLRemoveClient extends SLMessage { 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() { diff --git a/messages/SLSetCircuitRuntimeById.js b/messages/SLSetCircuitRuntimeById.js index 1de4934..5e1093f 100644 --- a/messages/SLSetCircuitRuntimeById.js +++ b/messages/SLSetCircuitRuntimeById.js @@ -7,10 +7,15 @@ const MSG_ID = 12550; exports.SLSetCircuitRuntimeById = class SLSetCircuitRuntimeById extends SLMessage { 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.runTime = runTime; + this.circuitId = circuitId; + this.runTime = runTime; + } } encode() { diff --git a/messages/SLSetCircuitStateMessage.js b/messages/SLSetCircuitStateMessage.js index f4ad69d..b2fa837 100644 --- a/messages/SLSetCircuitStateMessage.js +++ b/messages/SLSetCircuitStateMessage.js @@ -6,11 +6,16 @@ const MSG_ID = 12530; exports.SLSetCircuitStateMessage = class SLSetCircuitStateMessage extends SLMessage { 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.circuitId = circuitId; - this.circuitState = circuitState; + this.controllerId = controllerId; + this.circuitId = circuitId; + this.circuitState = circuitState; + } } encode() { diff --git a/messages/SLSetHeatMode.js b/messages/SLSetHeatMode.js index 4b3a570..761d851 100644 --- a/messages/SLSetHeatMode.js +++ b/messages/SLSetHeatMode.js @@ -6,13 +6,16 @@ const MSG_ID = 12538; exports.SLSetHeatMode = class SLSetHeatMode extends SLMessage { 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.bodyType = bodyType; - this.heatMode = heatMode; - // heatmodes: - // 0: "Off", 1: "Solar", 2 : "Solar Preferred", 3 : "Heat Pump", 4: "Don't Change" + this.controllerIndex = controllerIndex; + this.bodyType = bodyType; + this.heatMode = heatMode; + } } encode() { diff --git a/messages/SLSetHeatSetPoint.js b/messages/SLSetHeatSetPoint.js index c90ffab..dce089c 100644 --- a/messages/SLSetHeatSetPoint.js +++ b/messages/SLSetHeatSetPoint.js @@ -6,11 +6,16 @@ const MSG_ID = 12528; exports.SLSetHeatSetPoint = class SLSetHeatSetPoint extends SLMessage { 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.bodyType = bodyType; - this.temperature = temperature; + this.controllerIndex = controllerIndex; + this.bodyType = bodyType; + this.temperature = temperature; + } } encode() { diff --git a/messages/SLSetPumpFlow.js b/messages/SLSetPumpFlow.js index f02ca6a..9561e9c 100644 --- a/messages/SLSetPumpFlow.js +++ b/messages/SLSetPumpFlow.js @@ -6,16 +6,21 @@ const MSG_ID = 12586; exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage { constructor(pumpId, circuitId, setPoint, isRPMs, senderId) { - super(senderId, MSG_ID); - - this.pumpId = pumpId; - this.circuitId = circuitId; - this.setPoint = setPoint; - - if (isRPMs === true) { - this.isRPMs = 1; + if (typeof pumpId === 'object') { + var size = pumpId.readInt32LE(4) + 8; + super(pumpId, MSG_ID, size); } 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; + } } } diff --git a/messages/SLSetSaltCellConfigMessage.js b/messages/SLSetSaltCellConfigMessage.js index 7dce44c..1d5cbac 100644 --- a/messages/SLSetSaltCellConfigMessage.js +++ b/messages/SLSetSaltCellConfigMessage.js @@ -6,11 +6,16 @@ const MSG_ID = 12576; exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage { 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.poolOutput = poolOutput; - this.spaOutput = spaOutput; + this.controllerIndex = controllerIndex; + this.poolOutput = poolOutput; + this.spaOutput = spaOutput; + } } encode() {