Linter fixes

This commit is contained in:
2018-04-28 23:06:11 -05:00
parent 26083f75a7
commit 3c6b8ebcc7
14 changed files with 154 additions and 120 deletions

View File

@ -1,3 +1,5 @@
'use strict';
const ScreenLogic = require('./index');
var finder = new ScreenLogic.FindUnits();
@ -16,26 +18,27 @@ function connect(client) {
this.getVersion();
}).on('version', function(version) {
this.getPoolStatus();
console.log(" version=" + version.version);
console.log(' version=' + version.version);
}).on('poolStatus', function(status) {
this.getChemicalData();
console.log(" pool ok=" + status.ok);
console.log(" air temp=" + status.airTemp);
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());
console.log(' pool ok=' + status.ok);
console.log(' pool temp=' + status.currentTemp[0]);
console.log(' air temp=' + status.airTemp);
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('chemicalData', function(chemData) {
this.getSaltCellConfig();
console.log(" calcium=" + chemData.calcium);
console.log(" cyanuric acid=" + chemData.cyanuricAcid);
console.log(" alkalinity=" + chemData.alkalinity);
console.log(' calcium=' + chemData.calcium);
console.log(' cyanuric acid=' + chemData.cyanuricAcid);
console.log(' alkalinity=' + chemData.alkalinity);
}).on('saltCellConfig', function(saltCellConfig) {
this.getControllerConfig();
console.log(" salt cell installed=" + saltCellConfig.installed);
console.log(' salt cell installed=' + saltCellConfig.installed);
}).on('controllerConfig', function(config) {
console.log(" controller is in celsius=" + config.degC);
console.log(' controller is in celsius=' + config.degC);
client.close();
});

View File

@ -1,3 +1,5 @@
'use strict';
var dgram = require('dgram');
var net = require('net');
const EventEmitter = require('events');
@ -33,10 +35,11 @@ class FindUnits extends EventEmitter {
port: message.readInt16LE(8),
gatewayType: message.readUInt8(10),
gatewaySubtype: message.readUInt8(11),
gatewayName: message.toString('utf8', 12, 28)
gatewayName: message.toString('utf8', 12, 28),
};
//console.log(' type: ' + server.type + ', host: ' + server.address + ':' + server.port + ', identified as ' + server.gatewayName);
// console.log(' type: ' + server.type + ', host: ' + server.address + ':' + server.port + ',
// identified as ' + server.gatewayName);
if (server.type === 2) {
this.emit('serverFound', server);
}
@ -46,7 +49,7 @@ class FindUnits extends EventEmitter {
sendServerBroadcast() {
var message = Buffer.alloc(8);
message[0] = 1;
this.finder.send(message, 0, message.length, 1444, "255.255.255.255");
this.finder.send(message, 0, message.length, 1444, '255.255.255.255');
// console.log("Looking for ScreenLogic hosts...");
}
@ -186,5 +189,5 @@ for (const value of buf.values()) {
module.exports = {
FindUnits,
UnitConnection
}
UnitConnection,
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 14;
@ -10,4 +12,4 @@ exports.SLChallengeMessage = class SLChallengeMessage extends SLMessage {
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12592;
@ -53,4 +55,4 @@ exports.SLChemDataMessage = class SLChemDataMessage extends SLMessage {
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12532;
@ -49,8 +51,8 @@ exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMe
colorPos: this.readUInt8(),
colorStagger: this.readUInt8(),
deviceId: this.readUInt8(),
dfaultRt: this.readUInt16LE()
}
dfaultRt: this.readUInt16LE(),
};
this._readOffset += 2;
}
@ -60,11 +62,11 @@ exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMe
this.colorArray[i] = {
name: this.readSLString(),
color: {
r: this.readInt32LE() & 0xFF,
g: this.readInt32LE() & 0xFF,
b: this.readInt32LE() & 0xFF
}
}
r: this.readInt32LE() & 0xff,
g: this.readInt32LE() & 0xff,
b: this.readInt32LE() & 0xff,
},
};
}
let pumpCircCount = 8;
@ -80,4 +82,4 @@ exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMe
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 27;
@ -15,4 +17,4 @@ exports.SLLoginMessage = class SLLoginMessage extends SLMessage {
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SmartBuffer = require('smart-buffer').SmartBuffer;
exports.SLMessage = class SLMessage extends SmartBuffer {
@ -25,16 +27,16 @@ exports.SLMessage = class SLMessage extends SmartBuffer {
writeSLString(str) {
this.writeInt32LE(str.length);
this.writeString(str);
if (str.length % 4 != 0) {
this.skipWrite(4 - (str.length % 4));
if (str.length % 4 !== 0) {
this.skipWrite(4 - str.length % 4);
}
}
readSLString() {
var len = this.readInt32LE();
var str = this.readString(len);
if (len % 4 != 0) {
this.readOffset += 4 - (len % 4);
if (len % 4 !== 0) {
this.readOffset += 4 - len % 4;
}
return str;
}
@ -57,7 +59,5 @@ exports.SLMessage = class SLMessage extends SmartBuffer {
this.dataLength = this.readInt32LE();
}
encode() {
}
}
encode() {}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12526;
@ -60,8 +62,8 @@ exports.SLPoolStatusMessage = class SLPoolStatusMessage extends SLMessage {
colorSet: this.readUInt8(),
colorPos: this.readUInt8(),
colorStagger: this.readUInt8(),
delay: this.readUInt8()
}
delay: this.readUInt8(),
};
}
this.pH = this.readInt32LE() / 100;
@ -104,4 +106,4 @@ exports.SLPoolStatusMessage = class SLPoolStatusMessage extends SLMessage {
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12572;
@ -30,4 +32,4 @@ exports.SLSaltCellConfigMessage = class SLSaltCellConfigMessage extends SLMessag
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 12530;
@ -22,4 +24,4 @@ exports.SLSetCircuitStateMessage = class SLSetCircuitStateMessage extends SLMess
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,3 +1,5 @@
'use strict';
const SLMessage = require('./SLMessage.js').SLMessage;
const MSG_ID = 8120;
@ -22,4 +24,4 @@ exports.SLVersionMessage = class SLVersionMessage extends SLMessage {
static getResponseId() {
return MSG_ID + 1;
}
}
};

View File

@ -1,8 +1,10 @@
exports.SLPoolStatusMessage = require("./SLPoolStatusMessage.js").SLPoolStatusMessage;
exports.SLControllerConfigMessage = require("./SLControllerConfigMessage.js").SLControllerConfigMessage;
exports.SLChallengeMessage = require("./SLChallengeMessage.js").SLChallengeMessage;
exports.SLLoginMessage = require("./SLLoginMessage.js").SLLoginMessage;
exports.SLChemDataMessage = require("./SLChemDataMessage.js").SLChemDataMessage;
exports.SLSaltCellConfigMessage = require("./SLSaltCellConfigMessage.js").SLSaltCellConfigMessage;
exports.SLVersionMessage = require("./SLVersionMessage.js").SLVersionMessage;
exports.SLSetCircuitStateMessage = require("./SLSetCircuitStateMessage.js").SLSetCircuitStateMessage;
'use strict';
exports.SLPoolStatusMessage = require('./SLPoolStatusMessage.js').SLPoolStatusMessage;
exports.SLControllerConfigMessage = require('./SLControllerConfigMessage.js').SLControllerConfigMessage;
exports.SLChallengeMessage = require('./SLChallengeMessage.js').SLChallengeMessage;
exports.SLLoginMessage = require('./SLLoginMessage.js').SLLoginMessage;
exports.SLChemDataMessage = require('./SLChemDataMessage.js').SLChemDataMessage;
exports.SLSaltCellConfigMessage = require('./SLSaltCellConfigMessage.js').SLSaltCellConfigMessage;
exports.SLVersionMessage = require('./SLVersionMessage.js').SLVersionMessage;
exports.SLSetCircuitStateMessage = require('./SLSetCircuitStateMessage.js').SLSetCircuitStateMessage;

View File

@ -1,4 +1,4 @@
'use strict'
'use strict';
const ScreenLogic = require('../index');
@ -7,9 +7,9 @@ describe('Finder', () => {
it('finds a server', done => {
let finder = new ScreenLogic.FindUnits();
finder.on('serverFound', server => {
finder.close()
done()
})
finder.close();
done();
});
finder.search();
})
})
});
});

