nodejs-poolcontroller 7.3.1 → 7.6.1

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 (85) hide show
  1. package/.eslintrc.json +44 -44
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +52 -52
  3. package/CONTRIBUTING.md +74 -74
  4. package/Changelog +215 -195
  5. package/Dockerfile +17 -17
  6. package/Gruntfile.js +40 -40
  7. package/LICENSE +661 -661
  8. package/README.md +191 -186
  9. package/app.ts +2 -0
  10. package/config/Config.ts +27 -2
  11. package/config/VersionCheck.ts +33 -14
  12. package/config copy.json +299 -299
  13. package/controller/Constants.ts +88 -0
  14. package/controller/Equipment.ts +2459 -2225
  15. package/controller/Errors.ts +180 -157
  16. package/controller/Lockouts.ts +437 -0
  17. package/controller/State.ts +364 -79
  18. package/controller/boards/BoardFactory.ts +45 -45
  19. package/controller/boards/EasyTouchBoard.ts +2653 -2489
  20. package/controller/boards/IntelliCenterBoard.ts +4230 -3973
  21. package/controller/boards/IntelliComBoard.ts +63 -63
  22. package/controller/boards/IntelliTouchBoard.ts +241 -167
  23. package/controller/boards/NixieBoard.ts +1675 -1105
  24. package/controller/boards/SystemBoard.ts +4697 -3201
  25. package/controller/comms/Comms.ts +222 -10
  26. package/controller/comms/messages/Messages.ts +13 -9
  27. package/controller/comms/messages/config/ChlorinatorMessage.ts +13 -4
  28. package/controller/comms/messages/config/CircuitGroupMessage.ts +6 -0
  29. package/controller/comms/messages/config/CircuitMessage.ts +0 -0
  30. package/controller/comms/messages/config/ConfigMessage.ts +0 -0
  31. package/controller/comms/messages/config/CoverMessage.ts +1 -0
  32. package/controller/comms/messages/config/CustomNameMessage.ts +30 -30
  33. package/controller/comms/messages/config/EquipmentMessage.ts +4 -0
  34. package/controller/comms/messages/config/ExternalMessage.ts +53 -33
  35. package/controller/comms/messages/config/FeatureMessage.ts +8 -1
  36. package/controller/comms/messages/config/GeneralMessage.ts +8 -0
  37. package/controller/comms/messages/config/HeaterMessage.ts +14 -28
  38. package/controller/comms/messages/config/IntellichemMessage.ts +4 -1
  39. package/controller/comms/messages/config/OptionsMessage.ts +38 -2
  40. package/controller/comms/messages/config/PumpMessage.ts +4 -20
  41. package/controller/comms/messages/config/RemoteMessage.ts +4 -0
  42. package/controller/comms/messages/config/ScheduleMessage.ts +347 -331
  43. package/controller/comms/messages/config/SecurityMessage.ts +1 -0
  44. package/controller/comms/messages/config/ValveMessage.ts +13 -3
  45. package/controller/comms/messages/status/ChlorinatorStateMessage.ts +2 -3
  46. package/controller/comms/messages/status/EquipmentStateMessage.ts +79 -25
  47. package/controller/comms/messages/status/HeaterStateMessage.ts +86 -53
  48. package/controller/comms/messages/status/IntelliChemStateMessage.ts +445 -386
  49. package/controller/comms/messages/status/IntelliValveStateMessage.ts +35 -35
  50. package/controller/comms/messages/status/PumpStateMessage.ts +0 -0
  51. package/controller/comms/messages/status/VersionMessage.ts +0 -0
  52. package/controller/nixie/Nixie.ts +162 -160
  53. package/controller/nixie/NixieEquipment.ts +103 -103
  54. package/controller/nixie/bodies/Body.ts +120 -117
  55. package/controller/nixie/bodies/Filter.ts +135 -135
  56. package/controller/nixie/chemistry/ChemController.ts +2498 -2395
  57. package/controller/nixie/chemistry/Chlorinator.ts +314 -313
  58. package/controller/nixie/circuits/Circuit.ts +248 -210
  59. package/controller/nixie/heaters/Heater.ts +649 -441
  60. package/controller/nixie/pumps/Pump.ts +661 -599
  61. package/controller/nixie/schedules/Schedule.ts +257 -256
  62. package/controller/nixie/valves/Valve.ts +170 -170
  63. package/defaultConfig.json +286 -271
  64. package/issue_template.md +51 -51
  65. package/logger/DataLogger.ts +448 -433
  66. package/logger/Logger.ts +0 -0
  67. package/package.json +56 -54
  68. package/tsconfig.json +25 -25
  69. package/web/Server.ts +522 -31
  70. package/web/bindings/influxDB.json +1022 -894
  71. package/web/bindings/mqtt.json +654 -543
  72. package/web/bindings/mqttAlt.json +684 -574
  73. package/web/bindings/rulesManager.json +54 -54
  74. package/web/bindings/smartThings-Hubitat.json +31 -31
  75. package/web/bindings/valveRelays.json +20 -20
  76. package/web/bindings/vera.json +25 -25
  77. package/web/interfaces/baseInterface.ts +136 -136
  78. package/web/interfaces/httpInterface.ts +124 -122
  79. package/web/interfaces/influxInterface.ts +245 -240
  80. package/web/interfaces/mqttInterface.ts +475 -464
  81. package/web/services/config/Config.ts +181 -152
  82. package/web/services/config/ConfigSocket.ts +0 -0
  83. package/web/services/state/State.ts +118 -7
  84. package/web/services/state/StateSocket.ts +18 -1
  85. package/web/services/utilities/Utilities.ts +42 -42
