nodejs-poolcontroller 7.6.1 → 7.7.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 (91) hide show
  1. package/.eslintrc.json +44 -44
  2. package/.github/ISSUE_TEMPLATE/1-bug-report.yml +84 -0
  3. package/.github/ISSUE_TEMPLATE/2-docs.md +12 -0
  4. package/.github/ISSUE_TEMPLATE/3-proposal.md +28 -0
  5. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  6. package/CONTRIBUTING.md +74 -74
  7. package/Changelog +220 -215
  8. package/Dockerfile +17 -17
  9. package/Gruntfile.js +40 -40
  10. package/LICENSE +661 -661
  11. package/README.md +191 -191
  12. package/app.ts +1 -1
  13. package/config/Config.ts +14 -0
  14. package/config/VersionCheck.ts +2 -2
  15. package/controller/Constants.ts +2 -1
  16. package/controller/Equipment.ts +2484 -2459
  17. package/controller/Errors.ts +180 -180
  18. package/controller/Lockouts.ts +502 -436
  19. package/controller/State.ts +106 -30
  20. package/controller/boards/AquaLinkBoard.ts +1000 -0
  21. package/controller/boards/BoardFactory.ts +49 -45
  22. package/controller/boards/EasyTouchBoard.ts +2859 -2653
  23. package/controller/boards/IntelliCenterBoard.ts +4198 -4230
  24. package/controller/boards/IntelliComBoard.ts +63 -63
  25. package/controller/boards/IntelliTouchBoard.ts +273 -241
  26. package/controller/boards/NixieBoard.ts +1728 -1675
  27. package/controller/boards/SystemBoard.ts +4925 -4697
  28. package/controller/comms/Comms.ts +442 -479
  29. package/controller/comms/messages/Messages.ts +171 -25
  30. package/controller/comms/messages/config/ChlorinatorMessage.ts +5 -2
  31. package/controller/comms/messages/config/CircuitGroupMessage.ts +0 -0
  32. package/controller/comms/messages/config/CircuitMessage.ts +1 -0
  33. package/controller/comms/messages/config/ConfigMessage.ts +0 -0
  34. package/controller/comms/messages/config/CoverMessage.ts +0 -0
  35. package/controller/comms/messages/config/CustomNameMessage.ts +30 -30
  36. package/controller/comms/messages/config/EquipmentMessage.ts +0 -0
  37. package/controller/comms/messages/config/ExternalMessage.ts +0 -0
  38. package/controller/comms/messages/config/FeatureMessage.ts +0 -0
  39. package/controller/comms/messages/config/GeneralMessage.ts +0 -0
  40. package/controller/comms/messages/config/HeaterMessage.ts +142 -10
  41. package/controller/comms/messages/config/IntellichemMessage.ts +0 -0
  42. package/controller/comms/messages/config/OptionsMessage.ts +4 -21
  43. package/controller/comms/messages/config/PumpMessage.ts +53 -35
  44. package/controller/comms/messages/config/RemoteMessage.ts +0 -0
  45. package/controller/comms/messages/config/ScheduleMessage.ts +350 -347
  46. package/controller/comms/messages/config/SecurityMessage.ts +0 -0
  47. package/controller/comms/messages/config/ValveMessage.ts +1 -1
  48. package/controller/comms/messages/status/ChlorinatorStateMessage.ts +38 -86
  49. package/controller/comms/messages/status/EquipmentStateMessage.ts +58 -22
  50. package/controller/comms/messages/status/HeaterStateMessage.ts +116 -86
  51. package/controller/comms/messages/status/IntelliChemStateMessage.ts +445 -445
  52. package/controller/comms/messages/status/IntelliValveStateMessage.ts +35 -35
  53. package/controller/comms/messages/status/PumpStateMessage.ts +23 -1
  54. package/controller/comms/messages/status/VersionMessage.ts +0 -0
  55. package/controller/nixie/Nixie.ts +162 -162
  56. package/controller/nixie/NixieEquipment.ts +103 -103
  57. package/controller/nixie/bodies/Body.ts +120 -120
  58. package/controller/nixie/bodies/Filter.ts +135 -135
  59. package/controller/nixie/chemistry/ChemController.ts +2511 -2498
  60. package/controller/nixie/chemistry/Chlorinator.ts +363 -314
  61. package/controller/nixie/circuits/Circuit.ts +261 -248
  62. package/controller/nixie/heaters/Heater.ts +650 -648
  63. package/controller/nixie/pumps/Pump.ts +906 -661
  64. package/controller/nixie/schedules/Schedule.ts +313 -257
  65. package/controller/nixie/valves/Valve.ts +170 -170
  66. package/defaultConfig.json +306 -286
  67. package/logger/DataLogger.ts +448 -448
  68. package/logger/Logger.ts +0 -0
  69. package/package.json +56 -56
  70. package/tsconfig.json +25 -25
  71. package/web/Server.ts +92 -47
  72. package/web/bindings/aqualinkD.json +505 -0
  73. package/web/bindings/influxDB.json +1051 -1021
  74. package/web/bindings/mqtt.json +702 -654
  75. package/web/bindings/mqttAlt.json +731 -684
  76. package/web/bindings/rulesManager.json +54 -54
  77. package/web/bindings/smartThings-Hubitat.json +31 -31
  78. package/web/bindings/valveRelays.json +20 -20
  79. package/web/bindings/vera.json +25 -25
  80. package/web/interfaces/baseInterface.ts +137 -136
  81. package/web/interfaces/httpInterface.ts +145 -124
  82. package/web/interfaces/influxInterface.ts +276 -245
  83. package/web/interfaces/mqttInterface.ts +535 -475
  84. package/web/services/config/Config.ts +39 -18
  85. package/web/services/config/ConfigSocket.ts +0 -0
  86. package/web/services/state/State.ts +10 -0
  87. package/web/services/state/StateSocket.ts +4 -4
  88. package/web/services/utilities/Utilities.ts +44 -42
  89. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -52
  90. package/config copy.json +0 -300
  91. package/issue_template.md +0 -52
