nodejs-poolcontroller 8.3.0 → 8.4.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 (107) 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/157_issues.md +101 -0
  9. package/AGENTS.md +613 -0
  10. package/CONTRIBUTING.md +74 -74
  11. package/Changelog +292 -284
  12. package/Dockerfile +62 -62
  13. package/Gruntfile.js +40 -40
  14. package/LICENSE +661 -661
  15. package/README.md +329 -309
  16. package/anslq25/MessagesMock.ts +221 -221
  17. package/anslq25/boards/MockBoardFactory.ts +49 -49
  18. package/anslq25/boards/MockEasyTouchBoard.ts +696 -696
  19. package/anslq25/boards/MockSystemBoard.ts +216 -216
  20. package/anslq25/chemistry/MockChlorinator.ts +98 -98
  21. package/anslq25/pumps/MockPump.ts +83 -83
  22. package/app.ts +115 -115
  23. package/config/Config.ts +0 -0
  24. package/config/VersionCheck.ts +0 -0
  25. package/controller/Constants.ts +809 -805
  26. package/controller/Equipment.ts +2737 -2664
  27. package/controller/Errors.ts +181 -181
  28. package/controller/Lockouts.ts +549 -549
  29. package/controller/State.ts +3746 -3701
  30. package/controller/boards/AquaLinkBoard.ts +1175 -1003
  31. package/controller/boards/BoardFactory.ts +53 -53
  32. package/controller/boards/EasyTouchBoard.ts +3246 -3202
  33. package/controller/boards/IntelliCenterBoard.ts +4581 -3899
  34. package/controller/boards/IntelliComBoard.ts +69 -69
  35. package/controller/boards/IntelliTouchBoard.ts +382 -382
  36. package/controller/boards/NixieBoard.ts +1947 -1944
  37. package/controller/boards/SunTouchBoard.ts +401 -400
  38. package/controller/boards/SystemBoard.ts +5303 -5268
  39. package/controller/comms/Comms.ts +1278 -1255
  40. package/controller/comms/ScreenLogic.ts +1665 -1665
  41. package/controller/comms/messages/Messages.ts +1627 -1406
  42. package/controller/comms/messages/config/ChlorinatorMessage.ts +5 -0
  43. package/controller/comms/messages/config/CircuitGroupMessage.ts +0 -0
  44. package/controller/comms/messages/config/CircuitMessage.ts +0 -0
  45. package/controller/comms/messages/config/ConfigMessage.ts +6 -0
  46. package/controller/comms/messages/config/CoverMessage.ts +0 -0
  47. package/controller/comms/messages/config/CustomNameMessage.ts +31 -31
  48. package/controller/comms/messages/config/EquipmentMessage.ts +250 -210
  49. package/controller/comms/messages/config/ExternalMessage.ts +1051 -903
  50. package/controller/comms/messages/config/FeatureMessage.ts +0 -0
  51. package/controller/comms/messages/config/GeneralMessage.ts +65 -0
  52. package/controller/comms/messages/config/HeaterMessage.ts +0 -0
  53. package/controller/comms/messages/config/IntellichemMessage.ts +0 -0
  54. package/controller/comms/messages/config/OptionsMessage.ts +207 -174
  55. package/controller/comms/messages/config/PumpMessage.ts +427 -421
  56. package/controller/comms/messages/config/RemoteMessage.ts +0 -0
  57. package/controller/comms/messages/config/ScheduleMessage.ts +401 -390
  58. package/controller/comms/messages/config/SecurityMessage.ts +37 -13
  59. package/controller/comms/messages/config/ValveMessage.ts +0 -0
  60. package/controller/comms/messages/status/ChlorinatorStateMessage.ts +0 -0
  61. package/controller/comms/messages/status/EquipmentStateMessage.ts +940 -822
  62. package/controller/comms/messages/status/HeaterStateMessage.ts +147 -135
  63. package/controller/comms/messages/status/IntelliChemStateMessage.ts +448 -448
  64. package/controller/comms/messages/status/IntelliValveStateMessage.ts +36 -36
  65. package/controller/comms/messages/status/NeptuneModbusStateMessage.ts +217 -0
  66. package/controller/comms/messages/status/PumpStateMessage.ts +0 -0
  67. package/controller/comms/messages/status/RegalModbusStateMessage.ts +410 -410
  68. package/controller/comms/messages/status/VersionMessage.ts +152 -41
  69. package/controller/nixie/Nixie.ts +173 -173
  70. package/controller/nixie/NixieEquipment.ts +104 -104
  71. package/controller/nixie/bodies/Body.ts +120 -120
  72. package/controller/nixie/bodies/Filter.ts +135 -135
  73. package/controller/nixie/chemistry/ChemController.ts +2756 -2724
  74. package/controller/nixie/chemistry/ChemDoser.ts +806 -806
  75. package/controller/nixie/chemistry/Chlorinator.ts +367 -367
  76. package/controller/nixie/circuits/Circuit.ts +478 -478
  77. package/controller/nixie/heaters/Heater.ts +843 -834
  78. package/controller/nixie/pumps/Pump.ts +1336 -1193
  79. package/controller/nixie/schedules/Schedule.ts +401 -401
  80. package/controller/nixie/valves/Valve.ts +170 -170
  81. package/defaultConfig.json +352 -352
  82. package/docker-compose.yml +32 -31
  83. package/logger/DataLogger.ts +448 -448
  84. package/logger/Logger.ts +459 -436
  85. package/package.json +58 -58
  86. package/sendSocket.js +32 -32
  87. package/tsconfig.json +26 -25
  88. package/types/express-multer.d.ts +32 -32
  89. package/web/Server.ts +1939 -1927
  90. package/web/bindings/aqualinkD.json +559 -559
  91. package/web/bindings/influxDB.json +1066 -1066
  92. package/web/bindings/mqtt.json +721 -721
  93. package/web/bindings/mqttAlt.json +746 -746
  94. package/web/bindings/rulesManager.json +54 -54
  95. package/web/bindings/smartThings-Hubitat.json +31 -31
  96. package/web/bindings/valveRelays.json +20 -20
  97. package/web/bindings/vera.json +25 -25
  98. package/web/interfaces/baseInterface.ts +188 -188
  99. package/web/interfaces/httpInterface.ts +148 -148
  100. package/web/interfaces/influxInterface.ts +283 -283
  101. package/web/interfaces/mqttInterface.ts +695 -695
  102. package/web/interfaces/ruleInterface.ts +101 -87
  103. package/web/services/config/Config.ts +1212 -1053
  104. package/web/services/config/ConfigSocket.ts +0 -0
  105. package/web/services/state/State.ts +21 -0
  106. package/web/services/state/StateSocket.ts +28 -0
  107. package/web/services/utilities/Utilities.ts +233 -233
