Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
5f5b52f1ab
|
|||
7f76cb2a54
|
|||
863cd7b1e6 | |||
a53909eaa2
|
|||
27bdf0380e
|
|||
8294947f8c
|
|||
b0225c69bd
|
|||
89b8775ce3
|
|||
ab36d17a38
|
|||
c36e4cbaa2
|
|||
df22901ea1
|
|||
b23f488822
|
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
71
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 8 * * 3'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: ['javascript']
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
4
.github/workflows/nodejs.yml
vendored
4
.github/workflows/nodejs.yml
vendored
@ -5,9 +5,9 @@ name: Node.js CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v1.6.0 - 2020-06-14
|
||||
## v1.6.1 - 2020-11-23
|
||||
|
||||
### Added
|
||||
|
||||
* Every call now can optionally specify an ID that will be returned with the result, allowing tracking of simultaneous commands.
|
||||
|
||||
## v1.6.0 - 2020-07-14
|
||||
|
||||
### Added
|
||||
|
||||
@ -20,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
* ScreenLogic.HEAT_MODE_DONTCHANGE
|
||||
* Debug logs using the "debug" NPM package. You'll need to run an `npm install` after updating to this version.
|
||||
* Ability to cancel delays in pool equipment. #20 - thanks @bshep
|
||||
* Ability to register for push messages from the equipment so the connection can be kept open instead of repeatedly reconnecting and polling for changes. See the `addClient()` and `removeClient()` functions on the `UnitConnection` docs.
|
||||
* Ability to register for push messages from the equipment so the connection can be kept open instead of repeatedly reconnecting and polling for changes. See the `addClient()` and `removeClient()` functions on the `UnitConnection` docs. Thanks @bshep
|
||||
|
||||
## v1.5.0 - 2020-06-06
|
||||
|
||||
|
175
README.md
175
README.md
@ -2,7 +2,37 @@
|
||||
|
||||
This is a Node.JS library for interfacing with Pentair ScreenLogic systems over your local network or remotely through the Pentair dispatcher. Local connections require a Pentair ScreenLogic device on the same network (a network which supports UDP broadcasts).
|
||||
|
||||
Tested on node v8.11.1, v10.15.1 with a system on firmware versions 5.2 Build 736.0 Rel, 5.2 Build 738.0 Rel
|
||||
Tested with a Pentair ScreenLogic system on firmware versions 5.2 Build 736.0 Rel, 5.2 Build 738.0 Rel
|
||||
|
||||
* [Usage](#usage)
|
||||
* [Notes](#notes)
|
||||
* [Packet format](#packet-format)
|
||||
* [API reference](#api-reference)
|
||||
* [FindUnits](#findunits)
|
||||
* [RemoteLogin](#remotelogin)
|
||||
* [UnitConnection](#unitconnection)
|
||||
* [All messages](#all-messages)
|
||||
* [SLVersionMessage](#slversionmessage)
|
||||
* [SLPoolStatusMessage](#slpoolstatusmessage)
|
||||
* [SLChemDataMessage](#slchemdatamessage)
|
||||
* [SLSaltCellConfigMessage](#slsaltcellconfigmessage)
|
||||
* [SLSetSaltCellConfigMessage](#slsetsaltcellconfigmessage)
|
||||
* [SLControllerConfigMessage](#slcontrollerconfigmessage)
|
||||
* [SLSetCircuitStateMessage](#slsetcircuitstatemessage)
|
||||
* [SLSetHeatSetPointMessage](#slsetheatsetpointmessage)
|
||||
* [SLSetHeatModeMessage](#slsetheatmodemessage)
|
||||
* [SLLightControlMessage](#sllightcontrolmessage)
|
||||
* [SLGetGatewayDataMessage](#slgetgatewaydatamessage)
|
||||
* [SLAddNewScheduleEvent](#sladdnewscheduleevent)
|
||||
* [SLDeleteScheduleEventById](#sldeletescheduleeventbyid)
|
||||
* [SLGetScheduleData](#slgetscheduledata)
|
||||
* [SLSetScheduleEventById](#slsetscheduleeventbyid)
|
||||
* [SLSetCircuitRuntimeById](#slsetcircuitruntimebyid)
|
||||
* [SLGetPumpStatus](#slgetpumpstatus)
|
||||
* [SLSetPumpFlow](#slsetpumpflow)
|
||||
* [SLCancelDelay](#slcanceldelay)
|
||||
* [SLAddClient](#sladdclient)
|
||||
* [SLRemoveClient](#slremoveclient)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -178,87 +208,87 @@ client.connect();
|
||||
|
||||
Closes the connection.
|
||||
|
||||
#### getVersion()
|
||||
#### getVersion(senderId)
|
||||
|
||||
Requests the system version string from the connected unit. Emits the `version` event when the response comes back.
|
||||
Requests the system version string from the connected unit. Emits the `version` event when the response comes back. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getPoolStatus()
|
||||
#### getPoolStatus(senderId)
|
||||
|
||||
Requests pool status from the connected unit. Emits the `poolStatus` event when the response comes back.
|
||||
Requests pool status from the connected unit. Emits the `poolStatus` event when the response comes back. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getChemicalData()
|
||||
#### getChemicalData(senderId)
|
||||
|
||||
Requests chemical data from the connected unit (may require an IntelliChem or similar). Emits the `chemicalData` event when the response comes back.
|
||||
Requests chemical data from the connected unit (may require an IntelliChem or similar). Emits the `chemicalData` event when the response comes back. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getSaltCellConfig()
|
||||
#### getSaltCellConfig(senderId)
|
||||
|
||||
Requests salt cell status/configuration from the connected unit (requires an IntelliChlor or compatible salt cell). Emits the `saltCellConfig` event when the response comes back.
|
||||
Requests salt cell status/configuration from the connected unit (requires an IntelliChlor or compatible salt cell). Emits the `saltCellConfig` event when the response comes back. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getControllerConfig()
|
||||
#### getControllerConfig(senderId)
|
||||
|
||||
Requests controller configuration from the connected unit. Emits the `controllerConfig` event when the response comes back.
|
||||
Requests controller configuration from the connected unit. Emits the `controllerConfig` event when the response comes back. `senderId` isan optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setCircuitState(controllerId, circuitId, circuitState)
|
||||
#### setCircuitState(controllerId, circuitId, circuitState, senderId)
|
||||
|
||||
Activates or deactivates a circuit. See [`SLSetCircuitStateMessage`](#slsetcircuitstatemessage) documentation for argument values. Emits the `circuitStateChanged` event when response is acknowledged.
|
||||
Activates or deactivates a circuit. See [`SLSetCircuitStateMessage`](#slsetcircuitstatemessage) documentation for argument values. Emits the `circuitStateChanged` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setSetPoint(controllerId, bodyType, temperature)
|
||||
#### setSetPoint(controllerId, bodyType, temperature, senderId)
|
||||
|
||||
Sets the heating setpoint for any body. See [`SLSetHeatSetPointMessage`](#slsetheatsetpointmessage) documentation for argument values. Emits the `setPointChanged` event when response is acknowledged.
|
||||
Sets the heating setpoint for any body. See [`SLSetHeatSetPointMessage`](#slsetheatsetpointmessage) documentation for argument values. Emits the `setPointChanged` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setHeatMode(controllerId, bodyType, heatMode)
|
||||
#### setHeatMode(controllerId, bodyType, heatMode, senderId)
|
||||
|
||||
Sets the preferred heat mode. See [`SLSetHeatModeMessage`](#slsetheatmodemessage) documentation for argument values. Emits the `heatModeChanged` event when response is acknowledged.
|
||||
Sets the preferred heat mode. See [`SLSetHeatModeMessage`](#slsetheatmodemessage) documentation for argument values. Emits the `heatModeChanged` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### sendLightCommand(controllerId, command)
|
||||
#### sendLightCommand(controllerId, command, senderId)
|
||||
|
||||
Sends a lighting command. See [`SLLightControlMessage`](#sllightcontrolmessage) documentation for argument values. Emits the `sentLightCommand` event when response is acknowledged.
|
||||
Sends a lighting command. See [`SLLightControlMessage`](#sllightcontrolmessage) documentation for argument values. Emits the `sentLightCommand` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
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)
|
||||
#### setSaltCellOutput(controllerId, poolOutput, spaOutput, senderId)
|
||||
|
||||
Sets the salt cell's output levels. See [`SLSetSaltCellConfigMessage`](#slsetsaltcellconfigmessage) documentation for argument values. Emits the `setSaltCellConfig` event when response is acknowledged.
|
||||
Sets the salt cell's output levels. See [`SLSetSaltCellConfigMessage`](#slsetsaltcellconfigmessage) documentation for argument values. Emits the `setSaltCellConfig` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getScheduleData(scheduleType)
|
||||
#### getScheduleData(scheduleType, senderId)
|
||||
|
||||
Retrieves a list of schedule events of the specified type. See [`SLGetScheduleData`](#slgetscheduledata) documentation for argument values. Emits the `getScheduleData` event when response is acknowledged.
|
||||
Retrieves a list of schedule events of the specified type. See [`SLGetScheduleData`](#slgetscheduledata) documentation for argument values. Emits the `getScheduleData` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### addNewScheduleEvent(scheduleType)
|
||||
#### addNewScheduleEvent(scheduleType, senderId)
|
||||
|
||||
Adds a new event to the specified schedule type. See [`SLAddNewScheduleEvent`](#sladdnewscheduleevent) documentation for argument values. Emits the `addNewScheduleEvent` event when response is acknowledged.
|
||||
Adds a new event to the specified schedule type. See [`SLAddNewScheduleEvent`](#sladdnewscheduleevent) documentation for argument values. Emits the `addNewScheduleEvent` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### deleteScheduleEventById(scheduleId)
|
||||
#### deleteScheduleEventById(scheduleId, senderId)
|
||||
|
||||
Deletes a scheduled event with specified id. See [`SLDeleteScheduleEventById`](#sldeletescheduleeventbyid) documentation for argument values. Emits the `deleteScheduleById` event when response is acknowledged.
|
||||
Deletes a scheduled event with specified id. See [`SLDeleteScheduleEventById`](#sldeletescheduleeventbyid) documentation for argument values. Emits the `deleteScheduleById` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setScheduleEventById(scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint)
|
||||
#### setScheduleEventById(scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint, senderId)
|
||||
|
||||
Configures a schedule event. See [`SLSetScheduleEventById`](#slsetscheduleeventbyid) documentation for argument values. Emits the `setScheduleEventById` event when response is acknowledged.
|
||||
Configures a schedule event. See [`SLSetScheduleEventById`](#slsetscheduleeventbyid) documentation for argument values. Emits the `setScheduleEventById` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setCircuitRuntimebyId(circuitId, runTime)
|
||||
#### setCircuitRuntimebyId(circuitId, runTime, senderId)
|
||||
|
||||
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. See [`SLSetCircuitRuntimeById`](#slsetcircuitruntimebyid) documentation for argument values. Emits the `setCircuitRuntimeById` event when response is acknowledged.
|
||||
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. See [`SLSetCircuitRuntimeById`](#slsetcircuitruntimebyid) documentation for argument values. Emits the `setCircuitRuntimeById` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### getPumpStatus(pumpId)
|
||||
#### getPumpStatus(pumpId, senderId)
|
||||
|
||||
Gets information about the specified pump. See [`SLGetPumpStatus`](#slgetpumpstatus) documentation for argument values. Emits the `getPumpStatus` event when response is acknowledged.
|
||||
Gets information about the specified pump. See [`SLGetPumpStatus`](#slgetpumpstatus) documentation for argument values. Emits the `getPumpStatus` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### setPumpFlow(pumpId, circuitId, setPoint, isRPMs)
|
||||
#### setPumpFlow(pumpId, circuitId, setPoint, isRPMs, senderId)
|
||||
|
||||
Sets flow setting for a pump/circuit combination. See [`SLSetPumpFlow`](#slsetpumpflow) documentation for argument values. Emits the `setPumpFlow` event when response is acknowledged.
|
||||
Sets flow setting for a pump/circuit combination. See [`SLSetPumpFlow`](#slsetpumpflow) documentation for argument values. Emits the `setPumpFlow` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### cancelDelay()
|
||||
#### cancelDelay(senderId)
|
||||
|
||||
Cancels any delays on the system. See [`SLCancelDelay`](#slcanceldelay) documentation. Emits the `cancelDelay` event when response is acknowledged.
|
||||
Cancels any delays on the system. See [`SLCancelDelay`](#slcanceldelay) documentation. Emits the `cancelDelay` event when response is acknowledged. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### addClient(senderId)
|
||||
#### addClient(clientId, senderId)
|
||||
|
||||
Registers to receive updates from controller when something changes. Takes a random number `senderId` to identify the client. Emits the `poolStatus` event when something changes on the controller.
|
||||
Registers to receive updates from controller when something changes. Takes a random number `clientId` to identify the client. Emits the `poolStatus` event when something changes on the controller. `senderId` is an optional 16-bit integer and will be present as the `senderId` field on the returned message.
|
||||
|
||||
#### removeClient(senderId)
|
||||
#### removeClient(clientId, senderId)
|
||||
|
||||
No longer receive `poolStatus` messages from controller. Takes a random number `senderId` that should match a previously registered client with `addClient`.
|
||||
No longer receive `poolStatus` messages from controller. 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.
|
||||
|
||||
### Events
|
||||
|
||||
@ -295,6 +325,49 @@ No longer receive `poolStatus` messages from controller. Takes a random number `
|
||||
* `gatewaySubtype` - byte
|
||||
* `gatewayName` - string representing the server's name. Will be in the format Pentair: xx-xx-xx
|
||||
|
||||
### All messages
|
||||
|
||||
Information about features common to all the below SL Message types.
|
||||
|
||||
#### decodeTime(time)
|
||||
|
||||
Interprets a time integer recorded as minutes past midnight and returns the ScreenLogic string representation of it in 24-hour time.
|
||||
|
||||
#### encodeTime(time)
|
||||
|
||||
Interprets the string representing 24-hour time and returns an integer of minutes past midnight.
|
||||
|
||||
#### decodeDayMask(mask)
|
||||
|
||||
Converts a day mask from, for example, `SLGetScheduleData`'s events[idx].days property into a `DAY_VALUES` array for ease of use.
|
||||
|
||||
#### encodeDayMask(days)
|
||||
|
||||
Converts an array of DAY_VALUES into a mask used by, for example, `SLGetScheduleData`'s events[idx].days property.
|
||||
|
||||
#### getDayValue(dayName)
|
||||
|
||||
Returns the value of a given `DAY_VALUES` day name.
|
||||
|
||||
`DAY_VALUES` is defined as the following array for simplicity of checking whether a specific day is set in a mask:
|
||||
|
||||
```js
|
||||
const DAY_VALUES = [
|
||||
['Mon', 0x1 ],
|
||||
['Tue', 0x2 ],
|
||||
['Wed', 0x4 ],
|
||||
['Thu', 0x8 ],
|
||||
['Fri', 0x10 ],
|
||||
['Sat', 0x20 ],
|
||||
['Sun', 0x40 ],
|
||||
];
|
||||
```
|
||||
|
||||
#### Properties
|
||||
|
||||
* `senderId` - an integer matching whatever was passed as the `senderId` argument when making the initial request (default 0)
|
||||
* `messageId` - an integer indicating the ScreenLogic ID for this message
|
||||
|
||||
### SLVersionMessage
|
||||
|
||||
Passed as an argument to the emitted `version` event handler.
|
||||
@ -395,7 +468,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
|
||||
|
||||
@ -484,7 +557,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
|
||||
|
||||
@ -496,7 +569,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
|
||||
|
||||
@ -507,7 +580,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
|
||||
|
||||
@ -523,7 +596,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
|
||||
|
||||
@ -613,7 +686,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
|
||||
|
||||
@ -647,7 +720,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
|
||||
|
||||
@ -658,12 +731,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.
|
||||
|
146
index.js
146
index.js
@ -191,110 +191,110 @@ class UnitConnection extends EventEmitter {
|
||||
this.client.write(new messages.SLLoginMessage(password).toBuffer());
|
||||
}
|
||||
|
||||
getPoolStatus() {
|
||||
debugUnit('sending pool status query...');
|
||||
this.client.write(new messages.SLPoolStatusMessage().toBuffer());
|
||||
getPoolStatus(senderId) {
|
||||
debugUnit('[%d] sending pool status query...', senderId || 0);
|
||||
this.client.write(new messages.SLPoolStatusMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getControllerConfig() {
|
||||
debugUnit('sending controller config query...');
|
||||
this.client.write(new messages.SLControllerConfigMessage().toBuffer());
|
||||
getControllerConfig(senderId) {
|
||||
debugUnit('[%d] sending controller config query...', senderId || 0);
|
||||
this.client.write(new messages.SLControllerConfigMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getChemicalData() {
|
||||
debugUnit('sending chemical data query...');
|
||||
this.client.write(new messages.SLChemDataMessage().toBuffer());
|
||||
getChemicalData(senderId) {
|
||||
debugUnit('[%d] sending chemical data query...', senderId || 0);
|
||||
this.client.write(new messages.SLChemDataMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getSaltCellConfig() {
|
||||
debugUnit('sending salt cell config query...');
|
||||
this.client.write(new messages.SLSaltCellConfigMessage().toBuffer());
|
||||
getSaltCellConfig(senderId) {
|
||||
debugUnit('[%d] sending salt cell config query...', senderId || 0);
|
||||
this.client.write(new messages.SLSaltCellConfigMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getVersion() {
|
||||
debugUnit('sending version query...');
|
||||
this.client.write(new messages.SLVersionMessage().toBuffer());
|
||||
getVersion(senderId) {
|
||||
debugUnit('[%d] sending version query...', senderId || 0);
|
||||
this.client.write(new messages.SLVersionMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getEquipmentConfiguration() {
|
||||
debugUnit('sending equipment configuration query...');
|
||||
this.client.write(new messages.SLEquipmentConfigurationMessage().toBuffer());
|
||||
getEquipmentConfiguration(senderId) {
|
||||
debugUnit('[%d] sending equipment configuration query...', senderId || 0);
|
||||
this.client.write(new messages.SLEquipmentConfigurationMessage(null, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setCircuitState(controllerId, circuitId, circuitState) {
|
||||
debugUnit('sending set circuit state command: controllerId: %d, circuitId: %d, circuitState: %d...', controllerId, circuitId, circuitState);
|
||||
this.client.write(new messages.SLSetCircuitStateMessage(controllerId, circuitId, circuitState).toBuffer());
|
||||
setCircuitState(controllerId, circuitId, circuitState, senderId) {
|
||||
debugUnit('[%d] sending set circuit state command: controllerId: %d, circuitId: %d, circuitState: %d...', senderId || 0, controllerId, circuitId, circuitState);
|
||||
this.client.write(new messages.SLSetCircuitStateMessage(controllerId, circuitId, circuitState, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setSetPoint(controllerId, bodyType, temperature) {
|
||||
debugUnit('sending set setpoint command: controllerId: %d, bodyType: %d, temperature: %d...', controllerId, bodyType, temperature);
|
||||
this.client.write(new messages.SLSetHeatSetPointMessage(controllerId, bodyType, temperature).toBuffer());
|
||||
setSetPoint(controllerId, bodyType, temperature, senderId) {
|
||||
debugUnit('[%d] sending set setpoint command: controllerId: %d, bodyType: %d, temperature: %d...', senderId || 0, controllerId, bodyType, temperature);
|
||||
this.client.write(new messages.SLSetHeatSetPointMessage(controllerId, bodyType, temperature, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setHeatMode(controllerId, bodyType, heatMode) {
|
||||
debugUnit('sending set heatmode command: controllerId: %d, bodyType: %d, heatMode: %d...', controllerId, bodyType, heatMode);
|
||||
this.client.write(new messages.SLSetHeatModeMessage(controllerId, bodyType, heatMode).toBuffer());
|
||||
setHeatMode(controllerId, bodyType, heatMode, senderId) {
|
||||
debugUnit('[%d] sending set heatmode command: controllerId: %d, bodyType: %d, heatMode: %d...', senderId || 0, controllerId, bodyType, heatMode);
|
||||
this.client.write(new messages.SLSetHeatModeMessage(controllerId, bodyType, heatMode, senderId).toBuffer());
|
||||
}
|
||||
|
||||
sendLightCommand(controllerId, command) {
|
||||
debugUnit('sending light command: controllerId: %d, command: %d...', controllerId, command);
|
||||
this.client.write(new messages.SLLightControlMessage(controllerId, command).toBuffer());
|
||||
sendLightCommand(controllerId, command, senderId) {
|
||||
debugUnit('[%d] sending light command: controllerId: %d, command: %d...', senderId || 0, controllerId, command);
|
||||
this.client.write(new messages.SLLightControlMessage(controllerId, command, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setSaltCellOutput(controllerId, poolOutput, spaOutput) {
|
||||
debugUnit('sending set saltcell output command: controllerId: %d, poolOutput: %d, spaOutput: %d...', controllerId, poolOutput, spaOutput);
|
||||
this.client.write(new messages.SLSetSaltCellConfigMessage(controllerId, poolOutput, spaOutput).toBuffer());
|
||||
setSaltCellOutput(controllerId, poolOutput, spaOutput, senderId) {
|
||||
debugUnit('[%d] sending set saltcell output command: controllerId: %d, poolOutput: %d, spaOutput: %d...', senderId || 0, controllerId, poolOutput, spaOutput);
|
||||
this.client.write(new messages.SLSetSaltCellConfigMessage(controllerId, poolOutput, spaOutput, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getScheduleData(scheduleType) {
|
||||
debugUnit('sending set schedule data query for scheduleType: %d...', scheduleType);
|
||||
this.client.write(new messages.SLGetScheduleData(null, scheduleType).toBuffer());
|
||||
getScheduleData(scheduleType, senderId) {
|
||||
debugUnit('[%d] sending set schedule data query for scheduleType: %d...', senderId || 0, scheduleType);
|
||||
this.client.write(new messages.SLGetScheduleData(null, scheduleType, senderId).toBuffer());
|
||||
}
|
||||
|
||||
addNewScheduleEvent(scheduleType) {
|
||||
debugUnit('sending add new schedule event command for scheduleType: %d...', scheduleType);
|
||||
this.client.write(new messages.SLAddNewScheduleEvent(null, scheduleType).toBuffer());
|
||||
addNewScheduleEvent(scheduleType, senderId) {
|
||||
debugUnit('[%d] sending add new schedule event command for scheduleType: %d...', senderId || 0, scheduleType);
|
||||
this.client.write(new messages.SLAddNewScheduleEvent(null, scheduleType, senderId).toBuffer());
|
||||
}
|
||||
|
||||
deleteScheduleEventById(scheduleId) {
|
||||
debugUnit('sending delete schedule event command for scheduleId: %d...', scheduleId);
|
||||
this.client.write(new messages.SLDeleteScheduleEventById(scheduleId).toBuffer());
|
||||
deleteScheduleEventById(scheduleId, senderId) {
|
||||
debugUnit('[%d] sending delete schedule event command for scheduleId: %d...', senderId || 0, scheduleId);
|
||||
this.client.write(new messages.SLDeleteScheduleEventById(scheduleId, senderId).toBuffer());
|
||||
}
|
||||
|
||||
// todo: should this just accept a SLSetScheduleEventById message instead of all these args?
|
||||
setScheduleEventById(scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint) {
|
||||
debugUnit('sending set schedule event command for scheduleId: %d, circuitId: %d, startTime: %d, stopTime: %d, dayMask: %d, flags: %d, heatCmd: %d, heatSetPoint: %d...', scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint);
|
||||
this.client.write(new messages.SLSetScheduleEventById(null, scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint).toBuffer());
|
||||
setScheduleEventById(scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint, senderId) {
|
||||
debugUnit('[%d] sending set schedule event command for scheduleId: %d, circuitId: %d, startTime: %d, stopTime: %d, dayMask: %d, flags: %d, heatCmd: %d, heatSetPoint: %d...', senderId || 0, scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint);
|
||||
this.client.write(new messages.SLSetScheduleEventById(null, scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setCircuitRuntimebyId(circuitId, runTime) {
|
||||
debugUnit('sending set circuit runtime command for circuitId: %d, runTime: %d...', circuitId, runTime);
|
||||
this.client.write(new messages.SLSetCircuitRuntimeById(circuitId, runTime).toBuffer());
|
||||
setCircuitRuntimebyId(circuitId, runTime, senderId) {
|
||||
debugUnit('[%d] sending set circuit runtime command for circuitId: %d, runTime: %d...', senderId || 0, circuitId, runTime);
|
||||
this.client.write(new messages.SLSetCircuitRuntimeById(circuitId, runTime, senderId).toBuffer());
|
||||
}
|
||||
|
||||
getPumpStatus(pumpId) {
|
||||
debugUnit('sending get pump status command for pumpId: %d...', pumpId);
|
||||
this.client.write(new messages.SLGetPumpStatus(null, pumpId).toBuffer());
|
||||
getPumpStatus(pumpId, senderId) {
|
||||
debugUnit('[%d] sending get pump status command for pumpId: %d...', senderId || 0, pumpId);
|
||||
this.client.write(new messages.SLGetPumpStatus(null, pumpId, senderId).toBuffer());
|
||||
}
|
||||
|
||||
setPumpFlow(pumpId, circuitId, setPoint, isRPMs) {
|
||||
debugUnit('sending set pump flow command for pumpId: %d, circuitId: %d, setPoint: %d, isRPMs: %d...', pumpId, circuitId, setPoint, isRPMs);
|
||||
this.client.write(new messages.SLSetPumpFlow(pumpId, circuitId, setPoint, isRPMs).toBuffer());
|
||||
setPumpFlow(pumpId, circuitId, setPoint, isRPMs, senderId) {
|
||||
debugUnit('[%d] sending set pump flow command for pumpId: %d, circuitId: %d, setPoint: %d, isRPMs: %d...', senderId || 0, pumpId, circuitId, setPoint, isRPMs);
|
||||
this.client.write(new messages.SLSetPumpFlow(pumpId, circuitId, setPoint, isRPMs, senderId).toBuffer());
|
||||
}
|
||||
|
||||
cancelDelay() {
|
||||
debugUnit('sending cancel delay command...');
|
||||
this.client.write(new messages.SLCancelDelay().toBuffer());
|
||||
cancelDelay(senderId) {
|
||||
debugUnit('[%d] sending cancel delay command...', senderId || 0);
|
||||
this.client.write(new messages.SLCancelDelay(senderId).toBuffer());
|
||||
}
|
||||
|
||||
addClient(senderId) {
|
||||
debugUnit('sending add client command...');
|
||||
this.client.write(new messages.SLAddClient(senderId).toBuffer());
|
||||
addClient(clientId, senderId) {
|
||||
debugUnit('[%d] sending add client command, clientId %d...', senderId || 0, clientId);
|
||||
this.client.write(new messages.SLAddClient(clientId, senderId).toBuffer());
|
||||
}
|
||||
|
||||
removeClient(senderId) {
|
||||
debugUnit('sending remove client command...');
|
||||
this.client.write(new messages.SLRemoveClient(senderId).toBuffer());
|
||||
removeClient(clientId, senderId) {
|
||||
debugUnit('[%d] sending remove client command, clientId %d...', senderId || 0, clientId);
|
||||
this.client.write(new messages.SLRemoveClient(clientId, senderId).toBuffer());
|
||||
}
|
||||
|
||||
onClientMessage(msg) {
|
||||
@ -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");
|
||||
|
@ -5,15 +5,20 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12522;
|
||||
|
||||
exports.SLAddClient = class SLAddClient extends SLMessage {
|
||||
constructor(senderId) {
|
||||
super(0, MSG_ID);
|
||||
constructor(clientId, senderId) {
|
||||
if (typeof clientId === 'object') {
|
||||
var size = clientId.readInt32LE(4) + 8;
|
||||
super(clientId, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.senderId = senderId;
|
||||
this.clientId = clientId;
|
||||
}
|
||||
}
|
||||
|
||||
encode() {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(this.senderId);
|
||||
this.writeInt32LE(this.clientId);
|
||||
|
||||
super.encode();
|
||||
}
|
||||
|
@ -6,23 +6,15 @@ const MSG_ID = 12544;
|
||||
|
||||
|
||||
exports.SLAddNewScheduleEvent = class SLAddNewScheduleEvent extends SLMessage {
|
||||
constructor(buf, scheduleType) {
|
||||
var size;
|
||||
constructor(buf, scheduleType, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
|
||||
if (!buf) {
|
||||
// console.log('Requested Schedule type = ', scheduleType);
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(scheduleType);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
|
||||
this.decode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,8 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12580;
|
||||
|
||||
exports.SLCancelDelay = class SLCancelDelay extends SLMessage {
|
||||
constructor() {
|
||||
super(0, MSG_ID);
|
||||
|
||||
constructor(senderId) {
|
||||
super(senderId, MSG_ID);
|
||||
}
|
||||
|
||||
encode() {
|
||||
|
@ -5,20 +5,14 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12592;
|
||||
|
||||
exports.SLChemDataMessage = class SLChemDataMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0); // controller index
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.decode();
|
||||
this.writeInt32LE(0); // controller index
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,21 +13,15 @@ const CIRCUIT_NAME_VALUE_MAP = [
|
||||
];
|
||||
|
||||
exports.SLControllerConfigMessage = class SLControllerConfigMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(0);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.decode();
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,8 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12546;
|
||||
|
||||
exports.SLDeleteScheduleEventById = class SLDeleteScheduleEventById extends SLMessage {
|
||||
constructor(scheduleId) {
|
||||
super(0, MSG_ID);
|
||||
constructor(scheduleId, senderId) {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(scheduleId);
|
||||
|
@ -5,21 +5,15 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12566;
|
||||
|
||||
exports.SLEquipmentConfigurationMessage = class SLEquipmentConfigurationMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(0);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.decode();
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,21 +5,15 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12584;
|
||||
|
||||
exports.SLGetPumpStatus = class SLGetPumpStatus extends SLMessage {
|
||||
constructor(buf, pumpId) {
|
||||
var size;
|
||||
constructor(buf, pumpId, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(pumpId);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
|
||||
this.decode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,22 +5,15 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12542;
|
||||
|
||||
exports.SLGetScheduleData = class SLGetScheduleData extends SLMessage {
|
||||
constructor(buf, scheduleType) {
|
||||
var size;
|
||||
constructor(buf, scheduleType, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(scheduleType);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
|
||||
this.decode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,16 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12556;
|
||||
|
||||
exports.SLLightControl = class SLLightControl extends SLMessage {
|
||||
constructor(controllerIndex, command) {
|
||||
super(0, MSG_ID);
|
||||
constructor(controllerIndex, command, senderId) {
|
||||
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() {
|
||||
|
@ -27,7 +27,7 @@ exports.SLMessage = class SLMessage extends SmartBuffer {
|
||||
this.writeUInt16LE(messageId || 0);
|
||||
|
||||
this._wroteSize = false;
|
||||
} else if (senderId) {
|
||||
} else if (typeof senderId === 'object') {
|
||||
this._wroteSize = true;
|
||||
var buffer = senderId;
|
||||
this.writeBuffer(buffer, 0);
|
||||
|
@ -9,20 +9,14 @@ const SPA_CIRCUIT_ID = 500;
|
||||
const POOL_CIRCUIT_ID = 505;
|
||||
|
||||
exports.SLPoolStatusMessage = class SLPoolStatusMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.decode();
|
||||
this.writeInt32LE(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,15 +5,20 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12524;
|
||||
|
||||
exports.SLRemoveClient = class SLRemoveClient extends SLMessage {
|
||||
constructor(senderId) {
|
||||
super(0, MSG_ID);
|
||||
constructor(clientId, senderId) {
|
||||
if (typeof clientId === 'object') {
|
||||
var size = clientId.readInt32LE(4) + 8;
|
||||
super(clientId, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.senderId = senderId;
|
||||
this.clientId = clientId;
|
||||
}
|
||||
}
|
||||
|
||||
encode() {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(this.senderId);
|
||||
this.writeInt32LE(this.clientId);
|
||||
|
||||
super.encode();
|
||||
}
|
||||
|
@ -5,20 +5,14 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12572;
|
||||
|
||||
exports.SLSaltCellConfigMessage = class SLSaltCellConfigMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0); // controller index
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
this.decode();
|
||||
this.writeInt32LE(0); // controller index
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,16 @@ const MSG_ID = 12550;
|
||||
|
||||
|
||||
exports.SLSetCircuitRuntimeById = class SLSetCircuitRuntimeById extends SLMessage {
|
||||
constructor(circuitId, runTime) {
|
||||
super(0, MSG_ID);
|
||||
constructor(circuitId, runTime, senderId) {
|
||||
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() {
|
||||
|
@ -5,12 +5,17 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12530;
|
||||
|
||||
exports.SLSetCircuitStateMessage = class SLSetCircuitStateMessage extends SLMessage {
|
||||
constructor(controllerId, circuitId, circuitState) {
|
||||
super(0, MSG_ID);
|
||||
constructor(controllerId, circuitId, circuitState, senderId) {
|
||||
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() {
|
||||
|
@ -5,14 +5,17 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12538;
|
||||
|
||||
exports.SLSetHeatMode = class SLSetHeatMode extends SLMessage {
|
||||
constructor(controllerIndex, bodyType, heatMode) {
|
||||
super(0, MSG_ID);
|
||||
constructor(controllerIndex, bodyType, heatMode, senderId) {
|
||||
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() {
|
||||
|
@ -5,12 +5,17 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12528;
|
||||
|
||||
exports.SLSetHeatSetPoint = class SLSetHeatSetPoint extends SLMessage {
|
||||
constructor(controllerIndex, bodyType, temperature) {
|
||||
super(0, MSG_ID);
|
||||
constructor(controllerIndex, bodyType, temperature, senderId) {
|
||||
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() {
|
||||
|
@ -5,16 +5,22 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12586;
|
||||
|
||||
exports.SLSetPumpFlow = class SLSetPumpFlow extends SLMessage {
|
||||
constructor(pumpId, circuitId, setPoint, isRPMs) {
|
||||
super(0, MSG_ID);
|
||||
this.pumpId = pumpId;
|
||||
this.circuitId = circuitId;
|
||||
this.setPoint = setPoint;
|
||||
|
||||
if (isRPMs === true) {
|
||||
this.isRPMs = 1;
|
||||
constructor(pumpId, circuitId, setPoint, isRPMs, senderId) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,17 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 12576;
|
||||
|
||||
exports.SLSetSaltCellConfigMessage = class SLSetSaltCellConfigMessage extends SLMessage {
|
||||
constructor(controllerIndex, poolOutput, spaOutput) {
|
||||
super(0, MSG_ID);
|
||||
constructor(controllerIndex, poolOutput, spaOutput, senderId) {
|
||||
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() {
|
||||
|
@ -6,15 +6,13 @@ const MSG_ID = 12548;
|
||||
|
||||
|
||||
exports.SLSetScheduleEventById = class SLSetScheduleEventById extends SLMessage {
|
||||
constructor(buf, scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint) {
|
||||
var size;
|
||||
constructor(buf, scheduleId, circuitId, startTime, stopTime, dayMask, flags, heatCmd, heatSetPoint, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
|
||||
|
||||
if (!buf) {
|
||||
this.writeInt32LE(0);
|
||||
this.writeInt32LE(scheduleId);
|
||||
this.writeInt32LE(circuitId);
|
||||
@ -24,11 +22,6 @@ exports.SLSetScheduleEventById = class SLSetScheduleEventById extends SLMessage
|
||||
this.writeInt32LE(flags);
|
||||
this.writeInt32LE(heatCmd);
|
||||
this.writeInt32LE(heatSetPoint);
|
||||
} else {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
|
||||
this.decode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,18 +5,12 @@ const SLMessage = require('./SLMessage.js').SLMessage;
|
||||
const MSG_ID = 8120;
|
||||
|
||||
exports.SLVersionMessage = class SLVersionMessage extends SLMessage {
|
||||
constructor(buf) {
|
||||
var size;
|
||||
constructor(buf, senderId) {
|
||||
if (buf) {
|
||||
size = buf.readInt32LE(4) + 8;
|
||||
}
|
||||
super(0, MSG_ID, size);
|
||||
|
||||
if (buf) {
|
||||
this._wroteSize = true;
|
||||
this.writeBuffer(buf, 0);
|
||||
|
||||
this.decode();
|
||||
var size = buf.readInt32LE(4) + 8;
|
||||
super(buf, MSG_ID, size);
|
||||
} else {
|
||||
super(senderId, MSG_ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
802
package-lock.json
generated
802
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@ -1,28 +1,28 @@
|
||||
{
|
||||
"name": "node-screenlogic",
|
||||
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
|
||||
"version": "1.6.0",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/parnic/node-screenlogic.git",
|
||||
"keywords": [
|
||||
"pentair",
|
||||
"pool",
|
||||
"screenlogic",
|
||||
"swimmingpool"
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"smart-buffer": "~4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.4.0",
|
||||
"eslint-config-strongloop": "^2.1.0",
|
||||
"mocha": "^8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.spec.js",
|
||||
"pretest": "eslint --ignore-path .gitignore .",
|
||||
"test-slmessage": "mocha test/slmessage.spec.js"
|
||||
}
|
||||
"name": "node-screenlogic",
|
||||
"description": "Tool for connecting to Pentair ScreenLogic systems on the local network",
|
||||
"version": "1.6.1",
|
||||
"main": "index.js",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/parnic/node-screenlogic.git",
|
||||
"keywords": [
|
||||
"pentair",
|
||||
"pool",
|
||||
"screenlogic",
|
||||
"swimmingpool"
|
||||
],
|
||||
"dependencies": {
|
||||
"debug": "^4.3.1",
|
||||
"smart-buffer": "~4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.14.0",
|
||||
"eslint-config-strongloop": "^2.1.0",
|
||||
"mocha": "^8.2.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha test/*.spec.js",
|
||||
"pretest": "eslint --ignore-path .gitignore .",
|
||||
"test-slmessage": "mocha test/slmessage.spec.js"
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
const ScreenLogic = require('../index');
|
||||
|
||||
// you'll need a ScreenLogic-enabled device on your network for this to succeed
|
||||
describe('Finder', () => {
|
||||
it('finds a server', done => {
|
||||
describe('Finder', function() {
|
||||
it('finds a server', function(done) {
|
||||
let finder = new ScreenLogic.FindUnits();
|
||||
finder.on('serverFound', server => {
|
||||
finder.close();
|
||||
|
@ -9,7 +9,7 @@ function slMessageLen(str) {
|
||||
return 4 + str.length + SLMessage.slackForAlignment(str.length);
|
||||
}
|
||||
|
||||
describe('SLMessage utilities', () => {
|
||||
describe('SLMessage utilities', function() {
|
||||
// message header = senderId, messageId, bodyLen.
|
||||
// senderId and messageId are int16's, so 2b each. bodyLen is an int32, so 4b. total 8b.
|
||||
let msgHeaderLen = 8;
|
||||
|
@ -1,11 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const ScreenLogic = require('../index');
|
||||
var assert = require('assert');
|
||||
|
||||
// you'll need a ScreenLogic-enabled device on your network for this to succeed
|
||||
describe('Unit', () => {
|
||||
describe('Unit', function() {
|
||||
let unit;
|
||||
before(done => {
|
||||
before(function(done) {
|
||||
let finder = new ScreenLogic.FindUnits();
|
||||
finder.on('serverFound', server => {
|
||||
finder.close();
|
||||
@ -21,50 +22,57 @@ describe('Unit', () => {
|
||||
finder.search();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
after(function() {
|
||||
unit.close();
|
||||
});
|
||||
|
||||
// let circuit;
|
||||
it('gets pool status', done => {
|
||||
it('gets pool status', function(done) {
|
||||
unit.on('poolStatus', status => {
|
||||
/* circuit = */status.circuitArray[0];
|
||||
assert.equal(status.senderId, 0);
|
||||
done();
|
||||
});
|
||||
|
||||
unit.getPoolStatus();
|
||||
});
|
||||
|
||||
it('gets controller config', done => {
|
||||
it('gets controller config', function(done) {
|
||||
unit.on('controllerConfig', config => {
|
||||
assert.equal(config.senderId, 42);
|
||||
done();
|
||||
});
|
||||
unit.getControllerConfig();
|
||||
|
||||
unit.getControllerConfig(42);
|
||||
});
|
||||
|
||||
it('gets chemical data', done => {
|
||||
unit.on('chemicalData', () => {
|
||||
it('gets chemical data', function(done) {
|
||||
unit.on('chemicalData', chemData => {
|
||||
assert.equal(chemData.senderId, 123);
|
||||
done();
|
||||
});
|
||||
unit.getChemicalData();
|
||||
|
||||
unit.getChemicalData(123);
|
||||
});
|
||||
|
||||
it('gets salt cell config', done => {
|
||||
unit.on('saltCellConfig', () => {
|
||||
it('gets salt cell config', function(done) {
|
||||
unit.on('saltCellConfig', saltConfig => {
|
||||
assert.equal(saltConfig.senderId, 0);
|
||||
done();
|
||||
});
|
||||
|
||||
unit.getSaltCellConfig();
|
||||
});
|
||||
|
||||
it('gets version', done => {
|
||||
unit.on('version', () => {
|
||||
it('gets version', function(done) {
|
||||
unit.on('version', version => {
|
||||
assert.equal(version.senderId, 41239);
|
||||
done();
|
||||
});
|
||||
unit.getVersion();
|
||||
|
||||
unit.getVersion(41239);
|
||||
});
|
||||
|
||||
/* uncomment this and the `circuit` stuff above to test setting state
|
||||
it('sets circuit state', done => {
|
||||
it('sets circuit state', function(done) {
|
||||
unit.on('circuitStateChanged', () => {
|
||||
done();
|
||||
});
|
||||
|
Reference in New Issue
Block a user