diff --git a/messages/SLPoolStatusMessage.js b/messages/SLPoolStatusMessage.js index 6c8d69b..6a2b860 100755 --- a/messages/SLPoolStatusMessage.js +++ b/messages/SLPoolStatusMessage.js @@ -1,5 +1,8 @@ const SLMessage = require('./SLMessage.js').SLMessage; +const SPA_CIRCUIT_ID = 500; +const POOL_CIRCUIT_ID = 505; + exports.SLPoolStatusMessage = class SLPoolStatusMessage extends SLMessage { constructor(buf) { super(0, 12526); @@ -67,4 +70,32 @@ exports.SLPoolStatusMessage = class SLPoolStatusMessage extends SLMessage { this.orpTank = this.readInt32LE(); this.alarms = this.readInt32LE(); } + + isDeviceReady() { + return this.ok === 1; + } + + isDeviceSync() { + return this.ok === 2; + } + + isDeviceServiceMode() { + return this.ok === 3; + } + + isSpaActive() { + for (let i = 0; i < this.circuitArray.length; i++) { + if (this.circuitArray[i].id === SPA_CIRCUIT_ID) { + return this.circuitArray[i].state === 1; + } + } + } + + isPoolActive() { + for (let i = 0; i < this.circuitArray.length; i++) { + if (this.circuitArray[i].id === POOL_CIRCUIT_ID) { + return this.circuitArray[i].state === 1; + } + } + } } diff --git a/test.js b/test.js index a024230..809f85d 100755 --- a/test.js +++ b/test.js @@ -15,6 +15,8 @@ finder.on('serverFound', function(server) { console.log(" salt ppm=" + status.saltPPM); console.log(" pH=" + status.pH); console.log(" saturation=" + status.saturation); + console.log(" spa active=" + status.isSpaActive()); + console.log(" pool active=" + status.isPoolActive()); }).on('controllerConfig', function(config) { console.log(" controller is in celsius=" + config.degC); client.close();