@@ -1,383 +1,383 @@
1
- /* nodejs-poolController. An application to control pool equipment.
2
- Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022.
3
- Russell Goldin, tagyoureit. russ.goldin@gmail.com
4
-
5
- This program is free software: you can redistribute it and/or modify
6
- it under the terms of the GNU Affero General Public License as
7
- published by the Free Software Foundation, either version 3 of the
8
- License, or (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU Affero General Public License for more details.
14
-
15
- You should have received a copy of the GNU Affero General Public License
16
- along with this program. If not, see <http://www.gnu.org/licenses/>.
17
- */
18
- import { byteValueMap, EquipmentIdRange, } from './SystemBoard';
19
- import { logger } from '../../logger/Logger';
20
- import { EasyTouchBoard, TouchConfigQueue, GetTouchConfigCategories, TouchCircuitCommands } from './EasyTouchBoard';
21
- import { state, ICircuitGroupState } from '../State';
22
- import { PoolSystem, sys, ExpansionPanel, Equipment } from '../Equipment';
23
-
24
- import { conn } from '../comms/Comms';
25
- import { InvalidEquipmentDataError } from '../Errors';
26
- import { log } from 'winston';
27
-
28
- export class IntelliTouchBoard extends EasyTouchBoard {
29
- constructor(system: PoolSystem) {
30
- super(system);
31
- // Circuits even in single body IntelliTouch always start at 1.
32
- this.equipmentIds.circuits.start = 1;
33
- this.equipmentIds.features.start = 41;
34
- this.equipmentIds.features.end = 50;
35
- this.equipmentIds.virtualCircuits = new EquipmentIdRange(154, 162);
36
- this._configQueue = new ITTouchConfigQueue();
37
- this.valueMaps.expansionBoards = new byteValueMap([
38
- [0, { name: 'IT5', part: 'i5+3', desc: 'IntelliTouch i5+3', circuits: 6, shared: true }],
39
- [1, { name: 'IT7', part: 'i7+3', desc: 'IntelliTouch i7+3', circuits: 8, shared: true }],
40
- [2, { name: 'IT9', part: 'i9+3', desc: 'IntelliTouch i9+3', circuits: 10, shared: true }],
41
- [3, { name: 'IT5S', part: 'i5+3S', desc: 'IntelliTouch i5+3S', circuits: 5, single: true, shared: true, bodies: 2, intakeReturnValves: false }],
42
- [4, { name: 'IT9S', part: 'i9+3S', desc: 'IntelliTouch i9+3S', circuits: 9, single: true, shared: true, bodies: 2, intakeReturnValves: false }],
43
- [5, { name: 'IT10D', part: 'i10D', desc: 'IntelliTouch i10D', circuits: 10, single: true, shared: false, dual: true }],
44
- [32, { name: 'IT5X', part: 'i5X', desc: 'IntelliTouch i5X', circuits: 5 }],
45
- [33, { name: 'IT10X', part: 'i10X', desc: 'IntelliTouch i10X', circuits: 10 }],
46
- [64, { name: 'Valve Exp', part: '520285', desc: 'Valve Expansion Module', valves: 3 }]
47
- ]);
48
- // I don't think these have ever been right.
49
- // So far I have seen below based on discussion #436
50
- // 155 = heater
51
- // 156 = poolheater
52
- // 157 = spaheater
53
- this.valueMaps.virtualCircuits = new byteValueMap([
54
- [154, { name: 'freeze', desc: 'Freeze', assignableToPumpCircuit: true }],
55
- [155, { name: 'spaHeater', desc: 'Spa Heater', assignableToPumpCircuit: true }],
56
- [156, { name: 'poolHeater', desc: 'Pool Heater', assignableToPumpCircuit: true }],
57
- [157, { name: 'heater', desc: 'Either Heater', assignableToPumpCircuit: true }],
58
- [158, { name: 'solar', desc: 'Solar', assignableToPumpCircuit: true }],
59
- [159, { name: 'heatBoost', desc: 'Heat Boost', assignableToPumpCircuit: false }],
60
- [160, { name: 'heatEnable', desc: 'Heat Enable', assignableToPumpCircuit: false }],
61
- [161, { name: 'pumpSpeedUp', desc: 'Pump Speed +', assignableToPumpCircuit: false }],
62
- [162, { name: 'pumpSpeedDown', desc: 'Pump Speed -', assignableToPumpCircuit: false }],
63
- [255, { name: 'notused', desc: 'NOT USED', assignableToPumpCircuit: true }],
64
- [258, { name: 'anyHeater', desc: 'Any Heater' }]
65
- ]);
66
- }
67
- public initVirtualCircuits() {
68
- for (let i = state.virtualCircuits.length - 1; i >= 0; i--) {
69
- let vc = state.virtualCircuits.getItemByIndex(i);
70
- if (vc.id > this.equipmentIds.virtualCircuits.end ||
71
- vc.id < this.equipmentIds.virtualCircuits.start) state.virtualCircuits.removeItemByIndex(i);
72
- }
73
- // Now that we removed all the virtual circuits that should not be there we need
74
- // to update them based upon the data.
75
- }
76
- public initValves(eq) {
77
- if (typeof sys.valves.find((v) => v.id === 1) === 'undefined') {
78
- let valve = sys.valves.getItemById(1, true);
79
- valve.isIntake = false;
80
- valve.isReturn = false;
81
- valve.type = 0;
82
- valve.master = 0;
83
- valve.isActive = true;
84
- valve.name = 'Valve A';
85
- logger.info(`Initializing IntelliTouch Valve A`);
86
-
87
- }
88
- if (typeof sys.valves.find((v) => v.id === 2) === 'undefined') {
89
- let valve = sys.valves.getItemById(2, true);
90
- valve.isIntake = false;
91
- valve.isReturn = false;
92
- valve.type = 0;
93
- valve.master = 0;
94
- valve.isActive = true;
95
- valve.name = 'Valve B';
96
- logger.info(`Initializing IntelliTouch Valve B`);
97
- }
98
- if (eq.intakeReturnValves) {
99
- logger.info(`Initializing IntelliTouch Intake/Return Valves`);
100
- let valve = sys.valves.getItemById(3, true);
101
- valve.isIntake = true;
102
- valve.isReturn = false;
103
- valve.circuit = 6;
104
- valve.type = 0;
105
- valve.master = 0;
106
- valve.isActive = true;
107
- valve.name = 'Intake';
108
-
109
- valve = sys.valves.getItemById(4, true);
110
- valve.isIntake = false;
111
- valve.isReturn = true;
112
- valve.circuit = 6;
113
- valve.type = 0;
114
- valve.master = 0;
115
- valve.isActive = true;
116
- valve.name = 'Return';
117
- }
118
- }
119
- public initExpansionModules(byte1: number, byte2: number) {
120
- console.log(`Pentair IntelliTouch System Detected!`);
121
- // For i9+3S with valve expansion the bytes are 4, 32 the expectation is
122
- // that the 32 contains the indicator that there is a valve expansion module.
123
-
124
-
125
- // Initialize the installed personality board.
126
- let mt = this.valueMaps.expansionBoards.transform(byte1);
127
- let mod = sys.equipment.modules.getItemById(0, true);
128
- mod.name = mt.name;
129
- mod.desc = mt.desc;
130
- mod.type = byte1;
131
- mod.part = mt.part;
132
- let eq = sys.equipment;
133
- let md = mod.get();
134
-
135
- //eq.maxBodies = md.bodies = typeof mt.bodies !== 'undefined' ? mt.bodies : mt.shared || mt.dual ? 2 : 1;
136
- // There are always 2 bodies on an IntelliTouch even the single body models.
137
- eq.maxBodies = 2;
138
- eq.maxCircuits = md.circuits = typeof mt.circuits !== 'undefined' ? mt.circuits : 6;
139
- eq.maxFeatures = md.features = typeof mt.features !== 'undefined' ? mt.features : 8;
140
- eq.maxValves = md.valves = typeof mt.valves !== 'undefined' ? mt.valves : mt.shared ? 4 : 2;
141
- eq.maxPumps = md.maxPumps = typeof mt.pumps !== 'undefined' ? mt.pumps : 8;
142
- eq.shared = mt.shared;
143
- eq.dual = typeof mt.dual !== 'undefined' ? mt.dual : false;
144
- eq.single = typeof mt.single !== 'undefined' ? mt.single : false;
145
- eq.intakeReturnValves = eq.single ? false : true;
146
- eq.maxChlorinators = md.chlorinators = 1;
147
- eq.maxChemControllers = md.chemControllers = 1;
148
- eq.maxCustomNames = 20;
149
- eq.maxSchedules = 99;
150
- eq.maxCircuitGroups = 10; // Not sure why this is 10 other than to allow for those that we are in control of.
151
- if (eq.single) {
152
- // Replace the body types with Hi-Temp and Lo-Temp
153
- sys.board.valueMaps.bodyTypes.merge([[0, { name: 'pool', desc: 'Lo-Temp' }],
154
- [1, { name: 'spa', desc: 'Hi-Temp' }]]);
155
- }
156
- // Calculate out the invalid ids.
157
- // Add in all the invalid ids from the base personality board.
158
- sys.board.equipmentIds.invalidIds.set([16, 17, 18]); // These appear to alway be invalid in IntelliTouch.
159
- for (let i = 7; i <= 10; i++) {
160
- // This will add all the invalid ids between 7 and 10 that are omitted for IntelliTouch models.
161
- // For instance an i7+3 can have up to 8 circuits since 1 and 6 are shared but an i7+3S will only have 7.
162
- if (i > eq.maxCircuits) sys.board.equipmentIds.invalidIds.merge([i]);
163
- }
164
- // This code should be repeated if we ever see a panel with more than one expansion panel.
165
- let pnl1: ExpansionPanel;
166
- if ((byte2 & 0x40) === 64) {
167
- // 64 indicates one expansion panel; SL defaults to i10x but it could also be i5x until we know better
168
- pnl1 = sys.equipment.expansions.getItemById(1, true);
169
- pnl1.type = 32;
170
- let emt = this.valueMaps.expansionBoards.transform(pnl1.type);
171
- pnl1.name = emt.desc;
172
- pnl1.isActive = true;
173
- eq.maxCircuits += emt.circuits;
174
- }
175
- else sys.equipment.expansions.removeItemById(1);
176
- let pnl2: ExpansionPanel;
177
- if ((byte2 & 0x80) === 128) {
178
- // SL defaults to i5x but it could also be i10x until we know better
179
- pnl2 = sys.equipment.expansions.getItemById(2, true);
180
- pnl2.type = 32;
181
- let emt = this.valueMaps.expansionBoards.transform(pnl2.type);
182
- pnl2.name = emt.desc;
183
- pnl2.isActive = true;
184
- eq.maxCircuits += emt.circuits;
185
- }
186
- else sys.equipment.expansions.removeItemById(2);
187
- let pnl3: ExpansionPanel;
188
- if ((byte2 & 0xC0) === 192) {
189
- // SL defaults to i5x but it could also be i10x until we know better
190
- pnl3 = sys.equipment.expansions.getItemById(3, true);
191
- pnl3.type = 32;
192
- let emt = this.valueMaps.expansionBoards.transform(pnl3.type);
193
- pnl3.name = emt.desc;
194
- pnl3.isActive = true;
195
- eq.maxCircuits += emt.circuits;
196
- }
197
- else sys.equipment.expansions.removeItemById(3);
198
- // Detect the valve expansion module.
199
- if ((byte2 & 0x20) === 20) {
200
- // The valve expansion module is installed so this should add 3 valves.
201
- eq.maxValves += 3;
202
- let vexp = eq.modules.getItemById(1, true);
203
- vexp.isActive = true;
204
- let mt = this.valueMaps.expansionBoards.transform(64);
205
- vexp.name = mt.name;
206
- vexp.desc = mt.desc;
207
- vexp.type = byte1;
208
- vexp.part = mt.part;
209
- }
210
- else eq.modules.removeItemById(1);
211
- if (byte1 !== 14) sys.board.equipmentIds.invalidIds.merge([10, 19]);
212
- state.equipment.model = sys.equipment.model = mt.desc;
213
- state.equipment.controllerType = 'intellitouch';
214
- this.initBodyDefaults();
215
- this.initHeaterDefaults();
216
- (async () => {
217
- try { sys.board.bodies.initFilters(); } catch (err) {
218
- logger.error(`Error initializing IntelliTouch Filters`);
219
- }
220
- })();
221
- for (let i = 0; i < sys.circuits.length; i++) {
222
- let c = sys.circuits.getItemByIndex(i);
223
- if (c.id <= 40) c.master = 0;
224
- }
225
- for (let i = 0; i < sys.valves.length; i++) {
226
- let v = sys.valves.getItemByIndex(i);
227
- if (v.id < 50) v.master = 0;
228
- }
229
- // Clean up any schedules that shouldn't be there.
230
- for (let i = sys.schedules.length - 1; i > 0; i--) {
231
- let sched = sys.schedules.getItemByIndex(i);
232
- if (sched.id < 1) {
233
- sys.schedules.removeItemByIndex(i);
234
- state.schedules.removeItemById(sched.id);
235
- }
236
- if (sched.id < eq.maxSchedules) sched.master = 0;
237
- else if (sched.id > eq.maxSchedules && (sched.master === 0 || typeof sched.master === 'undefined')) {
238
- sys.schedules.removeItemByIndex(i);
239
- state.schedules.removeItemById(sched.id);
240
- }
241
- }
242
- eq.setEquipmentIds();
243
- this.initVirtualCircuits();
244
- this.initValves(eq);
245
- state.equipment.maxBodies = sys.equipment.maxBodies;
246
- state.equipment.maxCircuitGroups = sys.equipment.maxCircuitGroups;
247
- state.equipment.maxCircuits = sys.equipment.maxCircuits;
248
- state.equipment.maxFeatures = sys.equipment.maxFeatures;
249
- state.equipment.maxHeaters = sys.equipment.maxHeaters;
250
- state.equipment.maxLightGroups = sys.equipment.maxLightGroups;
251
- state.equipment.maxPumps = sys.equipment.maxPumps;
252
- state.equipment.maxSchedules = sys.equipment.maxSchedules;
253
- state.equipment.maxValves = sys.equipment.maxValves;
254
- state.equipment.single = sys.equipment.single;
255
- state.equipment.shared = sys.equipment.shared;
256
- state.equipment.dual = sys.equipment.dual;
257
-
258
- state.emitControllerChange();
259
-
260
- }
261
- public circuits: ITTouchCircuitCommands = new ITTouchCircuitCommands(this);
262
- public async setControllerType(obj): Promise<Equipment> {
263
- try {
264
- if (obj.controllerType !== sys.controllerType) {
265
- return Promise.reject(new InvalidEquipmentDataError(`You may not change the controller type data for ${sys.controllerType} controllers`, 'controllerType', obj.controllerType));
266
- }
267
-
268
- let mod = sys.equipment.modules.getItemById(0);
269
- let mt = this.valueMaps.expansionBoards.get(mod.type);
270
- let _circuits = mt.circuits;
271
- let pnl1 = sys.equipment.expansions.getItemById(1);
272
- if (typeof obj.expansion1 !== 'undefined' && obj.expansion1 !== pnl1.type) {
273
- let emt = this.valueMaps.expansionBoards.transform(obj.expansion1);
274
- logger.info(`Changing expansion 1 to ${emt.desc}.`);
275
- pnl1.type = emt.val;
276
- pnl1.name = emt.desc;
277
- pnl1.isActive = true;
278
- }
279
- let pnl2 = sys.equipment.expansions.getItemById(2);
280
- if (typeof obj.expansion2 !== 'undefined' && obj.expansion2 !== pnl2.type) {
281
- let emt = this.valueMaps.expansionBoards.transform(obj.expansion2);
282
- logger.info(`Changing expansion 2 to ${emt.desc}.`);
283
- pnl2.type = emt.val;
284
- pnl2.name = emt.desc;
285
- pnl2.isActive = true;
286
- }
287
- let pnl3 = sys.equipment.expansions.getItemById(3);
288
- if (typeof obj.expansion3 !== 'undefined' && obj.expansion3 !== pnl3.type) {
289
- let emt = this.valueMaps.expansionBoards.transform(obj.expansion3);
290
- logger.info(`Changing expansion 3 to ${emt.desc}.`);
291
- pnl3.type = emt.val;
292
- pnl3.name = emt.desc;
293
- pnl3.isActive = true;
294
- }
295
- let prevMaxCircuits = sys.equipment.maxCircuits;
296
- if (pnl1.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl1.type).circuits;
297
- if (pnl2.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl2.type).circuits;
298
- if (pnl3.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl3.type).circuits;
299
- if (_circuits < prevMaxCircuits) {
300
- // if we downsize expansions, remove circuits
301
- for (let i = _circuits + 1; i <= prevMaxCircuits; i++) {
302
- sys.circuits.removeItemById(i);
303
- state.circuits.removeItemById(i);
304
- }
305
- }
306
- else if (_circuits > prevMaxCircuits) {
307
- this._configQueue.queueChanges();
308
- }
309
- sys.equipment.maxCircuits = _circuits;
310
- return sys.equipment;
311
- } catch (err) {
312
- logger.error(`Error setting expansion panels: ${err.message}`);
313
- }
314
- }
315
- public initBodyDefaults() {
316
- // Initialize the bodies. We will need these very soon.
317
- for (let i = 1; i <= sys.equipment.maxBodies; i++) {
318
- // Add in the bodies for the configuration. These need to be set.
319
- let cbody = sys.bodies.getItemById(i, true);
320
- let tbody = state.temps.bodies.getItemById(i, true);
321
- cbody.isActive = true;
322
- // If the body doesn't represent a spa then we set the type.
323
- tbody.type = cbody.type = i - 1; // This will set the first body to pool/Lo-Temp and the second body to spa/Hi-Temp.
324
- if (typeof cbody.name === 'undefined') {
325
- let bt = sys.board.valueMaps.bodyTypes.transform(cbody.type);
326
- tbody.name = cbody.name = bt.desc;
327
- }
328
- }
329
- sys.bodies.removeItemById(3);
330
- sys.bodies.removeItemById(4);
331
- state.temps.bodies.removeItemById(3);
332
- state.temps.bodies.removeItemById(4);
333
- for (let i = 0; i < sys.bodies.length; i++) {
334
- let b = sys.bodies.getItemByIndex(i);
335
- b.master = 0;
336
- }
337
- sys.board.heaters.initTempSensors();
338
- sys.general.options.clockMode = sys.general.options.clockMode || 12;
339
- sys.general.options.clockSource = sys.general.options.clockSource || 'manual';
340
- }
341
- }
342
- class ITTouchConfigQueue extends TouchConfigQueue {
343
- public queueChanges() {
344
- this.reset();
345
- logger.info(`Requesting ${sys.controllerType} configuration`);
346
- this.queueItems(GetTouchConfigCategories.dateTime, [0]);
347
- this.queueItems(GetTouchConfigCategories.heatTemperature, [0]);
348
- this.queueItems(GetTouchConfigCategories.solarHeatPump, [0]);
349
- this.queueRange(GetTouchConfigCategories.customNames, 0, sys.equipment.maxCustomNames - 1);
350
- this.queueRange(GetTouchConfigCategories.circuits, 1, sys.equipment.maxCircuits); // circuits
351
- this.queueRange(GetTouchConfigCategories.circuits, 41, 41 + sys.equipment.maxFeatures); // features
352
- this.queueRange(GetTouchConfigCategories.schedules, 1, sys.equipment.maxSchedules);
353
- this.queueItems(GetTouchConfigCategories.delays, [0]);
354
- this.queueItems(GetTouchConfigCategories.settings, [0]);
355
- this.queueItems(GetTouchConfigCategories.intellifloSpaSideRemotes, [0]);
356
- this.queueItems(GetTouchConfigCategories.is4is10, [0]);
357
- this.queueItems(GetTouchConfigCategories.quickTouchRemote, [0]);
358
- this.queueItems(GetTouchConfigCategories.valves, [0]);
359
- this.queueItems(GetTouchConfigCategories.lightGroupPositions);
360
- this.queueItems(GetTouchConfigCategories.highSpeedCircuits, [0]);
361
- this.queueRange(GetTouchConfigCategories.pumpConfig, 1, sys.equipment.maxPumps);
362
- this.queueRange(GetTouchConfigCategories.circuitGroups, 0, sys.equipment.maxFeatures - 1);
363
- this.queueItems(GetTouchConfigCategories.intellichlor, [0]);
364
- if (this.remainingItems > 0) {
365
- var self = this;
366
- setTimeout(() => { self.processNext(); }, 50);
367
- } else state.status = 1;
368
- state.emitControllerChange();
369
- }
370
- }
371
- class ITTouchCircuitCommands extends TouchCircuitCommands {
372
- public async setCircuitGroupStateAsync(id: number, val: boolean): Promise<ICircuitGroupState> {
373
- // intellitouch supports groups/macros with id's 41-50 with a macro flag
374
- let grp = sys.circuitGroups.getItemById(id, false, { isActive: false });
375
- return new Promise<ICircuitGroupState>(async (resolve, reject) => {
376
- try {
377
- await sys.board.circuits.setCircuitStateAsync(id, val);
378
- resolve(state.circuitGroups.getInterfaceById(id));
379
- }
380
- catch (err) { reject(err); }
381
- });
382
- }
1
+ /* nodejs-poolController. An application to control pool equipment.
2
+ Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022.
3
+ Russell Goldin, tagyoureit. russ.goldin@gmail.com
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as
7
+ published by the Free Software Foundation, either version 3 of the
8
+ License, or (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ import { byteValueMap, EquipmentIdRange, } from './SystemBoard';
19
+ import { logger } from '../../logger/Logger';
20
+ import { EasyTouchBoard, TouchConfigQueue, GetTouchConfigCategories, TouchCircuitCommands } from './EasyTouchBoard';
21
+ import { state, ICircuitGroupState } from '../State';
22
+ import { PoolSystem, sys, ExpansionPanel, Equipment } from '../Equipment';
23
+
24
+ import { conn } from '../comms/Comms';
25
+ import { InvalidEquipmentDataError } from '../Errors';
26
+ import { log } from 'winston';
27
+
28
+ export class IntelliTouchBoard extends EasyTouchBoard {
29
+ constructor(system: PoolSystem) {
30
+ super(system);
31
+ // Circuits even in single body IntelliTouch always start at 1.
32
+ this.equipmentIds.circuits.start = 1;
33
+ this.equipmentIds.features.start = 41;
34
+ this.equipmentIds.features.end = 50;
35
+ this.equipmentIds.virtualCircuits = new EquipmentIdRange(154, 162);
36
+ this._configQueue = new ITTouchConfigQueue();
37
+ this.valueMaps.expansionBoards = new byteValueMap([
38
+ [0, { name: 'IT5', part: 'i5+3', desc: 'IntelliTouch i5+3', circuits: 6, shared: true }],
39
+ [1, { name: 'IT7', part: 'i7+3', desc: 'IntelliTouch i7+3', circuits: 8, shared: true }],
40
+ [2, { name: 'IT9', part: 'i9+3', desc: 'IntelliTouch i9+3', circuits: 10, shared: true }],
41
+ [3, { name: 'IT5S', part: 'i5+3S', desc: 'IntelliTouch i5+3S', circuits: 5, single: true, shared: true, bodies: 2, intakeReturnValves: false }],
42
+ [4, { name: 'IT9S', part: 'i9+3S', desc: 'IntelliTouch i9+3S', circuits: 9, single: true, shared: true, bodies: 2, intakeReturnValves: false }],
43
+ [5, { name: 'IT10D', part: 'i10D', desc: 'IntelliTouch i10D', circuits: 10, single: true, shared: false, dual: true }],
44
+ [32, { name: 'IT5X', part: 'i5X', desc: 'IntelliTouch i5X', circuits: 5 }],
45
+ [33, { name: 'IT10X', part: 'i10X', desc: 'IntelliTouch i10X', circuits: 10 }],
46
+ [64, { name: 'Valve Exp', part: '520285', desc: 'Valve Expansion Module', valves: 3 }]
47
+ ]);
48
+ // I don't think these have ever been right.
49
+ // So far I have seen below based on discussion #436
50
+ // 155 = heater
51
+ // 156 = poolheater
52
+ // 157 = spaheater
53
+ this.valueMaps.virtualCircuits = new byteValueMap([
54
+ [154, { name: 'freeze', desc: 'Freeze', assignableToPumpCircuit: true }],
55
+ [155, { name: 'spaHeater', desc: 'Spa Heater', assignableToPumpCircuit: true }],
56
+ [156, { name: 'poolHeater', desc: 'Pool Heater', assignableToPumpCircuit: true }],
57
+ [157, { name: 'heater', desc: 'Either Heater', assignableToPumpCircuit: true }],
58
+ [158, { name: 'solar', desc: 'Solar', assignableToPumpCircuit: true }],
59
+ [159, { name: 'heatBoost', desc: 'Heat Boost', assignableToPumpCircuit: false }],
60
+ [160, { name: 'heatEnable', desc: 'Heat Enable', assignableToPumpCircuit: false }],
61
+ [161, { name: 'pumpSpeedUp', desc: 'Pump Speed +', assignableToPumpCircuit: false }],
62
+ [162, { name: 'pumpSpeedDown', desc: 'Pump Speed -', assignableToPumpCircuit: false }],
63
+ [255, { name: 'notused', desc: 'NOT USED', assignableToPumpCircuit: true }],
64
+ [258, { name: 'anyHeater', desc: 'Any Heater' }]
65
+ ]);
66
+ }
67
+ public initVirtualCircuits() {
68
+ for (let i = state.virtualCircuits.length - 1; i >= 0; i--) {
69
+ let vc = state.virtualCircuits.getItemByIndex(i);
70
+ if (vc.id > this.equipmentIds.virtualCircuits.end ||
71
+ vc.id < this.equipmentIds.virtualCircuits.start) state.virtualCircuits.removeItemByIndex(i);
72
+ }
73
+ // Now that we removed all the virtual circuits that should not be there we need
74
+ // to update them based upon the data.
75
+ }
76
+ public initValves(eq) {
77
+ if (typeof sys.valves.find((v) => v.id === 1) === 'undefined') {
78
+ let valve = sys.valves.getItemById(1, true);
79
+ valve.isIntake = false;
80
+ valve.isReturn = false;
81
+ valve.type = 0;
82
+ valve.master = 0;
83
+ valve.isActive = true;
84
+ valve.name = 'Valve A';
85
+ logger.info(`Initializing IntelliTouch Valve A`);
86
+
87
+ }
88
+ if (typeof sys.valves.find((v) => v.id === 2) === 'undefined') {
89
+ let valve = sys.valves.getItemById(2, true);
90
+ valve.isIntake = false;
91
+ valve.isReturn = false;
92
+ valve.type = 0;
93
+ valve.master = 0;
94
+ valve.isActive = true;
95
+ valve.name = 'Valve B';
96
+ logger.info(`Initializing IntelliTouch Valve B`);
97
+ }
98
+ if (eq.intakeReturnValves) {
99
+ logger.info(`Initializing IntelliTouch Intake/Return Valves`);
100
+ let valve = sys.valves.getItemById(3, true);
101
+ valve.isIntake = true;
102
+ valve.isReturn = false;
103
+ valve.circuit = 6;
104
+ valve.type = 0;
105
+ valve.master = 0;
106
+ valve.isActive = true;
107
+ valve.name = 'Intake';
108
+
109
+ valve = sys.valves.getItemById(4, true);
110
+ valve.isIntake = false;
111
+ valve.isReturn = true;
112
+ valve.circuit = 6;
113
+ valve.type = 0;
114
+ valve.master = 0;
115
+ valve.isActive = true;
116
+ valve.name = 'Return';
117
+ }
118
+ }
119
+ public initExpansionModules(byte1: number, byte2: number) {
120
+ console.log(`Pentair IntelliTouch System Detected!`);
121
+ // For i9+3S with valve expansion the bytes are 4, 32 the expectation is
122
+ // that the 32 contains the indicator that there is a valve expansion module.
123
+
124
+
125
+ // Initialize the installed personality board.
126
+ let mt = this.valueMaps.expansionBoards.transform(byte1);
127
+ let mod = sys.equipment.modules.getItemById(0, true);
128
+ mod.name = mt.name;
129
+ mod.desc = mt.desc;
130
+ mod.type = byte1;
131
+ mod.part = mt.part;
132
+ let eq = sys.equipment;
133
+ let md = mod.get();
134
+
135
+ //eq.maxBodies = md.bodies = typeof mt.bodies !== 'undefined' ? mt.bodies : mt.shared || mt.dual ? 2 : 1;
136
+ // There are always 2 bodies on an IntelliTouch even the single body models.
137
+ eq.maxBodies = 2;
138
+ eq.maxCircuits = md.circuits = typeof mt.circuits !== 'undefined' ? mt.circuits : 6;
139
+ eq.maxFeatures = md.features = typeof mt.features !== 'undefined' ? mt.features : 8;
140
+ eq.maxValves = md.valves = typeof mt.valves !== 'undefined' ? mt.valves : mt.shared ? 4 : 2;
141
+ eq.maxPumps = md.maxPumps = typeof mt.pumps !== 'undefined' ? mt.pumps : 8;
142
+ eq.shared = mt.shared;
143
+ eq.dual = typeof mt.dual !== 'undefined' ? mt.dual : false;
144
+ eq.single = typeof mt.single !== 'undefined' ? mt.single : false;
145
+ eq.intakeReturnValves = eq.single ? false : true;
146
+ eq.maxChlorinators = md.chlorinators = 1;
147
+ eq.maxChemControllers = md.chemControllers = 1;
148
+ eq.maxCustomNames = 20;
149
+ eq.maxSchedules = 99;
150
+ eq.maxCircuitGroups = 10; // Not sure why this is 10 other than to allow for those that we are in control of.
151
+ if (eq.single) {
152
+ // Replace the body types with Hi-Temp and Lo-Temp
153
+ sys.board.valueMaps.bodyTypes.merge([[0, { name: 'pool', desc: 'Lo-Temp' }],
154
+ [1, { name: 'spa', desc: 'Hi-Temp' }]]);
155
+ }
156
+ // Calculate out the invalid ids.
157
+ // Add in all the invalid ids from the base personality board.
158
+ sys.board.equipmentIds.invalidIds.set([16, 17, 18]); // These appear to alway be invalid in IntelliTouch.
159
+ for (let i = 7; i <= 10; i++) {
160
+ // This will add all the invalid ids between 7 and 10 that are omitted for IntelliTouch models.
161
+ // For instance an i7+3 can have up to 8 circuits since 1 and 6 are shared but an i7+3S will only have 7.
162
+ if (i > eq.maxCircuits) sys.board.equipmentIds.invalidIds.merge([i]);
163
+ }
164
+ // This code should be repeated if we ever see a panel with more than one expansion panel.
165
+ let pnl1: ExpansionPanel;
166
+ if ((byte2 & 0x40) === 64) {
167
+ // 64 indicates one expansion panel; SL defaults to i10x but it could also be i5x until we know better
168
+ pnl1 = sys.equipment.expansions.getItemById(1, true);
169
+ pnl1.type = 32;
170
+ let emt = this.valueMaps.expansionBoards.transform(pnl1.type);
171
+ pnl1.name = emt.desc;
172
+ pnl1.isActive = true;
173
+ eq.maxCircuits += emt.circuits;
174
+ }
175
+ else sys.equipment.expansions.removeItemById(1);
176
+ let pnl2: ExpansionPanel;
177
+ if ((byte2 & 0x80) === 128) {
178
+ // SL defaults to i5x but it could also be i10x until we know better
179
+ pnl2 = sys.equipment.expansions.getItemById(2, true);
180
+ pnl2.type = 32;
181
+ let emt = this.valueMaps.expansionBoards.transform(pnl2.type);
182
+ pnl2.name = emt.desc;
183
+ pnl2.isActive = true;
184
+ eq.maxCircuits += emt.circuits;
185
+ }
186
+ else sys.equipment.expansions.removeItemById(2);
187
+ let pnl3: ExpansionPanel;
188
+ if ((byte2 & 0xC0) === 192) {
189
+ // SL defaults to i5x but it could also be i10x until we know better
190
+ pnl3 = sys.equipment.expansions.getItemById(3, true);
191
+ pnl3.type = 32;
192
+ let emt = this.valueMaps.expansionBoards.transform(pnl3.type);
193
+ pnl3.name = emt.desc;
194
+ pnl3.isActive = true;
195
+ eq.maxCircuits += emt.circuits;
196
+ }
197
+ else sys.equipment.expansions.removeItemById(3);
198
+ // Detect the valve expansion module.
199
+ if ((byte2 & 0x20) === 20) {
200
+ // The valve expansion module is installed so this should add 3 valves.
201
+ eq.maxValves += 3;
202
+ let vexp = eq.modules.getItemById(1, true);
203
+ vexp.isActive = true;
204
+ let mt = this.valueMaps.expansionBoards.transform(64);
205
+ vexp.name = mt.name;
206
+ vexp.desc = mt.desc;
207
+ vexp.type = byte1;
208
+ vexp.part = mt.part;
209
+ }
210
+ else eq.modules.removeItemById(1);
211
+ if (byte1 !== 14) sys.board.equipmentIds.invalidIds.merge([10, 19]);
212
+ state.equipment.model = sys.equipment.model = mt.desc;
213
+ state.equipment.controllerType = 'intellitouch';
214
+ this.initBodyDefaults();
215
+ this.initHeaterDefaults();
216
+ (async () => {
217
+ try { sys.board.bodies.initFilters(); } catch (err) {
218
+ logger.error(`Error initializing IntelliTouch Filters`);
219
+ }
220
+ })();
221
+ for (let i = 0; i < sys.circuits.length; i++) {
222
+ let c = sys.circuits.getItemByIndex(i);
223
+ if (c.id <= 40) c.master = 0;
224
+ }
225
+ for (let i = 0; i < sys.valves.length; i++) {
226
+ let v = sys.valves.getItemByIndex(i);
227
+ if (v.id < 50) v.master = 0;
228
+ }
229
+ // Clean up any schedules that shouldn't be there.
230
+ for (let i = sys.schedules.length - 1; i > 0; i--) {
231
+ let sched = sys.schedules.getItemByIndex(i);
232
+ if (sched.id < 1) {
233
+ sys.schedules.removeItemByIndex(i);
234
+ state.schedules.removeItemById(sched.id);
235
+ }
236
+ if (sched.id < eq.maxSchedules) sched.master = 0;
237
+ else if (sched.id > eq.maxSchedules && (sched.master === 0 || typeof sched.master === 'undefined')) {
238
+ sys.schedules.removeItemByIndex(i);
239
+ state.schedules.removeItemById(sched.id);
240
+ }
241
+ }
242
+ eq.setEquipmentIds();
243
+ this.initVirtualCircuits();
244
+ this.initValves(eq);
245
+ state.equipment.maxBodies = sys.equipment.maxBodies;
246
+ state.equipment.maxCircuitGroups = sys.equipment.maxCircuitGroups;
247
+ state.equipment.maxCircuits = sys.equipment.maxCircuits;
248
+ state.equipment.maxFeatures = sys.equipment.maxFeatures;
249
+ state.equipment.maxHeaters = sys.equipment.maxHeaters;
250
+ state.equipment.maxLightGroups = sys.equipment.maxLightGroups;
251
+ state.equipment.maxPumps = sys.equipment.maxPumps;
252
+ state.equipment.maxSchedules = sys.equipment.maxSchedules;
253
+ state.equipment.maxValves = sys.equipment.maxValves;
254
+ state.equipment.single = sys.equipment.single;
255
+ state.equipment.shared = sys.equipment.shared;
256
+ state.equipment.dual = sys.equipment.dual;
257
+
258
+ state.emitControllerChange();
259
+
260
+ }
261
+ public circuits: ITTouchCircuitCommands = new ITTouchCircuitCommands(this);
262
+ public async setControllerType(obj): Promise<Equipment> {
263
+ try {
264
+ if (obj.controllerType !== sys.controllerType) {
265
+ return Promise.reject(new InvalidEquipmentDataError(`You may not change the controller type data for ${sys.controllerType} controllers`, 'controllerType', obj.controllerType));
266
+ }
267
+
268
+ let mod = sys.equipment.modules.getItemById(0);
269
+ let mt = this.valueMaps.expansionBoards.get(mod.type);
270
+ let _circuits = mt.circuits;
271
+ let pnl1 = sys.equipment.expansions.getItemById(1);
272
+ if (typeof obj.expansion1 !== 'undefined' && obj.expansion1 !== pnl1.type) {
273
+ let emt = this.valueMaps.expansionBoards.transform(obj.expansion1);
274
+ logger.info(`Changing expansion 1 to ${emt.desc}.`);
275
+ pnl1.type = emt.val;
276
+ pnl1.name = emt.desc;
277
+ pnl1.isActive = true;
278
+ }
279
+ let pnl2 = sys.equipment.expansions.getItemById(2);
280
+ if (typeof obj.expansion2 !== 'undefined' && obj.expansion2 !== pnl2.type) {
281
+ let emt = this.valueMaps.expansionBoards.transform(obj.expansion2);
282
+ logger.info(`Changing expansion 2 to ${emt.desc}.`);
283
+ pnl2.type = emt.val;
284
+ pnl2.name = emt.desc;
285
+ pnl2.isActive = true;
286
+ }
287
+ let pnl3 = sys.equipment.expansions.getItemById(3);
288
+ if (typeof obj.expansion3 !== 'undefined' && obj.expansion3 !== pnl3.type) {
289
+ let emt = this.valueMaps.expansionBoards.transform(obj.expansion3);
290
+ logger.info(`Changing expansion 3 to ${emt.desc}.`);
291
+ pnl3.type = emt.val;
292
+ pnl3.name = emt.desc;
293
+ pnl3.isActive = true;
294
+ }
295
+ let prevMaxCircuits = sys.equipment.maxCircuits;
296
+ if (pnl1.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl1.type).circuits;
297
+ if (pnl2.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl2.type).circuits;
298
+ if (pnl3.isActive) _circuits += this.valueMaps.expansionBoards.get(pnl3.type).circuits;
299
+ if (_circuits < prevMaxCircuits) {
300
+ // if we downsize expansions, remove circuits
301
+ for (let i = _circuits + 1; i <= prevMaxCircuits; i++) {
302
+ sys.circuits.removeItemById(i);
303
+ state.circuits.removeItemById(i);
304
+ }
305
+ }
306
+ else if (_circuits > prevMaxCircuits) {
307
+ this._configQueue.queueChanges();
308
+ }
309
+ sys.equipment.maxCircuits = _circuits;
310
+ return sys.equipment;
311
+ } catch (err) {
312
+ logger.error(`Error setting expansion panels: ${err.message}`);
313
+ }
314
+ }
315
+ public initBodyDefaults() {
316
+ // Initialize the bodies. We will need these very soon.
317
+ for (let i = 1; i <= sys.equipment.maxBodies; i++) {
318
+ // Add in the bodies for the configuration. These need to be set.
319
+ let cbody = sys.bodies.getItemById(i, true);
320
+ let tbody = state.temps.bodies.getItemById(i, true);
321
+ cbody.isActive = true;
322
+ // If the body doesn't represent a spa then we set the type.
323
+ tbody.type = cbody.type = i - 1; // This will set the first body to pool/Lo-Temp and the second body to spa/Hi-Temp.
324
+ if (typeof cbody.name === 'undefined') {
325
+ let bt = sys.board.valueMaps.bodyTypes.transform(cbody.type);
326
+ tbody.name = cbody.name = bt.desc;
327
+ }
328
+ }
329
+ sys.bodies.removeItemById(3);
330
+ sys.bodies.removeItemById(4);
331
+ state.temps.bodies.removeItemById(3);
332
+ state.temps.bodies.removeItemById(4);
333
+ for (let i = 0; i < sys.bodies.length; i++) {
334
+ let b = sys.bodies.getItemByIndex(i);
335
+ b.master = 0;
336
+ }
337
+ sys.board.heaters.initTempSensors();
338
+ sys.general.options.clockMode = sys.general.options.clockMode || 12;
339
+ sys.general.options.clockSource = sys.general.options.clockSource || 'manual';
340
+ }
341
+ }
342
+ class ITTouchConfigQueue extends TouchConfigQueue {
343
+ public queueChanges() {
344
+ this.reset();
345
+ logger.info(`Requesting ${sys.controllerType} configuration`);
346
+ this.queueItems(GetTouchConfigCategories.dateTime, [0]);
347
+ this.queueItems(GetTouchConfigCategories.heatTemperature, [0]);
348
+ this.queueItems(GetTouchConfigCategories.solarHeatPump, [0]);
349
+ this.queueRange(GetTouchConfigCategories.customNames, 0, sys.equipment.maxCustomNames - 1);
350
+ this.queueRange(GetTouchConfigCategories.circuits, 1, sys.equipment.maxCircuits); // circuits
351
+ this.queueRange(GetTouchConfigCategories.circuits, 41, 41 + sys.equipment.maxFeatures); // features
352
+ this.queueRange(GetTouchConfigCategories.schedules, 1, sys.equipment.maxSchedules);
353
+ this.queueItems(GetTouchConfigCategories.delays, [0]);
354
+ this.queueItems(GetTouchConfigCategories.settings, [0]);
355
+ this.queueItems(GetTouchConfigCategories.intellifloSpaSideRemotes, [0]);
356
+ this.queueItems(GetTouchConfigCategories.is4is10, [0]);
357
+ this.queueItems(GetTouchConfigCategories.quickTouchRemote, [0]);
358
+ this.queueItems(GetTouchConfigCategories.valves, [0]);
359
+ this.queueItems(GetTouchConfigCategories.lightGroupPositions);
360
+ this.queueItems(GetTouchConfigCategories.highSpeedCircuits, [0]);
361
+ this.queueRange(GetTouchConfigCategories.pumpConfig, 1, sys.equipment.maxPumps);
362
+ this.queueRange(GetTouchConfigCategories.circuitGroups, 0, sys.equipment.maxFeatures - 1);
363
+ this.queueItems(GetTouchConfigCategories.intellichlor, [0]);
364
+ if (this.remainingItems > 0) {
365
+ var self = this;
366
+ setTimeout(() => { self.processNext(); }, 50);
367
+ } else state.status = 1;
368
+ state.emitControllerChange();
369
+ }
370
+ }
371
+ class ITTouchCircuitCommands extends TouchCircuitCommands {
372
+ public async setCircuitGroupStateAsync(id: number, val: boolean): Promise<ICircuitGroupState> {
373
+ // intellitouch supports groups/macros with id's 41-50 with a macro flag
374
+ let grp = sys.circuitGroups.getItemById(id, false, { isActive: false });
375
+ return new Promise<ICircuitGroupState>(async (resolve, reject) => {
376
+ try {
377
+ await sys.board.circuits.setCircuitStateAsync(id, val);
378
+ resolve(state.circuitGroups.getInterfaceById(id));
379
+ }
380
+ catch (err) { reject(err); }
381
+ });
382
+ }
383
383
  }