View File

@ -1,62 +1,72 @@
'use strict'
'use strict';
const ScreenLogic = require('../index');
// you'll need a ScreenLogic-enabled device on your network for this to succeed
describe('Unit', () => {
let unit
let unit;
before(done => {
let finder = new ScreenLogic.FindUnits();
finder.on('serverFound', server => {
finder.close()
finder.close();
unit = new ScreenLogic.UnitConnection(server)
unit = new ScreenLogic.UnitConnection(server);
unit.on('loggedIn', () => {
done()
})
done();
});
unit.connect()
})
unit.connect();
});
finder.search();
})
});
after(() => {
unit.close()
})
unit.close();
});
let circuit
let circuit;
it('gets pool status', done => {
unit.on('poolStatus', status => {
circuit = status.circuitArray[0]
done()
})
circuit = status.circuitArray[0];
done();
});
unit.getPoolStatus()
})
unit.getPoolStatus();
});
it('gets controller config', done => {
unit.on('controllerConfig', config => { done() })
unit.getControllerConfig()
})
unit.on('controllerConfig', config => {
done();
});
unit.getControllerConfig();
});
it('gets chemical data', done => {
unit.on('chemicalData', () => { done() })
unit.getChemicalData()
})
unit.on('chemicalData', () => {
done();
});
unit.getChemicalData();
});
it('gets salt cell config', done => {
unit.on('saltCellConfig', () => { done() })
unit.getSaltCellConfig()
})
unit.on('saltCellConfig', () => {
done();
});
unit.getSaltCellConfig();
});
it('gets version', done => {
unit.on('version', () => { done() })
unit.getVersion()
})
unit.on('version', () => {
done();
});
unit.getVersion();
});
it('sets circuit state', done => {
unit.on('circuitStateChanged', () => { done() })
unit.setCircuitState(0, circuit.id, circuit.state)
})
})
unit.on('circuitStateChanged', () => {
done();
});
unit.setCircuitState(0, circuit.id, circuit.state);
});
});