23
README.md
23
README.md
@ -33,6 +33,7 @@ Tested with a Pentair ScreenLogic system on firmware versions 5.2 Build 736.0 Re
|
||||
* [SLCancelDelay](#slcanceldelay)
|
||||
* [SLAddClient](#sladdclient)
|
||||
* [SLRemoveClient](#slremoveclient)
|
||||
* [SLGetSystemTime](#slgetsystemtime)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -290,6 +291,10 @@ Registers to receive updates from controller when something changes. Takes a ran
|
||||
|
||||
No longer receive `poolStatus` messages from controller. Emits the `removeClient` event when the request to remove a client is acknowledged. Takes a random number `clientId` that should match a previously registered client with `addClient`. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getSystemTime(senderId)
|
||||
|
||||
Retrieves the current time the system is set to. Emits the `getSystemTime` event when response is received. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
### 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.
|
||||
@ -314,6 +319,7 @@ No longer receive `poolStatus` messages from controller. Emits the `removeClient
|
||||
* `cancelDelay` - Indicates that a response to `cancelDelay()` has been received. Event handler receives a [`SLCancelDelay`](#slcanceldelay) object.
|
||||
* `addClient` - Indicates that a response to `addClient()` has been received. Event handler receives a [`SLAddClient`](#sladdclient) object.
|
||||
* `removeClient` - Indicates that a response to `removeClient()` has been received. Event handler receives a [`SLRemoveClient`](#slremoveclient) object.
|
||||
* `getSystemTime` - Indicates that a response to `getSystemTime()` has been received. Event handler receives a [`SLGetSystemTime`](#slgetsystemtime) object.
|
||||
* `loginFailed` - Indicates that a remote login attempt via supplying a system address and password to `UnitConnection` has failed likely due to the incorrect password being used.
|
||||
* `badParameter` - Indicates that a bad parameter has been supplied to a function. This can be triggered, for example, by sending the wrong controller ID to a `set` function.
|
||||
* `error` - Indicates that an unhandled error was caught (such as the connection timing out)
|
||||
@ -760,3 +766,20 @@ Passed as an argument to the emitted `addClient` event.
|
||||
### SLRemoveClient
|
||||
|
||||
Passed as an argument to the emitted `removeClient` event.
|
||||
|
||||
### SLGetSystemTime
|
||||
|
||||
Contains information about the system's current time and date. Passed as an argument to the emitted `getSystemTime` event.
|
||||
|
||||
#### Properties
|
||||
|
||||
* `year` - short representing current system year
|
||||
* `month` - short representing current system month (where 1 is January, 2 is February, etc.)
|
||||
* `day` - short representing current system day of the month
|
||||
* `dayOfWeek` - short representing current system day of the week (where 0 is Monday and 6 is Sunday)
|
||||
* `hour` - short representing current system hour (24-hour time where 0 is midnight, 13 is 1PM, etc.)
|
||||
* `minute` - short representing current system minute
|
||||
* `second` - short representing current system second
|
||||
* `millisecond` - short representing current system millisecond
|
||||
* `adjustForDST` - bool indicating whether the system should adjust for daylight saving time or not
|
||||
* `date` - `Date` instance representing the current system datetime (convenience, constructed from the above properties)
|
||||
|
9
index.js
9
index.js
@ -297,6 +297,11 @@ class UnitConnection extends EventEmitter {
|
||||
this.client.write(new messages.SLRemoveClient(clientId, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getSystemTime(senderId) {
|
||||
debugUnit('[%d] sending get system time query...', senderId || 0);
|
||||
this.client.write(new messages.SLGetSystemTime(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
onClientMessage(msg) {
|
||||
debugUnit('received message of length %d', msg.length);
|
||||
if (msg.length < 4) {
|
||||
@ -402,6 +407,10 @@ class UnitConnection extends EventEmitter {
|
||||
debugUnit(" it's async pool status");
|
||||
this.emit('poolStatus', new messages.SLPoolStatusMessage(msg));
|
||||
break;
|
||||
case messages.SLGetSystemTime.getResponseId():
|
||||
debugUnit(" it's system time");
|
||||
this.emit('getSystemTime', new messages.SLGetSystemTime(msg));
|
||||
break;
|
||||
case 12501:
|
||||
debugUnit(" it's a schedule changed notification");
|
||||
this.emit('scheduleChanged');
|
||||
|
37
messages/SLGetSystemTime.js
Normal file
37
messages/SLGetSystemTime.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
|
||||
const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
|
||||
const MSG_ID = 8110;
|
||||
|
||||
exports.SLGetSystemTime = class SLGetSystemTime extends SLMessage {
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
}
|
||||
}
|
||||
|
||||
decode() {
|
||||
super.decode();
|
||||
|
||||
this.year = this.readUInt16LE();
|
||||
this.month = this.readUInt16LE();
|
||||
this.dayOfWeek = this.readUInt16LE();
|
||||
this.day = this.readUInt16LE();
|
||||
this.hour = this.readUInt16LE();
|
||||
this.minute = this.readUInt16LE();
|
||||
this.second = this.readUInt16LE();
|
||||
this.millisecond = this.readUInt16LE();
|
||||
var adjustForDST = this.readInt32LE();
|
||||
this.adjustForDST = adjustForDST === 1;
|
||||
|
||||
this.date = new Date(this.year, this.month - 1, this.day, this.hour, this.minute, this.second);
|
||||
}
|
||||
|
||||
static getResponseId() {
|
||||
return MSG_ID + 1;
|
||||
}
|
||||
};
|
@ -25,3 +25,4 @@ exports.SLSetPumpFlow = require('./SLSetPumpFlow.js').SLSetPumpFlow;
|
||||
exports.SLCancelDelay = require('./SLCancelDelay.js').SLCancelDelay;
|
||||
exports.SLAddClient = require('./SLAddClient.js').SLAddClient;
|
||||
exports.SLRemoveClient = require('./SLRemoveClient.js').SLRemoveClient;
|
||||
exports.SLGetSystemTime = require('./SLGetSystemTime.js').SLGetSystemTime;
|
||||
|
Reference in New Issue
Block a user