@@ -1,180 +1,180 @@
1
- /* nodejs-poolController. An application to control pool equipment.
2
- Copyright (C) 2016, 2017, 2018, 2019, 2020. Russell Goldin, tagyoureit. russ.goldin@gmail.com
3
-
4
- This program is free software: you can redistribute it and/or modify
5
- it under the terms of the GNU Affero General Public License as
6
- published by the Free Software Foundation, either version 3 of the
7
- License, or (at your option) any later version.
8
-
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU Affero General Public License for more details.
13
-
14
- You should have received a copy of the GNU Affero General Public License
15
- along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import extend = require("extend");
18
- import { Message, Outbound, Inbound } from "./comms/messages/Messages";
19
- import * as path from "path";
20
-
21
- // Internal abstract class for all errors.
22
- class ApiError extends Error {
23
- constructor(message: string, code?: number, httpCode?: number) {
24
- super(message);
25
- this.name = 'ApiError';
26
- this.code = code || 0;
27
- this.httpCode = httpCode || 400;
28
- let pos: any = {};
29
- if (typeof this.stack !== 'undefined') {
30
- try {
31
- // Another weirdo decision by NodeJS to not include the line numbers and source. Only a text based stack trace.
32
- let lines = this.stack.split('\n');
33
- for (let i = 0; i < lines.length; i++) {
34
- let line = lines[i];
35
- if (line.trimLeft().startsWith('at ')) {
36
- let lastParen = line.lastIndexOf(')');
37
- let firstParen = line.indexOf('(');
38
- if (lastParen >= 0 && firstParen >= 0) {
39
- let p = line.substring(firstParen + 1, lastParen);
40
- let m = /(\:\d+\:\d+)(?!.*\1)/g;
41
- let matches = p.match(m);
42
- let linecol = '';
43
- let lastIndex = -1;
44
- if (matches.length > 0) {
45
- linecol = matches[matches.length - 1];
46
- lastIndex = p.lastIndexOf(linecol);
47
- p = p.substring(0, lastIndex);
48
- if (linecol.startsWith(':')) linecol = linecol.substring(1);
49
- let lastcolon = linecol.lastIndexOf(':');
50
- if (lastcolon !== -1) {
51
- pos.column = parseInt(linecol.substring(lastcolon + 1), 10);
52
- pos.line = parseInt(linecol.substring(0, lastcolon), 10);
53
- }
54
- }
55
- let po = path.parse(p);
56
- pos.dir = po.dir;
57
- pos.file = po.base;
58
- }
59
- break;
60
- }
61
- }
62
- } catch (e) { }
63
- }
64
- this.position = pos;
65
- }
66
- public code: number = 0;
67
- public httpCode: number = 500;
68
- public position: any = {}
69
- }
70
- class EquipmentError extends ApiError {
71
- constructor(message: string, code: number, eqType: string) {
72
- super(message, 210, 400);
73
- this.name = 'EquipmentError';
74
- this.equipmentType = eqType;
75
- }
76
- public equipmentType: string;
77
- }
78
- export class EquipmentNotFoundError extends EquipmentError {
79
- constructor(message: string, eqType: string) {
80
- super(message, 204, eqType);
81
- this.name = 'EquipmentNotFound';
82
- }
83
- }
84
- export class InvalidEquipmentIdError extends EquipmentError {
85
- constructor(message: string, id: number, eqType: string) {
86
- super(message, 250, eqType);
87
- this.name = 'InvalidEquipmentId';
88
- }
89
- public id: number;
90
- }
91
- export class InvalidEquipmentDataError extends EquipmentError {
92
- constructor(message: string, eqType: string, eqData) {
93
- super(message, 270, eqType);
94
- this.name = 'InvalidEquipmentData';
95
- this.eqData = eqData;
96
- }
97
- public eqData;
98
- }
99
- export class ServiceProcessError extends ApiError {
100
- constructor(message: string, serviceName: string, process?: string) {
101
- super(message, 290, 400);
102
- this.name = 'ServiceProcessError';
103
- this.service = serviceName;
104
- this.process = process;
105
- }
106
- public process: string;
107
- public service: string;
108
- }
109
- export class ServiceParameterError extends ApiError {
110
- constructor(message: string, serviceName: string, paramName: string, value) {
111
- super(message, 280, 400);
112
- this.name = 'InvalidServiceParameter';
113
-
114
- this.value = value;
115
- this.parameter = paramName;
116
- this.service = serviceName;
117
- }
118
- public value;
119
- public parameter: string;
120
- public service: string;
121
- }
122
- export class InvalidOperationError extends ApiError {
123
- constructor(message: string, operation: string) {
124
- super(message, 100, 400);
125
- this.name = 'InvalidOperation';
126
- this.operation = operation;
127
- }
128
- public operation: string;
129
- }
130
- export class EquipmentTimeoutError extends ApiError {
131
- constructor(message: string, operation: string) {
132
- super(message, 100, 400);
133
- this.name = 'TimeoutError';
134
- this.operation = operation;
135
- }
136
- public operation: string;
137
- }
138
- export class ParameterOutOfRangeError extends InvalidOperationError {
139
- constructor(message: string, operation: string, parameter: string, value) {
140
- super(message, operation);
141
- this.name = 'ParameterOutOfRange';
142
- this.operation = operation;
143
- }
144
- public value;
145
- public parameter: string;
146
- }
147
- export class BoardProcessError extends ApiError {
148
- constructor(message: string, process?: string) {
149
- super(message, 300, 400);
150
- this.name = 'ProcessingError';
151
- this.process = process;
152
- }
153
- public process: string;
154
-
155
- }
156
-
157
- export class MessageError extends ApiError {
158
- constructor(msg: Message, message: string, code?: number, httpCode?: number) {
159
- super(message, code, httpCode);
160
- this.name = 'MessageError';
161
- this.msg = msg;
162
- this.code = code || 500;
163
- }
164
- public msg: Message;
165
- }
166
- export class OutboundMessageError extends MessageError {
167
- constructor(msg: Outbound, message: string, code?: number, httpCode?: number) {
168
- super(msg, message, code, httpCode);
169
- this.name = 'OutboundMessageError';
170
- this.code = code || 501;
171
- }
172
- }
173
- export class InboundMessageError extends MessageError {
174
- constructor(msg: Inbound, message: string, code?: number, httpCode?: number) {
175
- super(msg, message, code, httpCode);
176
- this.name = 'InboundMessageError';
177
- this.code = code || 502;
178
- }
179
- }
180
-
1
+ /* nodejs-poolController. An application to control pool equipment.
2
+ Copyright (C) 2016, 2017, 2018, 2019, 2020. Russell Goldin, tagyoureit. russ.goldin@gmail.com
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as
6
+ published by the Free Software Foundation, either version 3 of the
7
+ License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ import extend = require("extend");
18
+ import { Message, Outbound, Inbound } from "./comms/messages/Messages";
19
+ import * as path from "path";
20
+
21
+ // Internal abstract class for all errors.
22
+ class ApiError extends Error {
23
+ constructor(message: string, code?: number, httpCode?: number) {
24
+ super(message);
25
+ this.name = 'ApiError';
26
+ this.code = code || 0;
27
+ this.httpCode = httpCode || 400;
28
+ let pos: any = {};
29
+ if (typeof this.stack !== 'undefined') {
30
+ try {
31
+ // Another weirdo decision by NodeJS to not include the line numbers and source. Only a text based stack trace.
32
+ let lines = this.stack.split('\n');
33
+ for (let i = 0; i < lines.length; i++) {
34
+ let line = lines[i];
35
+ if (line.trimLeft().startsWith('at ')) {
36
+ let lastParen = line.lastIndexOf(')');
37
+ let firstParen = line.indexOf('(');
38
+ if (lastParen >= 0 && firstParen >= 0) {
39
+ let p = line.substring(firstParen + 1, lastParen);
40
+ let m = /(\:\d+\:\d+)(?!.*\1)/g;
41
+ let matches = p.match(m);
42
+ let linecol = '';
43
+ let lastIndex = -1;
44
+ if (matches.length > 0) {
45
+ linecol = matches[matches.length - 1];
46
+ lastIndex = p.lastIndexOf(linecol);
47
+ p = p.substring(0, lastIndex);
48
+ if (linecol.startsWith(':')) linecol = linecol.substring(1);
49
+ let lastcolon = linecol.lastIndexOf(':');
50
+ if (lastcolon !== -1) {
51
+ pos.column = parseInt(linecol.substring(lastcolon + 1), 10);
52
+ pos.line = parseInt(linecol.substring(0, lastcolon), 10);
53
+ }
54
+ }
55
+ let po = path.parse(p);
56
+ pos.dir = po.dir;
57
+ pos.file = po.base;
58
+ }
59
+ break;
60
+ }
61
+ }
62
+ } catch (e) { }
63
+ }
64
+ this.position = pos;
65
+ }
66
+ public code: number = 0;
67
+ public httpCode: number = 500;
68
+ public position: any = {}
69
+ }
70
+ class EquipmentError extends ApiError {
71
+ constructor(message: string, code: number, eqType: string) {
72
+ super(message, 210, 400);
73
+ this.name = 'EquipmentError';
74
+ this.equipmentType = eqType;
75
+ }
76
+ public equipmentType: string;
77
+ }
78
+ export class EquipmentNotFoundError extends EquipmentError {
79
+ constructor(message: string, eqType: string) {
80
+ super(message, 204, eqType);
81
+ this.name = 'EquipmentNotFound';
82
+ }
83
+ }
84
+ export class InvalidEquipmentIdError extends EquipmentError {
85
+ constructor(message: string, id: number, eqType: string) {
86
+ super(message, 250, eqType);
87
+ this.name = 'InvalidEquipmentId';
88
+ }
89
+ public id: number;
90
+ }
91
+ export class InvalidEquipmentDataError extends EquipmentError {
92
+ constructor(message: string, eqType: string, eqData) {
93
+ super(message, 270, eqType);
94
+ this.name = 'InvalidEquipmentData';
95
+ this.eqData = eqData;
96
+ }
97
+ public eqData;
98
+ }
99
+ export class ServiceProcessError extends ApiError {
100
+ constructor(message: string, serviceName: string, process?: string) {
101
+ super(message, 290, 400);
102
+ this.name = 'ServiceProcessError';
103
+ this.service = serviceName;
104
+ this.process = process;
105
+ }
106
+ public process: string;
107
+ public service: string;
108
+ }
109
+ export class ServiceParameterError extends ApiError {
110
+ constructor(message: string, serviceName: string, paramName: string, value) {
111
+ super(message, 280, 400);
112
+ this.name = 'InvalidServiceParameter';
113
+
114
+ this.value = value;
115
+ this.parameter = paramName;
116
+ this.service = serviceName;
117
+ }
118
+ public value;
119
+ public parameter: string;
120
+ public service: string;
121
+ }
122
+ export class InvalidOperationError extends ApiError {
123
+ constructor(message: string, operation: string) {
124
+ super(message, 100, 400);
125
+ this.name = 'InvalidOperation';
126
+ this.operation = operation;
127
+ }
128
+ public operation: string;
129
+ }
130
+ export class EquipmentTimeoutError extends ApiError {
131
+ constructor(message: string, operation: string) {
132
+ super(message, 100, 400);
133
+ this.name = 'TimeoutError';
134
+ this.operation = operation;
135
+ }
136
+ public operation: string;
137
+ }
138
+ export class ParameterOutOfRangeError extends InvalidOperationError {
139
+ constructor(message: string, operation: string, parameter: string, value) {
140
+ super(message, operation);
141
+ this.name = 'ParameterOutOfRange';
142
+ this.operation = operation;
143
+ }
144
+ public value;
145
+ public parameter: string;
146
+ }
147
+ export class BoardProcessError extends ApiError {
148
+ constructor(message: string, process?: string) {
149
+ super(message, 300, 400);
150
+ this.name = 'ProcessingError';
151
+ this.process = process;
152
+ }
153
+ public process: string;
154
+
155
+ }
156
+
157
+ export class MessageError extends ApiError {
158
+ constructor(msg: Message, message: string, code?: number, httpCode?: number) {
159
+ super(message, code, httpCode);
160
+ this.name = 'MessageError';
161
+ this.msg = msg;
162
+ this.code = code || 500;
163
+ }
164
+ public msg: Message;
165
+ }
166
+ export class OutboundMessageError extends MessageError {
167
+ constructor(msg: Outbound, message: string, code?: number, httpCode?: number) {
168
+ super(msg, message, code, httpCode);
169
+ this.name = 'OutboundMessageError';
170
+ this.code = code || 501;
171
+ }
172
+ }
173
+ export class InboundMessageError extends MessageError {
174
+ constructor(msg: Inbound, message: string, code?: number, httpCode?: number) {
175
+ super(msg, message, code, httpCode);
176
+ this.name = 'InboundMessageError';
177
+ this.code = code || 502;
178
+ }
179
+ }
180
+