nodejs-poolcontroller 8.3.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.eslintrc.json +36 -36
  2. package/.github/ISSUE_TEMPLATE/1-bug-report.yml +84 -84
  3. package/.github/ISSUE_TEMPLATE/2-docs.md +12 -12
  4. package/.github/ISSUE_TEMPLATE/3-proposal.md +28 -28
  5. package/.github/ISSUE_TEMPLATE/config.yml +8 -8
  6. package/.github/copilot-instructions.md +63 -63
  7. package/.github/workflows/ghcr-publish.yml +67 -67
  8. package/AGENTS.md +597 -0
  9. package/CONTRIBUTING.md +74 -74
  10. package/Changelog +292 -284
  11. package/Dockerfile +62 -62
  12. package/Gruntfile.js +40 -40
  13. package/LICENSE +661 -661
  14. package/README.md +318 -309
  15. package/anslq25/MessagesMock.ts +221 -221
  16. package/anslq25/boards/MockBoardFactory.ts +49 -49
  17. package/anslq25/boards/MockEasyTouchBoard.ts +696 -696
  18. package/anslq25/boards/MockSystemBoard.ts +216 -216
  19. package/anslq25/chemistry/MockChlorinator.ts +98 -98
  20. package/anslq25/pumps/MockPump.ts +83 -83
  21. package/app.ts +115 -115
  22. package/config/Config.ts +0 -0
  23. package/config/VersionCheck.ts +0 -0
  24. package/controller/Constants.ts +809 -805
  25. package/controller/Equipment.ts +2688 -2664
  26. package/controller/Errors.ts +181 -181
  27. package/controller/Lockouts.ts +549 -549
  28. package/controller/State.ts +3738 -3701
  29. package/controller/boards/AquaLinkBoard.ts +1003 -1003
  30. package/controller/boards/BoardFactory.ts +53 -53
  31. package/controller/boards/EasyTouchBoard.ts +3202 -3202
  32. package/controller/boards/IntelliCenterBoard.ts +4393 -3899
  33. package/controller/boards/IntelliComBoard.ts +69 -69
  34. package/controller/boards/IntelliTouchBoard.ts +382 -382
  35. package/controller/boards/NixieBoard.ts +1944 -1944
  36. package/controller/boards/SunTouchBoard.ts +400 -400
  37. package/controller/boards/SystemBoard.ts +5268 -5268
  38. package/controller/comms/Comms.ts +1272 -1255
  39. package/controller/comms/ScreenLogic.ts +1665 -1665
  40. package/controller/comms/messages/Messages.ts +1433 -1406
  41. package/controller/comms/messages/config/ChlorinatorMessage.ts +5 -0
  42. package/controller/comms/messages/config/CircuitGroupMessage.ts +0 -0
  43. package/controller/comms/messages/config/CircuitMessage.ts +0 -0
  44. package/controller/comms/messages/config/ConfigMessage.ts +6 -0
  45. package/controller/comms/messages/config/CoverMessage.ts +0 -0
  46. package/controller/comms/messages/config/CustomNameMessage.ts +31 -31
  47. package/controller/comms/messages/config/EquipmentMessage.ts +216 -210
  48. package/controller/comms/messages/config/ExternalMessage.ts +96 -10
  49. package/controller/comms/messages/config/FeatureMessage.ts +0 -0
  50. package/controller/comms/messages/config/GeneralMessage.ts +0 -0
  51. package/controller/comms/messages/config/HeaterMessage.ts +0 -0
  52. package/controller/comms/messages/config/IntellichemMessage.ts +0 -0
  53. package/controller/comms/messages/config/OptionsMessage.ts +194 -174
  54. package/controller/comms/messages/config/PumpMessage.ts +0 -0
  55. package/controller/comms/messages/config/RemoteMessage.ts +0 -0
  56. package/controller/comms/messages/config/ScheduleMessage.ts +401 -390
  57. package/controller/comms/messages/config/SecurityMessage.ts +0 -0
  58. package/controller/comms/messages/config/ValveMessage.ts +0 -0
  59. package/controller/comms/messages/status/ChlorinatorStateMessage.ts +0 -0
  60. package/controller/comms/messages/status/EquipmentStateMessage.ts +1158 -822
  61. package/controller/comms/messages/status/HeaterStateMessage.ts +135 -135
  62. package/controller/comms/messages/status/IntelliChemStateMessage.ts +448 -448
  63. package/controller/comms/messages/status/IntelliValveStateMessage.ts +36 -36
  64. package/controller/comms/messages/status/PumpStateMessage.ts +0 -0
  65. package/controller/comms/messages/status/RegalModbusStateMessage.ts +410 -410
  66. package/controller/comms/messages/status/VersionMessage.ts +103 -41
  67. package/controller/nixie/Nixie.ts +173 -173
  68. package/controller/nixie/NixieEquipment.ts +104 -104
  69. package/controller/nixie/bodies/Body.ts +120 -120
  70. package/controller/nixie/bodies/Filter.ts +135 -135
  71. package/controller/nixie/chemistry/ChemController.ts +2724 -2724
  72. package/controller/nixie/chemistry/ChemDoser.ts +806 -806
  73. package/controller/nixie/chemistry/Chlorinator.ts +367 -367
  74. package/controller/nixie/circuits/Circuit.ts +478 -478
  75. package/controller/nixie/heaters/Heater.ts +834 -834
  76. package/controller/nixie/pumps/Pump.ts +1193 -1193
  77. package/controller/nixie/schedules/Schedule.ts +401 -401
  78. package/controller/nixie/valves/Valve.ts +170 -170
  79. package/defaultConfig.json +352 -352
  80. package/docker-compose.yml +31 -31
  81. package/logger/DataLogger.ts +448 -448
  82. package/logger/Logger.ts +448 -436
  83. package/package.json +58 -58
  84. package/sendSocket.js +32 -32
  85. package/tsconfig.json +25 -25
  86. package/types/express-multer.d.ts +32 -32
  87. package/web/Server.ts +1937 -1927
  88. package/web/bindings/aqualinkD.json +559 -559
  89. package/web/bindings/influxDB.json +1066 -1066
  90. package/web/bindings/mqtt.json +721 -721
  91. package/web/bindings/mqttAlt.json +746 -746
  92. package/web/bindings/rulesManager.json +54 -54
  93. package/web/bindings/smartThings-Hubitat.json +31 -31
  94. package/web/bindings/valveRelays.json +20 -20
  95. package/web/bindings/vera.json +25 -25
  96. package/web/interfaces/baseInterface.ts +188 -188
  97. package/web/interfaces/httpInterface.ts +148 -148
  98. package/web/interfaces/influxInterface.ts +283 -283
  99. package/web/interfaces/mqttInterface.ts +695 -695
  100. package/web/interfaces/ruleInterface.ts +101 -87
  101. package/web/services/config/Config.ts +1063 -1053
  102. package/web/services/config/ConfigSocket.ts +0 -0
  103. package/web/services/state/State.ts +0 -0
  104. package/web/services/state/StateSocket.ts +0 -0
  105. package/web/services/utilities/Utilities.ts +233 -233
