Added support for controlling the salt cell generator output levels
Closes #17
This commit is contained in:
23
README.md
23
README.md
@ -206,6 +206,10 @@ Sends a lighting command. See [`SLLightControlMessage`](#sllightcontrolmessage)
|
||||
|
||||
Note that better/more complete handling of lighting is desired, but I have yet to find all the commands I need to implement to make that happen. This currently sends each command to all lights and there is no ability to send to an individual light. Pull requests adding more functionality here would be most welcome.
|
||||
|
||||
### setSaltCellOutput(controllerId, poolOutput, spaOutput)
|
||||
|
||||
Sets the salt cell's output levels. See [`SLSetSaltCellConfigMessage`](#slsetsaltcellconfigmessage) documentation for argument values. Emits the `setSaltCellConfig` event when response is acknowledged.
|
||||
|
||||
### Events
|
||||
|
||||
* `loggedIn` - Indicates that a connection to the server has been established and the login process completed. `get` methods can be called once this event has been emitted.
|
||||
@ -320,13 +324,24 @@ Passed as an argument to the emitted `saltCellConfig` event handler.
|
||||
### Properties
|
||||
|
||||
* `installed` - boolean indicating whether a salt cell is installed or not
|
||||
* `status` - integer
|
||||
* `level1` - integer
|
||||
* `level2` - integer
|
||||
* `status` - integer bitmask
|
||||
* `level1` - integer indicating the output level of the salt cell for the pool. I believe this operates on a 0-100 scale
|
||||
* `level2` - integer indicating the output level of the salt cell for the spa. I believe this operates on a 0-100 scale
|
||||
* `salt` - integer indicating salt level in parts-per-million
|
||||
* `flags` - integer
|
||||
* `flags` - integer bitmask
|
||||
* `superChlorTimer` - integer
|
||||
|
||||
## 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.
|
||||
|
||||
### Properties
|
||||
|
||||
* `controllerId` - integer indicating the ID of the controller to send this command to.
|
||||
* Note that while `SLControllerConfigMessage` includes a controllerId, this ID, in my experience, should always be 0.
|
||||
* `poolOutput` - integer indicating the output level of the salt cell for the pool. I believe this operates on a 0-100 scale.
|
||||
* `spaOutput` - integer indicating the output level of the salt cell for the spa. I believe this operates on a 0-100 scale.
|
||||
|
||||
## SLControllerConfigMessage
|
||||
|
||||
Passed as an argument to the emitted `controllerConfig` event handler.
|
||||
|
8
index.js
8
index.js
@ -218,6 +218,10 @@ class UnitConnection extends EventEmitter {
|
||||
this.client.write(new messages.SLLightControlMessage(controllerId, command).toBuffer());
|
||||
}
|
||||
|
||||
setSaltCellOutput(controllerId, poolOutput, spaOutput) {
|
||||
this.client.write(new messages.SLSetSaltCellConfigMessage(controllerId, poolOutput, spaOutput).toBuffer());
|
||||
}
|
||||
|
||||
onClientMessage(msg) {
|
||||
// console.log('received message of length ' + msg.length);
|
||||
if (msg.length < 4) {
|
||||
@ -271,6 +275,10 @@ class UnitConnection extends EventEmitter {
|
||||
// console.log(" it's a light control ack");
|
||||
this.emit('sentLightCommand', new messages.SLLightControlMessage());
|
||||
break;
|
||||
case messages.SLSetSaltCellConfigMessage.getResponseId():
|
||||
// console.log(" it's a set salt cell config ack");
|
||||
this.emit('setSaltCellConfig', new messages.SLSetSaltCellConfigMessage());
|
||||
break;
|
||||
case 13:
|
||||
// console.log(" it's a login failure.");
|
||||
this.emit('loginFailed');
|
||||
|
29
messages/SLSetSaltCellConfigMessage.js
Normal file
29
messages/SLSetSaltCellConfigMessage.js
Normal file
@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
|
||||
const MSG_ID = 12576;
|
||||
|
||||
exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage {
|
||||
constructor(controllerIndex, poolOutput, spaOutput) {
|
||||
super(0, MSG_ID);
|
||||
|
||||
this.controllerIndex = controllerIndex;
|
||||
this.poolOutput = poolOutput;
|
||||
this.spaOutput = spaOutput;
|
||||
}
|
||||
|
||||
encode() {
|
||||
this.writeInt32LE(this.controllerIndex || 0);
|
||||
this.writeInt32LE(this.poolOutput || 0);
|
||||
this.writeInt32LE(this.spaOutput || 0);
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(0);
|
||||
|
||||
super.encode();
|
||||
}
|
||||
|
||||
static getResponseId() {
|
||||
return MSG_ID + 1;
|
||||
}
|
||||
};
|
@ -12,3 +12,4 @@ exports.SLGetGatewayDataMessage = require('./SLGetGatewayDataMessage.js').SLGetG
|
||||
exports.SLSetHeatSetPointMessage = require('./SLSetHeatSetPoint.js').SLSetHeatSetPoint;
|
||||
exports.SLSetHeatModeMessage = require('./SLSetHeatMode.js').SLSetHeatMode;
|
||||
exports.SLLightControlMessage = require('./SLLightControl.js').SLLightControl;
|
||||
exports.SLSetSaltCellConfigMessage = require('./SLSetSaltCellConfigMessage.js').SLSetSaltCellConfigMessage;
|
||||
|
Reference in New Issue
Block a user