package/README.md CHANGED
@@ -1,186 +1,191 @@
1
- # nodejs-poolController - Version 7.3.0
2
-
3
- ## What is nodejs-poolController
4
-
5
- nodejs-poolController is an application to communicate and control your Pentair compatible pool equipment.
6
-
7
- * Want to include a low cost controller for your pool?
8
- * Want a web interface for your system?
9
- * Want to turn your pumps on remotely?
10
- * Want to have your home automation system talk to your pool?
11
- * Want to control your pumps or chlorinator without a pool controller?
12
-
13
- Equipment supported
14
- 1. Controllers: IntelliCenter, Intellitouch, EasyTouch, No controller (standalone equimpent)
15
- 1. Pumps: Intelliflow VS/VSF/VF, older models
16
- 1. Chlorinators: Intellichlor, Aqua-Rite and OEM brands
17
- 1. Heaters: Gas, solar, heatpump
18
- 1. Intellichem and homegrown chemical controllers
19
- 1. Intellivalve (coming soon)
20
- 1. Home Automation: SmartThings, Hubitat, ISY, Vera, Siri, Echo
21
- 1. Chemical probes (pH, ORP, flow sensors, EC, etc.)
22
-
23
- ## Latest Changes
24
- See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
25
-
26
- ## What's new in 7.0?
27
-
28
- 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).
29
-
30
- Starting with this version, all code will immediately be pushed to `master` branch. The version of a `next` branch for feature development will disappear.
31
-
32
-
33
- <a name="module_nodejs-poolController--install"></a>
34
-
35
- Dashpanel Client Screenshot
36
-
37
- <img src="https://tagyoureit.github.io/nodejs-poolController/images/v6/clients/dashPanel.png?raw=true" height="300">
38
-
39
- ## Installation Instructions
40
-
41
- This code requires a physical [RS485](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) adapter to work.
42
-
43
- This is only the server code. See [clients](#module_nodejs-poolController--clients) below for web or other ways to read/control the pool equipment.
44
-
45
- ### Prerequisites
46
- If you don't know anything about NodeJS, these directions might be helpful.
47
-
48
- 1. Install Nodejs (v12 recommended). (https://nodejs.org/en/download/)
49
- 1. Update NPM (https://docs.npmjs.com/getting-started/installing-node).
50
- 1. It is recommended to clone the source code as updates are frequently pushed while releases are infrequent
51
-
52
- Download the latest [code release](https://github.com/tagyoureit/nodejs-poolController/releases)
53
- OR
54
- clone with `git clone git@github.com:tagyoureit/nodejs-poolController.git`
55
- 1. Unzip into nodejs-poolController.
56
- 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).
57
- 1. Run the app with `npm start`.
58
- * `npm start` will compile the Typescript code. You should use this every time you download/clone/pull the latest code.
59
- * `npm run start:cached` will run the app without compiling the code which can be much faster.
60
- 1. Running `npm start` will also create a `config.json` file for your installation. If you need to modify any properties (e.g. the path to your serialport adapter, enabling socat, etc) then stop the app, edit the `config.json` per the [instructions](module_nodejs-poolController--config.json) below, and start the app again.
61
- 1. Verify your pool equipment is correctly identified by inspecting the `/data/*.json` files.
62
- 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.
63
-
64
- 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.
65
-
66
- ### Docker instructions
67
-
68
- See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Docker). Thanks @wurmr @andylippitt @emes.
69
-
70
- ### Automate startup of app
71
- See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Automatically-start-at-boot---PM2-&-Systemd).
72
-
73
- # Clients & Bindings
74
- 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.
75
-
76
- <a name="module_nodejs-poolController--clients"></a>
77
-
78
- ## REM (Relay Equipment Manager)
79
- [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:
80
- * Atlas Scientific pH, orp, ec, hum, prs, pmp, rtd
81
- * ADS1x15 a/d converters
82
- * Pressure Tranducers
83
- * Flow sensors
84
- * Temperature sensors (10k, NTC)
85
-
86
- ## Web Clients
87
- 1. [nodejs-poolController-dashPanel](https://github.com/rstrouse/nodejs-poolController-dashPanel). Full compatibility with IntelliCenter, *Touch, REM (RelayEquipmentManager).
88
- 1. Deprecated - ~~[nodejs-poolController-webClient](http://github.com/tagyoureit/nodejs-poolController-webClient). Built primarily around EasyTouch/IntelliTouch but will work with other systems.~~
89
-
90
- * This app has the default to only listen to clients from localhost (127.0.0.1). If you need to have clients connect from other machines you will need to change the [ip](#module_nodejs-poolController--config.json) in `config.json`.
91
-
92
- <a name="module_nodejs-poolController--bindings"></a>
93
-
94
- ## Home Automation Bindings (previously Integrations)
95
- **NOTE: Existing integrations built of 5.3 or earlier WILL NOT WORK. They need to be upgraded to leverage 6.0. **
96
-
97
- Available for 6.x:
98
- * [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-in-2.0#vera)
99
- * [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-in-2.0#smartthingshubitat)
100
- * [Homebridge/Siri/EVE](https://github.com/gadget-monk/homebridge-poolcontroller) by @gadget-monk, adopted from @leftyflip
101
- * InfluxDB - [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations-in-2.0#influx)
102
- * [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-in-2.0#mqtt)
103
- * [Homeseer](https://github.com/tagyoureit/nodejs-poolController/wiki/Homeseer-Setup-Instructions) - Integration directions by @miamijerry to integrate Homeseer through MQTT
104
-
105
- Need to be updated:
106
- * [Another SmartThings Controller](https://github.com/dhop90/pentair-pool-controller/blob/master/README.md) by @dhop90
107
- * [ISY](src/integrations/socketISY.js). Original credit to @blueman2, enhancements by @mayermd
108
- * [ISY Polyglot NodeServer](https://github.com/brianmtreese/nodejs-pool-controller-polyglotv2) created by @brianmtreese
109
-
110
- # Support
111
- 1. For discussions, recommendations, designs, and clarifications, we recommend you join our [Gitter Chat room](https://gitter.im/pentair_pool/Lobby).
112
- 1. Check the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki) for tips, tricks and additional documentation.
113
- 1. For bug reports you can open a [github issue](https://github.com/tagyoureit/nodejs-poolController/issues/new),
114
-
115
- ### Virtual Controller
116
- v6 adds all new configuration and support for virtual pumps, chlorinators (and soon, Intellichem)
117
-
118
- * [Virtual Pump Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Virtual-Pump-Controller---v6)
119
- * [Virtual Chlorinator Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Virtual-Chlorinator-Controller-v6)
120
- * Virtual Chem Controller
121
-
122
- # Changes
123
- See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
124
-
125
-
126
- <a name="module_nodejs-poolController--config.json"></a>
127
- # Config.json changes
128
-
129
- ## Controller section - changes to the communications for the app
130
- * `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.
131
- * `portSettings` - should not need to be changed for RS485
132
- * `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).
133
- * `netConnect` - used to connect via [Socat](https://github.com/tagyoureit/nodejs-poolController/wiki/Socat)
134
- * `netHost` and `netPort` - host and port for Socat connection.
135
- * `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.
136
-
137
- ## Web section - controls various aspects of external communications
138
- * `servers` - setting for different servers/services
139
- * `http2` - not used currently
140
- * `http` - primary server used for api connections without secure communications
141
- * `enabled` - self-explanatory
142
- * `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.
143
- * `port` - Port to listen on. Default is `4200`.
144
- * `httpsRedirect` - Redirect http traffic to https
145
- * `authentication` - Enable basic username/password authentication. (Not implemented yet.)
146
- * `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.
147
- * `https` - See http options above.
148
- * `sslKeyFile` - Location of key file
149
- * `sslCertFile` - Location of certificate file
150
- * `mdns` - Not currently used.
151
- * `ssdp` - Enable for automatic configuration by the webClient and other platforms.
152
-
153
-
154
- ## Log - Different aspects of logging to the application
155
- * `app` - Application wide settings
156
- * `enabled` - Enable/disable logging for the entire application
157
- * `level` - Different levels of logging from least to most: 'error', 'warn', 'info', 'verbose', 'debug', 'silly'
158
- * `packet` - Configuration for the
159
-
160
-
161
- # Credit
162
-
163
- 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.
164
- 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)
165
- 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).
166
- 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.
167
- 1. [rflemming](https://github.com/rflemming) for being the first to contribute some changes to the code.
168
- 1. Awesome help from @arrmo and @blueman2 on Gitter
169
-
170
- # License
171
-
172
- nodejs-poolController. An application to control pool equipment.
173
- Copyright (C) 2016, 2017. Russell Goldin, tagyoureit. russ.goldin@gmail.com
174
-
175
- This program is free software: you can redistribute it and/or modify
176
- it under the terms of the GNU Affero General Public License as
177
- published by the Free Software Foundation, either version 3 of the
178
- License, or (at your option) any later version.
179
-
180
- This program is distributed in the hope that it will be useful,
181
- but WITHOUT ANY WARRANTY; without even the implied warranty of
182
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183
- GNU Affero General Public License for more details.
184
-
185
- You should have received a copy of the GNU Affero General Public License
186
- along with this program. If not, see <http://www.gnu.org/licenses/>
1
+ # nodejs-poolController - Version 7.6
2
+
3
+ ## What is nodejs-poolController
4
+
5
+ nodejs-poolController is an application to communicate and control your Pentair compatible pool equipment.
6
+
7
+ * Want to include a low cost controller for your pool?
8
+ * Want a web interface for your system?
9
+ * Want to turn your pumps on remotely?
10
+ * Want to have your home automation system talk to your pool?
11
+ * Want to control your pumps or chlorinator without a pool controller?
12
+
13
+ Equipment supported
14
+ 1. Controllers: IntelliCenter, Intellitouch, EasyTouch, No controller (standalone equimpent)
15
+ 1. Pumps: Intelliflow VS/VSF/VF, older models
16
+ 1. Chlorinators: Intellichlor, Aqua-Rite and OEM brands
17
+ 1. Heaters: Gas, solar, heatpump
18
+ 1. Intellichem and Relay Equipment Manager (REM) chemical controllers
19
+ 1. Intellivalve (coming soon)
20
+ 1. Home Automation: SmartThings, Hubitat, ISY, Vera, Siri, Echo
21
+ 1. Chemical probes (pH, ORP, flow sensors, EC, etc.)
22
+
23
+ ## Latest Changes
24
+ See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
25
+
26
+ ## What's new in 7.0?
27
+
28
+ 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).
29
+
30
+ Starting with this version, all code will immediately be pushed to `master` branch. The version of a `next` branch for feature development will disappear.
31
+
32
+
33
+ <a name="module_nodejs-poolController--install"></a>
34
+
35
+ Dashpanel Client Screenshot
36
+
37
+ <img src="https://tagyoureit.github.io/nodejs-poolController/images/v6/clients/dashPanel.png?raw=true" height="300">
38
+
39
+ ## Installation Instructions
40
+
41
+ This code requires a physical [RS485](https://github.com/tagyoureit/nodejs-poolController/wiki/RS-485-Adapter-Details) adapter to work.
42
+
43
+ This is only the server code. See [clients](#module_nodejs-poolController--clients) below for web or other ways to read/control the pool equipment.
44
+
45
+ ### Prerequisites
46
+ If you don't know anything about NodeJS, these directions might be helpful.
47
+
48
+ 1. Install Nodejs (v12 recommended). (https://nodejs.org/en/download/)
49
+ 1. Update NPM (https://docs.npmjs.com/getting-started/installing-node).
50
+ 1. It is recommended to clone the source code as updates are frequently pushed while releases are infrequent
51
+ clone with `git clone https://github.com/tagyoureit/nodejs-poolController.git`
52
+ (Alternate - not recommended - Download the latest [code release](https://github.com/tagyoureit/nodejs-poolController/releases)
53
+ 1. Change directory into nodejs-poolController.
54
+ 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).
55
+ 1. Run the app with `npm start`.
56
+ * `npm start` will compile the Typescript code. You should use this every time you download/clone/pull the latest code.
57
+ * `npm run start:cached` will run the app without compiling the code which can be much faster.
58
+ 1. Running `npm start` will also create a `config.json` file for your installation. If you need to modify any properties (e.g. the path to your serialport adapter, enabling socat, etc) then stop the app, edit the `config.json` per the [instructions](module_nodejs-poolController--config.json) below, and start the app again.
59
+ 1. Verify your pool equipment is correctly identified by inspecting the `/data/*.json` files.
60
+ 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.
61
+
62
+ 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.
63
+
64
+ #### Upgrade Instructions
65
+ Assuming you cloned the repo, the following are easy steps to get the latest version:
66
+ 1. Change directory to the njsPC app
67
+ 2. `git pull`
68
+ 3. `npm i` (not always necessary, but if dependencies are upgraded this will bring them up to date)
69
+ 4. Start application as normal, or if using `npm run start:cached` then run `npm run build` to compile the code.
70
+
71
+ ### Docker instructions
72
+
73
+ See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Docker). Thanks @wurmr @andylippitt @emes.
74
+
75
+ ### Automate startup of app
76
+ See the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki/Automatically-start-at-boot---PM2-&-Systemd).
77
+
78
+ # Clients & Bindings
79
+ 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.
80
+
81
+ <a name="module_nodejs-poolController--clients"></a>
82
+
83
+ ## REM (Relay Equipment Manager)
84
+ [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:
85
+ * Atlas Scientific pH, orp, ec, hum, prs, pmp, rtd
86
+ * ADS1x15 a/d converters
87
+ * Pressure Tranducers
88
+ * Flow sensors
89
+ * Temperature sensors (10k, NTC)
90
+
91
+ ## Web Clients
92
+ 1. [nodejs-poolController-dashPanel](https://github.com/rstrouse/nodejs-poolController-dashPanel). Full compatibility with IntelliCenter, *Touch, REM (RelayEquipmentManager).
93
+ 1. Deprecated - ~~[nodejs-poolController-webClient](http://github.com/tagyoureit/nodejs-poolController-webClient). Built primarily around EasyTouch/IntelliTouch but will work with other systems.~~
94
+
95
+ * This app has the default to only listen to clients from localhost (127.0.0.1). If you need to have clients connect from other machines you will need to change the [ip](#module_nodejs-poolController--config.json) in `config.json`.
96
+
97
+ <a name="module_nodejs-poolController--bindings"></a>
98
+
99
+ ## Home Automation Bindings (previously Integrations)
100
+ **NOTE: Existing integrations built of 5.3 or earlier WILL NOT WORK. They need to be upgraded to leverage 6.0. **
101
+
102
+ Available for 6.x:
103
+ * [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-in-2.0#vera)
104
+ * [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-in-2.0#smartthingshubitat)
105
+ * [Homebridge/Siri/EVE](https://github.com/gadget-monk/homebridge-poolcontroller) by @gadget-monk, adopted from @leftyflip
106
+ * InfluxDB - [Bindings Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Bindings-Integrations-in-2.0#influx)
107
+ * [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-in-2.0#mqtt)
108
+ * [Homeseer](https://github.com/tagyoureit/nodejs-poolController/wiki/Homeseer-Setup-Instructions) - Integration directions by @miamijerry to integrate Homeseer through MQTT
109
+
110
+ Need to be updated:
111
+ * [Another SmartThings Controller](https://github.com/dhop90/pentair-pool-controller/blob/master/README.md) by @dhop90
112
+ * [ISY](src/integrations/socketISY.js). Original credit to @blueman2, enhancements by @mayermd
113
+ * [ISY Polyglot NodeServer](https://github.com/brianmtreese/nodejs-pool-controller-polyglotv2) created by @brianmtreese
114
+
115
+ # Support
116
+ 1. For discussions, recommendations, designs, and clarifications, we recommend you join our [Gitter Chat room](https://gitter.im/pentair_pool/Lobby).
117
+ 1. Check the [wiki](https://github.com/tagyoureit/nodejs-poolController/wiki) for tips, tricks and additional documentation.
118
+ 1. For bug reports you can open a [github issue](https://github.com/tagyoureit/nodejs-poolController/issues/new),
119
+
120
+ ### Virtual Controller
121
+ v6 adds all new configuration and support for virtual pumps, chlorinators (and soon, Intellichem)
122
+
123
+ * [Virtual Pump Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Virtual-Pump-Controller---v6)
124
+ * [Virtual Chlorinator Directions](https://github.com/tagyoureit/nodejs-poolController/wiki/Virtual-Chlorinator-Controller-v6)
125
+ * Virtual Chem Controller
126
+
127
+ # Changes
128
+ See [Changelog](https://github.com/tagyoureit/nodejs-poolController/blob/master/Changelog)
129
+
130
+
131
+ <a name="module_nodejs-poolController--config.json"></a>
132
+ # Config.json changes
133
+
134
+ ## Controller section - changes to the communications for the app
135
+ * `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.
136
+ * `portSettings` - should not need to be changed for RS485
137
+ * `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).
138
+ * `netConnect` - used to connect via [Socat](https://github.com/tagyoureit/nodejs-poolController/wiki/Socat)
139
+ * `netHost` and `netPort` - host and port for Socat connection.
140
+ * `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.
141
+
142
+ ## Web section - controls various aspects of external communications
143
+ * `servers` - setting for different servers/services
144
+ * `http2` - not used currently
145
+ * `http` - primary server used for api connections without secure communications
146
+ * `enabled` - self-explanatory
147
+ * `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.
148
+ * `port` - Port to listen on. Default is `4200`.
149
+ * `httpsRedirect` - Redirect http traffic to https
150
+ * `authentication` - Enable basic username/password authentication. (Not implemented yet.)
151
+ * `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.
152
+ * `https` - See http options above.
153
+ * `sslKeyFile` - Location of key file
154
+ * `sslCertFile` - Location of certificate file
155
+ * `mdns` - Not currently used.
156
+ * `ssdp` - Enable for automatic configuration by the webClient and other platforms.
157
+
158
+
159
+ ## Log - Different aspects of logging to the application
160
+ * `app` - Application wide settings
161
+ * `enabled` - Enable/disable logging for the entire application
162
+ * `level` - Different levels of logging from least to most: 'error', 'warn', 'info', 'verbose', 'debug', 'silly'
163
+ * `packet` - Configuration for the
164
+
165
+
166
+ # Credit
167
+
168
+ 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.
169
+ 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)
170
+ 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).
171
+ 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.
172
+ 1. [rflemming](https://github.com/rflemming) for being the first to contribute some changes to the code.
173
+ 1. Awesome help from @arrmo and @blueman2 on Gitter
174
+
175
+ # License
176
+
177
+ nodejs-poolController. An application to control pool equipment.
178
+ Copyright (C) 2016, 2017. Russell Goldin, tagyoureit. russ.goldin@gmail.com
179
+
180
+ This program is free software: you can redistribute it and/or modify
181
+ it under the terms of the GNU Affero General Public License as
182
+ published by the Free Software Foundation, either version 3 of the
183
+ License, or (at your option) any later version.
184
+
185
+ This program is distributed in the hope that it will be useful,
186
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
187
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
188
+ GNU Affero General Public License for more details.
189
+
190
+ You should have received a copy of the GNU Affero General Public License
191
+ along with this program. If not, see <http://www.gnu.org/licenses/>
package/app.ts CHANGED
@@ -35,6 +35,7 @@ export async function initAsync() {
35
35
  await state.init();
36
36
  await webApp.init();
37
37
  await sys.start();
38
+ await webApp.initAutoBackup();
38
39
  } catch (err) { console.log(`Error Initializing nodejs-PoolController ${err.message}`); }
39
40
  //return Promise.resolve()
40
41
  // .then(function () { config.init(); })
@@ -70,6 +71,7 @@ export async function stopAsync(): Promise<void> {
70
71
  try {
71
72
  console.log('Shutting down open processes');
72
73
  // await sys.board.virtualPumpControllers.stopAsync();
74
+ await webApp.stopAutoBackup();
73
75
  await sys.stopAsync();
74
76
  await state.stopAsync();
75
77
  await conn.stopAsync();
package/config/Config.ts CHANGED
@@ -17,10 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  import * as path from "path";
18
18
  import * as fs from "fs";
19
19
  import { EventEmitter } from 'events';
20
-
21
- //import { conn } from "../controller/comms/Comms";
22
20
  const extend = require("extend");
23
21
  import { logger } from "../logger/Logger";
22
+ import { utils } from "../controller/Constants";
24
23
  class Config {
25
24
  private cfgPath: string;
26
25
  private _cfg: any;
@@ -59,6 +58,7 @@ class Config {
59
58
  else throw err;
60
59
  });
61
60
  this._isLoading = false;
61
+ this.getEnvVariables();
62
62
  } catch (err) {
63
63
  console.log(`Error reading configuration information. Aborting startup: ${ err }`);
64
64
  // Rethrow this error so we exit the app with the appropriate pause in the console.
@@ -100,6 +100,8 @@ class Config {
100
100
  c[section] = val;
101
101
  this.update();
102
102
  }
103
+ // RKS: 09-21-21 - We are counting on the return from this being immutable. A copy of the data
104
+ // should always be returned here.
103
105
  public getSection(section?: string, opts?: any): any {
104
106
  if (typeof section === 'undefined') return this._cfg;
105
107
  let c: any = this._cfg;
@@ -118,6 +120,7 @@ class Config {
118
120
  let baseDir = process.cwd();
119
121
  this.ensurePath(baseDir + '/logs/');
120
122
  this.ensurePath(baseDir + '/data/');
123
+ this.ensurePath(baseDir + '/backups/');
121
124
  // this.ensurePath(baseDir + '/replay/');
122
125
  //setTimeout(() => { config.update(); }, 100);
123
126
  }
@@ -148,5 +151,27 @@ class Config {
148
151
  }
149
152
  }
150
153
  }
154
+ private getEnvVariables(){
155
+ // set docker env variables to config.json, if they are set
156
+ let env = process.env;
157
+ let bUpdate = false;
158
+ if (typeof env.POOL_RS485_PORT !== 'undefined' && env.POOL_RS485_PORT !== this._cfg.controller.comms.rs485Port) {
159
+ this._cfg.controller.comms.rs485Port = env.POOL_RS485_PORT;
160
+ bUpdate = true;
161
+ }
162
+ if (typeof env.POOL_NET_CONNECT !== 'undefined' && env.POOL_NET_CONNECT !== this._cfg.controller.comms.netConnect) {
163
+ this._cfg.controller.comms.netConnect = utils.makeBool(env.POOL_NET_CONNECT);
164
+ bUpdate = true;
165
+ }
166
+ if (typeof env.POOL_NET_HOST !== 'undefined' && env.POOL_NET_HOST !== this._cfg.controller.comms.netHost) {
167
+ this._cfg.controller.comms.netHost = env.POOL_NET_HOST;
168
+ bUpdate = true;
169
+ }
170
+ if (typeof env.POOL_NET_PORT !== 'undefined' && env.POOL_NET_PORT !== this._cfg.controller.comms.netPort) {
171
+ this._cfg.controller.comms.netPort = env.POOL_NET_PORT;
172
+ bUpdate = true;
173
+ }
174
+ if (bUpdate) this.update();
175
+ }
151
176
  }
152
177
  export const config: Config = new Config();
@@ -39,26 +39,42 @@ class VersionCheck {
39
39
  if (typeof state.appVersion.nextCheckTime === 'undefined' || new Date() > new Date(state.appVersion.nextCheckTime)) setTimeout(() => { this.checkAll(); }, 100);
40
40
  }
41
41
  public checkGitLocal() {
42
+ let env = process.env;
42
43
  // check local git version
43
44
  try {
44
- let res = execSync('git rev-parse --abbrev-ref HEAD');
45
- let out = res.toString().trim();
45
+ let out: string;
46
+ if (typeof env.SOURCE_BRANCH !== 'undefined')
47
+ {
48
+ out = `${env.SOURCE_BRANCH} - From environment variable`; // check for docker variable
49
+ }
50
+ else {
51
+ let res = execSync('git rev-parse --abbrev-ref HEAD', { stdio: 'pipe' });
52
+ out = res.toString().trim();
53
+ }
46
54
  logger.info(`The current git branch output is ${out}`);
47
55
  switch (out) {
48
- case 'fatal':
49
- case 'command':
50
- state.appVersion.gitLocalBranch = '--';
51
- break;
52
- default:
53
- state.appVersion.gitLocalBranch = out;
54
- }
56
+ case 'fatal':
57
+ case 'command':
58
+ state.appVersion.gitLocalBranch = '--';
59
+ break;
60
+ default:
61
+ state.appVersion.gitLocalBranch = out;
62
+ }
55
63
  }
56
64
  catch (err) {
57
- logger.error(`Unable to retrieve local git branch. ${err}`);
65
+ state.appVersion.gitLocalBranch = '--';
66
+ logger.warn(`Unable to retrieve local git branch. ${err}`);
58
67
  }
59
68
  try {
60
- let res = execSync('git rev-parse HEAD');
61
- let out = res.toString().trim();
69
+ let out: string;
70
+ if (typeof env.SOURCE_COMMIT !== 'undefined')
71
+ {
72
+ out = `${env.SOURCE_COMMIT} - From environment variable`; // check for docker variable
73
+ }
74
+ else {
75
+ let res = execSync('git rev-parse HEAD', { stdio: 'pipe' });
76
+ out = res.toString().trim();
77
+ }
62
78
  logger.info(`The current git commit output is ${out}`);
63
79
  switch (out) {
64
80
  case 'fatal':
@@ -69,7 +85,10 @@ class VersionCheck {
69
85
  state.appVersion.gitLocalCommit = out;
70
86
  }
71
87
  }
72
- catch (err) { logger.error(`Unable to retrieve local git commit. ${err}`); }
88
+ catch (err) {
89
+ state.appVersion.gitLocalCommit = '--';
90
+ logger.warn(`Unable to retrieve local git commit. ${err}`);
91
+ }
73
92
  }
74
93
  private checkAll() {
75
94
  try {
@@ -83,7 +102,7 @@ class VersionCheck {
83
102
  });
84
103
  }
85
104
  catch (err) {
86
- logger.error(err);
105
+ logger.error(`Error checking latest release: ${err.message}`);
87
106
  }
88
107
  }
89
108