package/README.md CHANGED
@@ -1,309 +1,318 @@
1
- ```diff
2
- - INTELLICENTER USERS: Do not upgrade Intellicenter to 2.006. Rollback to 1.064 to use this application.
3
- ```
4
- # nodejs-poolController - Version 8.3.0
5
-
6
- ## What is nodejs-poolController
7
-
8
- nodejs-poolController is an application to communicate and control your Pentair compatible pool equipment.
9
-
10
- * Want to include a low cost controller for your pool?
11
- * Want a web interface for your system?
12
- * Want to turn your pumps on remotely?
13
- * Want to have your home automation system talk to your pool?
14
- * Want to control your pumps or chlorinator without a pool controller?
15
-
16
- Equipment supported
17
- 1. Controllers: IntelliCenter, Intellitouch, EasyTouch, Nixie (standalone equimpent), Aqualink
18
- 1. Pumps: Intelliflow VS/VSF/VF, older models, relay controlled pumps, Whisperflo
19
- 1. Chlorinators: Intellichlor, Aqua-Rite and OEM brands
20
- 1. Heaters: Gas, solar, heatpump
21
- 1. Intellichem and Relay Equipment Manager (REM) chemical controllers
22
- 1. Intellivalve (coming soon)
23
- 1. Home Automation: SmartThings, Hubitat, ISY, Vera, Siri, Echo
24
- 1. Chemical probes (pH, ORP, flow sensors, EC, etc.)
25
-
26
- ## Latest Changes
27
- See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
28
-
29
- ## What's new in 8.3.0?
30
-
31
- 1. Configurable RS‑485 transmit pacing via new `controller.txDelays` for finer collision avoidance and throughput tuning.
32
- 2. Startup & config resilience: empty or invalid `config.json` now auto‑recreated from defaults, corrupt originals backed up.
33
- 3. Latitude / longitude environment overrides to eliminate early heliotrope warnings prior to UI configuration.
34
- 4. Version check enhancements: git detection, safer redirects, throttled polling, warning suppression.
35
- 5. Docker improvements: fixed Dockerfile and added docker‑compose example with named volumes & environment variable guidance.
36
- 6. Add workflow to build and publish docker images to GitHub Container registry.
37
- 7. Runtime requirements: elevated minimum Node.js version to 20+, safe dependency and security/patch updates.
38
-
39
- ## What's new in 8.1?
40
-
41
- Support for dual chlorinators with REM chem controllers. It is now possible to have two separate chlorinators controlled in 'dynamic' mode by two separate REM chems. Note: In order for REM chem to control each chlorinator, each needs to be on a dedicated RS-485 port (not shared with an OCP or any other chlorinator).
42
-
43
- ## What's new in 8.0?
44
-
45
- Screenlogic can now be used as a direct connection point. If you feel that integrating an RS-485 adapter is a bit too much, then this is an option for you. The preferred method is still RS-485 as it is more fully featured.
46
-
47
- ## What's new in 7.0?
48
-
49
- The current version includes very tight intergation with [relayEquipmentManager](https://github.com/rstrouse/relayEquipmentManager) which allows for hardware control over your ancillary pool equipment (chemical probes, pumps, tanks, heaters, pumps, etc).
50
-
51
- Starting with this version, all code will immediately be pushed to `master` branch. The version of a `next` branch for feature development will disappear.
52
-
53
-
54
- <a name="module_nodejs-poolController--install"></a>
55
-
56
- Dashpanel Client Screenshot
57
-
58
- <img src="https://tagyoureit.github.io/nodejs-poolController/images/v6/clients/dashPanel.png?raw=true" height="300">
59
-
60
- ## Installation Instructions
61
-
62
- This code requires a physical [RS485](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) adapter to work.
63
-
64
- This is only the server code. See [clients](#module_nodejs-poolController--clients) below for web or other ways to read/control the pool equipment.
65
-
66
- ### Prerequisites
67
- If you don't know anything about NodeJS, these directions might be helpful.
68
-
69
- 1. Install Nodejs (v20+ required). (https://nodejs.org/en/download/)
70
- 1. Update NPM (https://docs.npmjs.com/getting-started/installing-node).
71
- 1. It is recommended to clone the source code as updates are frequently pushed while releases are infrequent
72
- clone with `git clone https://github.com/tagyoureit/nodejs-poolController.git`
73
- (Alternate - not recommended - Download the latest [code release](https://github.com/tagyoureit/nodejs-poolController/releases)
74
- 1. Change directory into nodejs-poolController.
75
- 1. Run `npm install` in the new folder (where package.json exists). This will automatically install all the dependencies (serial-port, express, sockets.io, etc).
76
- 1. Run the app with `npm start`.
77
- * `npm start` will compile the Typescript code. You should use this every time you download/clone/pull the latest code.
78
- * `npm run start:cached` will run the app without compiling the code which can be much faster.
79
- 1. Install a [webclient](module_nodejs-poolController--clients) for a browser experience and/or a [binding](module_nodejs-poolController--bindings) to have two way control with Home Automation systems.
80
-
81
- For a very thorough walk-through, see [this](https://www.troublefreepool.com/threads/pentair-intellicenter-pool-control-dashboard-instructional-guide.218514/) great thread on Trouble Free Pool. Thanks @MyAZPool.
82
-
83
- #### Upgrade Instructions
84
- Assuming you cloned the repo, the following are easy steps to get the latest version:
85
- 1. Change directory to the njsPC app
86
- 2. **Important**: Ensure you have Node.js v20 or higher installed (`node --version`). If not, upgrade Node.js first.
87
- 3. `git pull`
88
- 4. **Important**: Run `npm i` to update dependencies. This is especially important when upgrading to version 8.3.0+ as it requires Node 20+ and has updated dependencies.
89
- 5. Start application as normal, or if using `npm run start:cached` then run `npm run build` to compile the code.
90
-
91
- ### Docker instructions
92
-
93
- See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Docker). Thanks @wurmr @andylippitt @emes.
94
-
95
- ### Docker Compose (Controller + Optional dashPanel UI)
96
-
97
- Below is an example `docker-compose.yml` snippet showing this controller (`njspc`) and an OPTIONAL dashPanel UI service (`njspc-dash`). The dashPanel image is published separately; uncomment if you want a built-in web dashboard on port 5150.
98
-
99
- ```yaml
100
- services:
101
- njspc:
102
- image: ghcr.io/sam2kb/njspc
103
- container_name: njspc
104
- restart: unless-stopped
105
- environment:
106
- - TZ=${TZ:-UTC}
107
- - NODE_ENV=production
108
- # Serial vs network connection options
109
- # - POOL_NET_CONNECT=true
110
- # - POOL_NET_HOST=raspberrypi
111
- # - POOL_NET_PORT=9801
112
- # Provide coordinates so sunrise/sunset (heliotrope) works immediately - change as needed
113
- - POOL_LATITUDE=28.5383
114
- - POOL_LONGITUDE=-81.3792
115
- ports:
116
- - "4200:4200"
117
- devices:
118
- - /dev/ttyACM0:/dev/ttyUSB0
119
- # Persistence (create host directories/files first)
120
- volumes:
121
- - ./server-config.json:/app/config.json # Persisted config file on host
122
- - njspc-data:/app/data # State & equipment snapshots
123
- - njspc-backups:/app/backups # Backup archives
124
- - njspc-logs:/app/logs # Logs
125
- - njspc-bindings:/app/web/bindings/custom # Custom bindings
126
- # OPTIONAL: If you get permission errors accessing /dev/tty*, prefer adding the container user to the host dialout/uucp group;
127
- # only as a last resort temporarily uncomment the two lines below to run privileged/root (less secure).
128
- # privileged: true
129
- # user: "0:0"
130
-
131
- njspc-dash:
132
- image: ghcr.io/sam2kb/njspc-dash
133
- container_name: njspc-dash
134
- restart: unless-stopped
135
- depends_on:
136
- - njspc
137
- environment:
138
- - TZ=${TZ:-UTC}
139
- - NODE_ENV=production
140
- - POOL_WEB_SERVICES_IP=njspc # Link to backend service name
141
- ports:
142
- - "5150:5150"
143
- volumes:
144
- - ./dash-config.json:/app/config.json
145
- - njspc-dash-data:/app/data
146
- - njspc-dash-logs:/app/logs
147
- - njspc-dash-uploads:/app/uploads
148
-
149
- volumes:
150
- njspc-data:
151
- njspc-backups:
152
- njspc-logs:
153
- njspc-bindings:
154
- njspc-dash-data:
155
- njspc-dash-logs:
156
- njspc-dash-uploads:
157
- ```
158
-
159
- Quick start:
160
- 1. Save compose file.
161
- 2. (Optional) create an empty config file: `touch dash-config.json`.
162
- 3. `docker compose up -d`
163
- 4. Visit Dash UI at: `http://localhost:5150`.
164
-
165
- Notes:
166
- * Provide either RS-485 device OR enable network (ScreenLogic) connection.
167
- * Coordinates env vars prevent heliotrope warnings before the panel reports location.
168
- * Persistence (controller):
169
- * `./server-config.json:/app/config.json` main runtime config. You can either:
170
- * Seed it with a copy of `defaultConfig.json` (`cp defaultConfig.json server-config.json`), OR
171
- * Start with an empty file and the app will auto-populate it from defaults on first launch. If the file exists but contains invalid JSON it will be backed up to `config.corrupt-<timestamp>.json` and regenerated.
172
- * Remaining state (data, backups, logs, custom bindings) is typically stored in named volumes in the provided compose for cleaner host directories. If you prefer bind mounts instead, replace the named volumes with host paths similar to the example below.
173
- * Data artifacts: `poolConfig.json`, `poolState.json` etc. live under `/app/data` (volume `njspc-data`).
174
- * Backups: `/app/backups` (volume `njspc-backups`).
175
- * Logs: `/app/logs` (volume `njspc-logs`).
176
- * Custom bindings: `/app/web/bindings/custom` (volume `njspc-bindings`).
177
- * To migrate from bind mounts to named volumes, stop the stack, `docker run --rm -v oldPath:/from -v newVolume:/to alpine sh -c 'cp -a /from/. /to/'` for each path, then update compose.
178
-
179
- ### Automate startup of app
180
- See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Automatically-start-at-boot---PM2-&-Systemd).
181
-
182
- # Clients & Bindings
183
- To do anything with this app, you need a client to connect to it. A client can be a web application or Home Automation system.
184
-
185
- <a name="module_nodejs-poolController--clients"></a>
186
-
187
- ## REM (Relay Equipment Manager)
188
- [Relay Equipment Manager](https://github.com/rstrouse/relayEquipmentManager) is a companion app developed by @rstrouse that integrates standalone hardware control. Controls GPIO, i2c, and SPI devices including:
189
- * Atlas Scientific pH, orp, ec, hum, prs, pmp, rtd
190
- * ADS1x15 a/d converters
191
- * Pressure Tranducers
192
- * Flow sensors
193
- * Temperature sensors (10k, NTC)
194
-
195
- ## Web Clients
196
- 1. [nodejs-poolController-dashPanel](https://github.com/rstrouse/nodejs-poolController-dashPanel). Full compatibility with IntelliCenter, *Touch, REM (RelayEquipmentManager).
197
-
198
-
199
- <a name="module_nodejs-poolController--bindings"></a>
200
-
201
- ## Home Automation Bindings (previously Integrations)
202
-
203
- Available automations:
204
- * [Vera Home Automation Hub](https://github.com/rstrouse/nodejs-poolController-veraPlugin) - A plugin that integrates with nodejs-poolController. [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#vera)
205
- * [Hubitat](https://github.com/bsileo/hubitat_poolcontroller) by @bsileo (prev help from @johnny2678, @donkarnag, @arrmo). [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#smartthingshubitat)
206
- * [Homebridge/Siri/EVE](https://github.com/gadget-monk/homebridge-poolcontroller) by @gadget-monk, adopted from @leftyflip
207
- * InfluxDB - [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#influx)
208
- * [MQTT](https://github.com/crsherman/nodejs-poolController-mqtt) original release by @crsherman, re-write by @kkzonie, testing by @baudfather and others. [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#mqtt)
209
- * [Homeseer](https://github.com/tagyoureit/nodejs-poolController/wiki/Homeseer-Setup-Instructions) - Integration directions by @miamijerry to integrate Homeseer through MQTT
210
-
211
- Outdated:
212
- * [Another SmartThings Controller](https://github.com/dhop90/pentair-pool-controller/blob/master/README.md) by @dhop90
213
- * [ISY](src/integrations/socketISY.js). Original credit to @blueman2, enhancements by @mayermd
214
- * [ISY Polyglot NodeServer](https://github.com/brianmtreese/nodejs-pool-controller-polyglotv2) created by @brianmtreese
215
-
216
- # Support
217
- 1. For discussions, recommendations, designs, and clarifications, we recommend you join the [Github discussions](https://github.com/tagyoureit/nodejs-poolController/discussions.
218
- 1. Check the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki) for tips, tricks and additional documentation.
219
- 1. For bug reports you can open a [github issue](https://github.com/tagyoureit/nodejs-poolController/issues/new),
220
-
221
-
222
- # Changes
223
- See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
224
-
225
- <a name="module_nodejs-poolController--config.json"></a>
226
- # Config.json changes
227
-
228
- ## Controller section - changes to the communications for the app
229
- Most of these can be configured directly from the UI in dashPanel.
230
- * `rs485Port` - set to the name of you rs485 controller. See [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) for details and testing.
231
- * `portSettings` - should not need to be changed for RS485
232
- * `mockPort` - opens a "fake" port for this app to communicate on. Can be used with [packet captures/replays](https://github.com/tagyoureit/nodejs-poolController/wiki/How-to-capture-all-packets-for-issue-resolution).
233
- * `netConnect` - used to connect via [Socat](https://github.com/tagyoureit/nodejs-poolController/wiki/Socat)
234
- * `netHost` and `netPort` - host and port for Socat connection.
235
- * `inactivityRetry` - # of seconds the app should wait before trying to reopen the port after no communications. If your equipment isn't on all the time or you are running a virtual controller you may want to dramatically increase the timeout so you don't get console warnings.
236
- * `txDelays` - (optional) fine‑grained transmit pacing controls added in 8.1+ to better coexist with busy or bridged (socat / multiple panel / dual chlorinator) RS‑485 buses. These values are all in milliseconds. If the block is omitted, internal defaults are used (see `defaultConfig.json`). All values can be hot‑reloaded from config.
237
- * `idleBeforeTxMs` Minimum quiet time on the bus (no RX or TX seen) before a new outbound frame may start. Helps avoid collisions just after another device finishes talking. Typical: 40‑80. Set to 0 to disable.
238
- * `interFrameDelayMs` Delay inserted between completed outbound attempts (success, retry scheduling, or queue drain) and evaluation of the next outbound message. Replaces the previous fixed 100ms. Typical: 30‑75. Lower values increase throughput but may raise collision / rewind counts.
239
- * `interByteDelayMs` Optional per‑byte pacing inside a single frame. Normally 0 (disabled). Set to 1‑2ms only if you observe hardware or USB adapter overruns, or are experimenting with very marginal wiring / long cable runs.
240
-
241
- Example tuning block - more conservative pacing for SunTouch that works way better than defaults:
242
-
243
- ```json
244
- "txDelays": {
245
- "idleBeforeTxMs": 60,
246
- "interFrameDelayMs": 50,
247
- "interByteDelayMs": 1
248
- }
249
- ```
250
-
251
- Tuning guidance:
252
- - Start with the defaults. Only change one value at a time and observe stats (collisions, retries, rewinds) via rs485PortStats.
253
- - If you see frequent outbound retries or receive rewinds, first raise `idleBeforeTxMs` in small steps (e.g. +10ms) before touching `interFrameDelayMs`.
254
- - If overall throughput feels sluggish but collisions are low, you may lower `interFrameDelayMs` gradually.
255
- - Use `interByteDelayMs` only as a last resort; it elongates every frame and reduces total bus capacity.
256
- - Setting any value too high will simply slow configuration bursts (e.g. on startup); setting them too low can cause more retries and ultimately lower effective throughput.
257
-
258
- All three parameters are safe to adjust without restarting; edits to `config.json` are picked up by the existing config watcher.
259
-
260
- ## Web section - controls various aspects of external communications
261
- * `servers` - setting for different servers/services
262
- * `http2` - not used currently
263
- * `http` - primary server used for api connections without secure communications
264
- * `enabled` - self-explanatory
265
- * `ip` - The ip of the network address to listen on. Default of `127.0.0.1` will only listen on the local loopback (localhost) adapter. `0.0.0.0` will listen on all network interfaces. Any other address will listen exclusively on that interface.
266
- * `port` - Port to listen on. Default is `4200`.
267
- * `httpsRedirect` - Redirect http traffic to https
268
- * `authentication` - Enable basic username/password authentication. (Not implemented yet.)
269
- * `authFile` - Location of the encrypted password file. By default, `/users.htpasswd`. If you have `authentication=1` then create the file users.htpasswd in the root of the application. Use a tool such as http://www.htaccesstools.com/htpasswd-generator/ and paste your user(s) into this file. You will now be prompted for authentication.
270
- * `https` - See http options above.
271
- * `sslKeyFile` - Location of key file
272
- * `sslCertFile` - Location of certificate file
273
- * `mdns` - Not currently used.
274
- * `ssdp` - Enable for automatic configuration by the webClient and other platforms.
275
-
276
-
277
- ## Log - Different aspects of logging to the application
278
- * `app` - Application wide settings
279
- * `enabled` - Enable/disable logging for the entire application
280
- * `level` - Different levels of logging from least to most: 'error', 'warn', 'info', 'verbose', 'debug', 'silly'
281
- * `packet` - Configuration for the
282
-
283
-
284
- # Credit
285
-
286
- 1. @Rstrouse for helping make the 6.0 rewrite and Intellicenter possible, continuing to make monumental changes, and driving this project forward in numerous ways. My knowledge of coding in general has benefitted greatly from working with him.
287
- 1. [Jason Young](http://www.sdyoung.com/home/decoding-the-pentair-easytouch-rs-485-protocol) (Read both posts, they are a great baseline for knowledge)
288
- 1. Michael Russe [ceesco](https://github.com/ceesco53/pentair_examples) [CocoonTech](http://cocoontech.com/forums/topic/13548-intelliflow-pump-rs485-protocol/?p=159671) - Registration required for CocoonTech. Jason Young used this material for his understanding in the protocol as well. There is a very detailed .txt file with great information ~~that I won't post unless I get permission~~. Looks like it was publicly posted to [Pastebin](http://pastebin.com/uiAmvNjG).
289
- 1. [Michael Usner](https://github.com/michaelusner/Home-Device-Controller) for taking the work of both of the above and turning it into Javascript code.
290
- 1. [rflemming](https://github.com/rflemming) for being the first to contribute some changes to the code.
291
- 1. Awesome help from @arrmo and @blueman2 on Gitter
292
-
293
- # License
294
-
295
- nodejs-poolController. An application to control pool equipment.
296
- Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025. Russell Goldin, tagyoureit. russ.goldin@gmail.com
297
-
298
- This program is free software: you can redistribute it and/or modify
299
- it under the terms of the GNU Affero General Public License as
300
- published by the Free Software Foundation, either version 3 of the
301
- License, or (at your option) any later version.
302
-
303
- This program is distributed in the hope that it will be useful,
304
- but WITHOUT ANY WARRANTY; without even the implied warranty of
305
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
306
- GNU Affero General Public License for more details.
307
-
308
- You should have received a copy of the GNU Affero General Public License
309
- along with this program. If not, see <http://www.gnu.org/licenses/>
1
+ # nodejs-poolController - Version 8.4.0
2
+
3
+ ```diff
4
+ + INTELLICENTER USERS: Firmware v3.004+ is supported, but still being refined. If you run into issues, please open a discussion and include a replay capture.
5
+ ```
6
+
7
+ ## What is nodejs-poolController
8
+
9
+ nodejs-poolController is an application to communicate and control your Pentair compatible pool equipment.
10
+
11
+ * Want to include a low cost controller for your pool?
12
+ * Want a web interface for your system?
13
+ * Want to turn your pumps on remotely?
14
+ * Want to have your home automation system talk to your pool?
15
+ * Want to control your pumps or chlorinator without a pool controller?
16
+
17
+ Equipment supported
18
+ 1. Controllers: IntelliCenter, Intellitouch, EasyTouch, Nixie (standalone equimpent), Aqualink
19
+ 1. Pumps: Intelliflow VS/VSF/VF, older models, relay controlled pumps, Whisperflo
20
+ 1. Chlorinators: Intellichlor, Aqua-Rite and OEM brands
21
+ 1. Heaters: Gas, solar, heatpump
22
+ 1. Intellichem and Relay Equipment Manager (REM) chemical controllers
23
+ 1. Intellivalve (coming soon)
24
+ 1. Home Automation: SmartThings, Hubitat, ISY, Vera, Siri, Echo
25
+ 1. Chemical probes (pH, ORP, flow sensors, EC, etc.)
26
+
27
+ ## Latest Changes
28
+ See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
29
+
30
+ ## What's new in 8.4.0?
31
+
32
+ 1. IntelliCenter v3.004+ support updates (still being refined): registration/config refresh handling, better source-of-truth gating, and improved stability.
33
+ 2. IntelliCenter v3.004+ circuit control: Action 184 support with learned Target IDs for more reliable circuit on/off behavior.
34
+ 3. v3.004+ parsing fixes: Wireless byte offsets, big-endian schedule times, and options/setpoint processing improvements.
35
+ 4. Reduced noise: longer device announce interval and better-scoped logging.
36
+
37
+ ## What's new in 8.3.0?
38
+
39
+ 1. Configurable RS‑485 transmit pacing via new `controller.txDelays` for finer collision avoidance and throughput tuning.
40
+ 2. Startup & config resilience: empty or invalid `config.json` now auto‑recreated from defaults, corrupt originals backed up.
41
+ 3. Latitude / longitude environment overrides to eliminate early heliotrope warnings prior to UI configuration.
42
+ 4. Version check enhancements: git detection, safer redirects, throttled polling, warning suppression.
43
+ 5. Docker improvements: fixed Dockerfile and added docker‑compose example with named volumes & environment variable guidance.
44
+ 6. Add workflow to build and publish docker images to GitHub Container registry.
45
+ 7. Runtime requirements: elevated minimum Node.js version to 20+, safe dependency and security/patch updates.
46
+
47
+ ## What's new in 8.1?
48
+
49
+ Support for dual chlorinators with REM chem controllers. It is now possible to have two separate chlorinators controlled in 'dynamic' mode by two separate REM chems. Note: In order for REM chem to control each chlorinator, each needs to be on a dedicated RS-485 port (not shared with an OCP or any other chlorinator).
50
+
51
+ ## What's new in 8.0?
52
+
53
+ Screenlogic can now be used as a direct connection point. If you feel that integrating an RS-485 adapter is a bit too much, then this is an option for you. The preferred method is still RS-485 as it is more fully featured.
54
+
55
+ ## What's new in 7.0?
56
+
57
+ The current version includes very tight intergation with [relayEquipmentManager](https://github.com/rstrouse/relayEquipmentManager) which allows for hardware control over your ancillary pool equipment (chemical probes, pumps, tanks, heaters, pumps, etc).
58
+
59
+ Starting with this version, all code will immediately be pushed to `master` branch. The version of a `next` branch for feature development will disappear.
60
+
61
+
62
+ <a name="module_nodejs-poolController--install"></a>
63
+
64
+ Dashpanel Client Screenshot
65
+
66
+ <img src="https://tagyoureit.github.io/nodejs-poolController/images/v6/clients/dashPanel.png?raw=true" height="300">
67
+
68
+ ## Installation Instructions
69
+
70
+ This code requires a physical [RS485](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) adapter to work.
71
+
72
+ This is only the server code. See [clients](#module_nodejs-poolController--clients) below for web or other ways to read/control the pool equipment.
73
+
74
+ ### Prerequisites
75
+ If you don't know anything about NodeJS, these directions might be helpful.
76
+
77
+ 1. Install Nodejs (v20+ required). (https://nodejs.org/en/download/)
78
+ 1. Update NPM (https://docs.npmjs.com/getting-started/installing-node).
79
+ 1. It is recommended to clone the source code as updates are frequently pushed while releases are infrequent
80
+ clone with `git clone https://github.com/tagyoureit/nodejs-poolController.git`
81
+ (Alternate - not recommended - Download the latest [code release](https://github.com/tagyoureit/nodejs-poolController/releases)
82
+ 1. Change directory into nodejs-poolController.
83
+ 1. Run `npm install` in the new folder (where package.json exists). This will automatically install all the dependencies (serial-port, express, sockets.io, etc).
84
+ 1. Run the app with `npm start`.
85
+ * `npm start` will compile the Typescript code. You should use this every time you download/clone/pull the latest code.
86
+ * `npm run start:cached` will run the app without compiling the code which can be much faster.
87
+ 1. Install a [webclient](module_nodejs-poolController--clients) for a browser experience and/or a [binding](module_nodejs-poolController--bindings) to have two way control with Home Automation systems.
88
+
89
+ For a very thorough walk-through, see [this](https://www.troublefreepool.com/threads/pentair-intellicenter-pool-control-dashboard-instructional-guide.218514/) great thread on Trouble Free Pool. Thanks @MyAZPool.
90
+
91
+ #### Upgrade Instructions
92
+ Assuming you cloned the repo, the following are easy steps to get the latest version:
93
+ 1. Change directory to the njsPC app
94
+ 2. **Important**: Ensure you have Node.js v20 or higher installed (`node --version`). If not, upgrade Node.js first.
95
+ 3. `git pull`
96
+ 4. **Important**: Run `npm i` to update dependencies. This is especially important when upgrading to version 8.3.0+ (including 8.4.0+) as it requires Node 20+ and has updated dependencies.
97
+ 5. Start application as normal, or if using `npm run start:cached` then run `npm run build` to compile the code.
98
+
99
+ ### Docker instructions
100
+
101
+ See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Docker). Thanks @wurmr @andylippitt @emes.
102
+
103
+ ### Docker Compose (Controller + Optional dashPanel UI)
104
+
105
+ Below is an example `docker-compose.yml` snippet showing this controller (`njspc`) and an OPTIONAL dashPanel UI service (`njspc-dash`). The dashPanel image is published separately; uncomment if you want a built-in web dashboard on port 5150.
106
+
107
+ ```yaml
108
+ services:
109
+ njspc:
110
+ image: ghcr.io/sam2kb/njspc
111
+ container_name: njspc
112
+ restart: unless-stopped
113
+ environment:
114
+ - TZ=${TZ:-UTC}
115
+ - NODE_ENV=production
116
+ # Serial vs network connection options
117
+ # - POOL_NET_CONNECT=true
118
+ # - POOL_NET_HOST=raspberrypi
119
+ # - POOL_NET_PORT=9801
120
+ # Provide coordinates so sunrise/sunset (heliotrope) works immediately - change as needed
121
+ - POOL_LATITUDE=28.5383
122
+ - POOL_LONGITUDE=-81.3792
123
+ ports:
124
+ - "4200:4200"
125
+ devices:
126
+ - /dev/ttyACM0:/dev/ttyUSB0
127
+ # Persistence (create host directories/files first)
128
+ volumes:
129
+ - ./server-config.json:/app/config.json # Persisted config file on host
130
+ - njspc-data:/app/data # State & equipment snapshots
131
+ - njspc-backups:/app/backups # Backup archives
132
+ - njspc-logs:/app/logs # Logs
133
+ - njspc-bindings:/app/web/bindings/custom # Custom bindings
134
+ # OPTIONAL: If you get permission errors accessing /dev/tty*, prefer adding the container user to the host dialout/uucp group;
135
+ # only as a last resort temporarily uncomment the two lines below to run privileged/root (less secure).
136
+ # privileged: true
137
+ # user: "0:0"
138
+
139
+ njspc-dash:
140
+ image: ghcr.io/sam2kb/njspc-dash
141
+ container_name: njspc-dash
142
+ restart: unless-stopped
143
+ depends_on:
144
+ - njspc
145
+ environment:
146
+ - TZ=${TZ:-UTC}
147
+ - NODE_ENV=production
148
+ - POOL_WEB_SERVICES_IP=njspc # Link to backend service name
149
+ ports:
150
+ - "5150:5150"
151
+ volumes:
152
+ - ./dash-config.json:/app/config.json
153
+ - njspc-dash-data:/app/data
154
+ - njspc-dash-logs:/app/logs
155
+ - njspc-dash-uploads:/app/uploads
156
+
157
+ volumes:
158
+ njspc-data:
159
+ njspc-backups:
160
+ njspc-logs:
161
+ njspc-bindings:
162
+ njspc-dash-data:
163
+ njspc-dash-logs:
164
+ njspc-dash-uploads:
165
+ ```
166
+
167
+ Quick start:
168
+ 1. Save compose file.
169
+ 2. (Optional) create an empty config file: `touch dash-config.json`.
170
+ 3. `docker compose up -d`
171
+ 4. Visit Dash UI at: `http://localhost:5150`.
172
+
173
+ Notes:
174
+ * Provide either RS-485 device OR enable network (ScreenLogic) connection.
175
+ * Coordinates env vars prevent heliotrope warnings before the panel reports location.
176
+ * Persistence (controller):
177
+ * `./server-config.json:/app/config.json` main runtime config. You can either:
178
+ * Seed it with a copy of `defaultConfig.json` (`cp defaultConfig.json server-config.json`), OR
179
+ * Start with an empty file and the app will auto-populate it from defaults on first launch. If the file exists but contains invalid JSON it will be backed up to `config.corrupt-<timestamp>.json` and regenerated.
180
+ * Remaining state (data, backups, logs, custom bindings) is typically stored in named volumes in the provided compose for cleaner host directories. If you prefer bind mounts instead, replace the named volumes with host paths similar to the example below.
181
+ * Data artifacts: `poolConfig.json`, `poolState.json` etc. live under `/app/data` (volume `njspc-data`).
182
+ * Backups: `/app/backups` (volume `njspc-backups`).
183
+ * Logs: `/app/logs` (volume `njspc-logs`).
184
+ * Custom bindings: `/app/web/bindings/custom` (volume `njspc-bindings`).
185
+ * To migrate from bind mounts to named volumes, stop the stack, `docker run --rm -v oldPath:/from -v newVolume:/to alpine sh -c 'cp -a /from/. /to/'` for each path, then update compose.
186
+
187
+ ### Automate startup of app
188
+ See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Automatically-start-at-boot---PM2-&-Systemd).
189
+
190
+ # Clients & Bindings
191
+ To do anything with this app, you need a client to connect to it. A client can be a web application or Home Automation system.
192
+
193
+ <a name="module_nodejs-poolController--clients"></a>
194
+
195
+ ## REM (Relay Equipment Manager)
196
+ [Relay Equipment Manager](https://github.com/rstrouse/relayEquipmentManager) is a companion app developed by @rstrouse that integrates standalone hardware control. Controls GPIO, i2c, and SPI devices including:
197
+ * Atlas Scientific pH, orp, ec, hum, prs, pmp, rtd
198
+ * ADS1x15 a/d converters
199
+ * Pressure Tranducers
200
+ * Flow sensors
201
+ * Temperature sensors (10k, NTC)
202
+
203
+ ## Web Clients
204
+ 1. [nodejs-poolController-dashPanel](https://github.com/rstrouse/nodejs-poolController-dashPanel). Full compatibility with IntelliCenter, *Touch, REM (RelayEquipmentManager).
205
+
206
+
207
+ <a name="module_nodejs-poolController--bindings"></a>
208
+
209
+ ## Home Automation Bindings (previously Integrations)
210
+
211
+ Available automations:
212
+ * [Vera Home Automation Hub](https://github.com/rstrouse/nodejs-poolController-veraPlugin) - A plugin that integrates with nodejs-poolController. [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#vera)
213
+ * [Hubitat](https://github.com/bsileo/hubitat_poolcontroller) by @bsileo (prev help from @johnny2678, @donkarnag, @arrmo). [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#smartthingshubitat)
214
+ * [Homebridge/Siri/EVE](https://github.com/gadget-monk/homebridge-poolcontroller) by @gadget-monk, adopted from @leftyflip
215
+ * InfluxDB - [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#influx)
216
+ * [MQTT](https://github.com/crsherman/nodejs-poolController-mqtt) original release by @crsherman, re-write by @kkzonie, testing by @baudfather and others. [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations#mqtt)
217
+ * [Homeseer](https://github.com/tagyoureit/nodejs-poolController/wiki/Homeseer-Setup-Instructions) - Integration directions by @miamijerry to integrate Homeseer through MQTT
218
+
219
+ Outdated:
220
+ * [Another SmartThings Controller](https://github.com/dhop90/pentair-pool-controller/blob/master/README.md) by @dhop90
221
+ * [ISY](src/integrations/socketISY.js). Original credit to @blueman2, enhancements by @mayermd
222
+ * [ISY Polyglot NodeServer](https://github.com/brianmtreese/nodejs-pool-controller-polyglotv2) created by @brianmtreese
223
+
224
+ # Support
225
+ 1. For discussions, recommendations, designs, and clarifications, we recommend you join the [Github discussions](https://github.com/tagyoureit/nodejs-poolController/discussions.
226
+ 1. Check the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki) for tips, tricks and additional documentation.
227
+ 1. For bug reports you can open a [github issue](https://github.com/tagyoureit/nodejs-poolController/issues/new),
228
+
229
+
230
+ # Changes
231
+ See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
232
+
233
+ <a name="module_nodejs-poolController--config.json"></a>
234
+ # Config.json changes
235
+
236
+ ## Controller section - changes to the communications for the app
237
+ Most of these can be configured directly from the UI in dashPanel.
238
+ * `rs485Port` - set to the name of you rs485 controller. See [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) for details and testing.
239
+ * `portSettings` - should not need to be changed for RS485
240
+ * `mockPort` - opens a "fake" port for this app to communicate on. Can be used with [packet captures/replays](https://github.com/tagyoureit/nodejs-poolController/wiki/How-to-capture-all-packets-for-issue-resolution).
241
+ * `netConnect` - used to connect via [Socat](https://github.com/tagyoureit/nodejs-poolController/wiki/Socat)
242
+ * `netHost` and `netPort` - host and port for Socat connection.
243
+ * `inactivityRetry` - # of seconds the app should wait before trying to reopen the port after no communications. If your equipment isn't on all the time or you are running a virtual controller you may want to dramatically increase the timeout so you don't get console warnings.
244
+ * `txDelays` - (optional) fine‑grained transmit pacing controls added in 8.1+ to better coexist with busy or bridged (socat / multiple panel / dual chlorinator) RS‑485 buses. These values are all in milliseconds. If the block is omitted, internal defaults are used (see `defaultConfig.json`). All values can be hot‑reloaded from config.
245
+ * `idleBeforeTxMs` – Minimum quiet time on the bus (no RX or TX seen) before a new outbound frame may start. Helps avoid collisions just after another device finishes talking. Typical: 40‑80. Set to 0 to disable.
246
+ * `interFrameDelayMs` – Delay inserted between completed outbound attempts (success, retry scheduling, or queue drain) and evaluation of the next outbound message. Replaces the previous fixed 100ms. Typical: 30‑75. Lower values increase throughput but may raise collision / rewind counts.
247
+ * `interByteDelayMs` – Optional per‑byte pacing inside a single frame. Normally 0 (disabled). Set to 1‑2ms only if you observe hardware or USB adapter overruns, or are experimenting with very marginal wiring / long cable runs.
248
+
249
+ Example tuning block - more conservative pacing for SunTouch that works way better than defaults:
250
+
251
+ ```json
252
+ "txDelays": {
253
+ "idleBeforeTxMs": 60,
254
+ "interFrameDelayMs": 50,
255
+ "interByteDelayMs": 1
256
+ }
257
+ ```
258
+
259
+ Tuning guidance:
260
+ - Start with the defaults. Only change one value at a time and observe stats (collisions, retries, rewinds) via rs485PortStats.
261
+ - If you see frequent outbound retries or receive rewinds, first raise `idleBeforeTxMs` in small steps (e.g. +10ms) before touching `interFrameDelayMs`.
262
+ - If overall throughput feels sluggish but collisions are low, you may lower `interFrameDelayMs` gradually.
263
+ - Use `interByteDelayMs` only as a last resort; it elongates every frame and reduces total bus capacity.
264
+ - Setting any value too high will simply slow configuration bursts (e.g. on startup); setting them too low can cause more retries and ultimately lower effective throughput.
265
+
266
+ All three parameters are safe to adjust without restarting; edits to `config.json` are picked up by the existing config watcher.
267
+
268
+ ## Web section - controls various aspects of external communications
269
+ * `servers` - setting for different servers/services
270
+ * `http2` - not used currently
271
+ * `http` - primary server used for api connections without secure communications
272
+ * `enabled` - self-explanatory
273
+ * `ip` - The ip of the network address to listen on. Default of `127.0.0.1` will only listen on the local loopback (localhost) adapter. `0.0.0.0` will listen on all network interfaces. Any other address will listen exclusively on that interface.
274
+ * `port` - Port to listen on. Default is `4200`.
275
+ * `httpsRedirect` - Redirect http traffic to https
276
+ * `authentication` - Enable basic username/password authentication. (Not implemented yet.)
277
+ * `authFile` - Location of the encrypted password file. By default, `/users.htpasswd`. If you have `authentication=1` then create the file users.htpasswd in the root of the application. Use a tool such as http://www.htaccesstools.com/htpasswd-generator/ and paste your user(s) into this file. You will now be prompted for authentication.
278
+ * `https` - See http options above.
279
+ * `sslKeyFile` - Location of key file
280
+ * `sslCertFile` - Location of certificate file
281
+ * `mdns` - Not currently used.
282
+ * `ssdp` - Enable for automatic configuration by the webClient and other platforms.
283
+
284
+
285
+ ## Log - Different aspects of logging to the application
286
+ * `app` - Application wide settings
287
+ * `enabled` - Enable/disable logging for the entire application
288
+ * `level` - Different levels of logging from least to most: 'error', 'warn', 'info', 'verbose', 'debug', 'silly'
289
+ * `packet` - Configuration for the
290
+
291
+
292
+ # Credit
293
+
294
+ 1. @Rstrouse for helping make the 6.0 rewrite and Intellicenter possible, continuing to make monumental changes, and driving this project forward in numerous ways. My knowledge of coding in general has benefitted greatly from working with him.
295
+ 1. @jwtaylor310 for providing a ton of IntelliCenter v3.004+ replay captures that helped track down and fix bugs.
296
+ 1. [Jason Young](http://www.sdyoung.com/home/decoding-the-pentair-easytouch-rs-485-protocol) (Read both posts, they are a great baseline for knowledge)
297
+ 1. Michael Russe [ceesco](https://github.com/ceesco53/pentair_examples) [CocoonTech](http://cocoontech.com/forums/topic/13548-intelliflow-pump-rs485-protocol/?p=159671) - Registration required for CocoonTech. Jason Young used this material for his understanding in the protocol as well. There is a very detailed .txt file with great information ~~that I won't post unless I get permission~~. Looks like it was publicly posted to [Pastebin](http://pastebin.com/uiAmvNjG).
298
+ 1. [Michael Usner](https://github.com/michaelusner/Home-Device-Controller) for taking the work of both of the above and turning it into Javascript code.
299
+ 1. [rflemming](https://github.com/rflemming) for being the first to contribute some changes to the code.
300
+ 1. Awesome help from @arrmo and @blueman2 on Gitter
301
+
302
+ # License
303
+
304
+ nodejs-poolController. An application to control pool equipment.
305
+ Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025. Russell Goldin, tagyoureit. russ.goldin@gmail.com
306
+
307
+ This program is free software: you can redistribute it and/or modify
308
+ it under the terms of the GNU Affero General Public License as
309
+ published by the Free Software Foundation, either version 3 of the
310
+ License, or (at your option) any later version.
311
+
312
+ This program is distributed in the hope that it will be useful,
313
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
314
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
315
+ GNU Affero General Public License for more details.
316
+
317
+ You should have received a copy of the GNU Affero General Public License
318
+ along with this program. If not, see <http://www.gnu.org/licenses/>