nodejs-poolcontroller 7.7.0 → 8.0.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.
- package/.eslintrc.json +26 -35
- package/Changelog +22 -0
- package/README.md +7 -3
- package/anslq25/MessagesMock.ts +218 -0
- package/anslq25/boards/MockBoardFactory.ts +50 -0
- package/anslq25/boards/MockEasyTouchBoard.ts +696 -0
- package/anslq25/boards/MockSystemBoard.ts +217 -0
- package/anslq25/chemistry/MockChlorinator.ts +75 -0
- package/anslq25/pumps/MockPump.ts +84 -0
- package/app.ts +10 -14
- package/config/Config.ts +13 -9
- package/config/VersionCheck.ts +6 -2
- package/controller/Constants.ts +58 -25
- package/controller/Equipment.ts +224 -41
- package/controller/Errors.ts +2 -1
- package/controller/Lockouts.ts +34 -2
- package/controller/State.ts +491 -48
- package/controller/boards/AquaLinkBoard.ts +6 -3
- package/controller/boards/BoardFactory.ts +5 -1
- package/controller/boards/EasyTouchBoard.ts +1971 -1751
- package/controller/boards/IntelliCenterBoard.ts +1311 -1688
- package/controller/boards/IntelliComBoard.ts +7 -1
- package/controller/boards/IntelliTouchBoard.ts +153 -42
- package/controller/boards/NixieBoard.ts +209 -66
- package/controller/boards/SunTouchBoard.ts +393 -0
- package/controller/boards/SystemBoard.ts +1862 -1543
- package/controller/comms/Comms.ts +539 -138
- package/controller/comms/ScreenLogic.ts +1663 -0
- package/controller/comms/messages/Messages.ts +242 -60
- package/controller/comms/messages/config/ChlorinatorMessage.ts +4 -3
- package/controller/comms/messages/config/CircuitGroupMessage.ts +5 -2
- package/controller/comms/messages/config/CircuitMessage.ts +81 -13
- package/controller/comms/messages/config/ConfigMessage.ts +3 -1
- package/controller/comms/messages/config/CoverMessage.ts +2 -1
- package/controller/comms/messages/config/CustomNameMessage.ts +2 -1
- package/controller/comms/messages/config/EquipmentMessage.ts +5 -1
- package/controller/comms/messages/config/ExternalMessage.ts +33 -3
- package/controller/comms/messages/config/FeatureMessage.ts +2 -1
- package/controller/comms/messages/config/GeneralMessage.ts +2 -1
- package/controller/comms/messages/config/HeaterMessage.ts +3 -1
- package/controller/comms/messages/config/IntellichemMessage.ts +2 -1
- package/controller/comms/messages/config/OptionsMessage.ts +12 -6
- package/controller/comms/messages/config/PumpMessage.ts +9 -12
- package/controller/comms/messages/config/RemoteMessage.ts +80 -13
- package/controller/comms/messages/config/ScheduleMessage.ts +43 -3
- package/controller/comms/messages/config/SecurityMessage.ts +2 -1
- package/controller/comms/messages/config/ValveMessage.ts +43 -26
- package/controller/comms/messages/status/ChlorinatorStateMessage.ts +8 -7
- package/controller/comms/messages/status/EquipmentStateMessage.ts +93 -20
- package/controller/comms/messages/status/HeaterStateMessage.ts +24 -5
- package/controller/comms/messages/status/IntelliChemStateMessage.ts +7 -4
- package/controller/comms/messages/status/IntelliValveStateMessage.ts +2 -1
- package/controller/comms/messages/status/PumpStateMessage.ts +72 -4
- package/controller/comms/messages/status/VersionMessage.ts +2 -1
- package/controller/nixie/Nixie.ts +15 -4
- package/controller/nixie/NixieEquipment.ts +1 -0
- package/controller/nixie/chemistry/ChemController.ts +300 -129
- package/controller/nixie/chemistry/ChemDoser.ts +806 -0
- package/controller/nixie/chemistry/Chlorinator.ts +133 -129
- package/controller/nixie/circuits/Circuit.ts +171 -30
- package/controller/nixie/heaters/Heater.ts +337 -173
- package/controller/nixie/pumps/Pump.ts +264 -236
- package/controller/nixie/schedules/Schedule.ts +9 -3
- package/defaultConfig.json +45 -5
- package/logger/Logger.ts +38 -9
- package/package.json +13 -9
- package/web/Server.ts +235 -122
- package/web/bindings/aqualinkD.json +114 -59
- package/web/bindings/homeassistant.json +437 -0
- package/web/bindings/influxDB.json +15 -0
- package/web/bindings/mqtt.json +28 -9
- package/web/bindings/mqttAlt.json +15 -0
- package/web/interfaces/baseInterface.ts +58 -7
- package/web/interfaces/httpInterface.ts +5 -2
- package/web/interfaces/influxInterface.ts +9 -2
- package/web/interfaces/mqttInterface.ts +234 -74
- package/web/interfaces/ruleInterface.ts +87 -0
- package/web/services/config/Config.ts +140 -33
- package/web/services/config/ConfigSocket.ts +2 -1
- package/web/services/state/State.ts +144 -3
- package/web/services/state/StateSocket.ts +65 -14
- package/web/services/utilities/Utilities.ts +189 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* nodejs-poolController. An application to control pool equipment.
|
|
2
|
-
Copyright (C) 2016, 2017, 2018, 2019, 2020
|
|
2
|
+
Copyright (C) 2016, 2017, 2018, 2019, 2020, 2021, 2022.
|
|
3
|
+
Russell Goldin, tagyoureit. russ.goldin@gmail.com
|
|
3
4
|
|
|
4
5
|
This program is free software: you can redistribute it and/or modify
|
|
5
6
|
it under the terms of the GNU Affero General Public License as
|
|
@@ -128,18 +129,18 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
128
129
|
// with the i8P and i10P than I do with the others as this follows the pattern for the known personality cards. i10D and the order of the
|
|
129
130
|
// MUX and A/D modules don't seem to fit the pattern. If we ever see an i10D then this may be bit 3&4 set to 1. The theory here is that
|
|
130
131
|
// the first 5 bits indicate up to 16 potential personality cards with 0 being i5P.
|
|
131
|
-
[0, { name: 'i5P', part: '523125Z', desc: 'i5P Personality Card', bodies: 1, valves: 2, circuits: 5, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }],
|
|
132
|
+
[0, { name: 'i5P', part: '523125Z', desc: 'i5P Personality Card', bodies: 1, valves: 2, circuits: 5, single: true, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }],
|
|
132
133
|
[1, { name: 'i5PS', part: '521936Z', desc: 'i5PS Personality Card', bodies: 2, valves: 4, circuits: 6, shared: true, dual: false, chlorinators: 1, chemControllers: 1 }],
|
|
133
|
-
[2, { name: 'i8P', part: '521977Z', desc: 'i8P Personality Card', bodies: 1, valves: 2, circuits: 8, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }], // This is a guess
|
|
134
|
+
[2, { name: 'i8P', part: '521977Z', desc: 'i8P Personality Card', bodies: 1, valves: 2, circuits: 8, single: true, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }], // This is a guess
|
|
134
135
|
[3, { name: 'i8PS', part: '521968Z', desc: 'i8PS Personality Card', bodies: 2, valves: 4, circuits: 9, shared: true, dual: false, chlorinators: 1, chemControllers: 1 }],
|
|
135
|
-
[4, { name: 'i10P', part: '521993Z', desc: 'i10P Personality Card', bodies: 1, valves: 2, circuits: 10, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }], // This is a guess
|
|
136
|
+
[4, { name: 'i10P', part: '521993Z', desc: 'i10P Personality Card', bodies: 1, valves: 2, circuits: 10, single: true, shared: false, dual: false, chlorinators: 1, chemControllers: 1 }], // This is a guess
|
|
136
137
|
[5, { name: 'i10PS', part: '521873Z', desc: 'i10PS Personality Card', bodies: 2, valves: 4, circuits: 11, shared: true, dual: false, chlorinators: 1, chemControllers: 1 }],
|
|
137
138
|
[6, { name: 'i10x', part: '522997Z', desc: 'i10x Expansion Module', circuits: 10 }],
|
|
138
139
|
[7, { name: 'i10D', part: '523029Z', desc: 'i10D Personality Card', bodies: 2, valves: 2, circuits: 11, shared: false, dual: true, chlorinators: 1, chemControllers: 2 }], // We have witnessed this in the wild
|
|
139
140
|
[8, { name: 'Valve Exp', part: '522440', desc: 'Valve Expansion Module', valves: 6 }],
|
|
140
141
|
[9, { name: 'A/D Module', part: '522039', desc: 'A/D Cover Module', covers: 2 }], // Finally have a user with one of these
|
|
141
142
|
[10, { name: 'iChlor Mux', part: '522719', desc: 'iChlor MUX Card', chlorinators: 3 }], // This is a guess
|
|
142
|
-
[255, {name: 'i5x', part: '522033', desc: 'i5x Expansion Module', circuits: 5}] // This does not actually map to a known value at this point but we do know it will be > 6.
|
|
143
|
+
[255, { name: 'i5x', part: '522033', desc: 'i5x Expansion Module', circuits: 5 }] // This does not actually map to a known value at this point but we do know it will be > 6.
|
|
143
144
|
]);
|
|
144
145
|
|
|
145
146
|
this.valueMaps.virtualCircuits = new byteValueMap([
|
|
@@ -154,16 +155,17 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
154
155
|
[248, { name: 'solarHeat', desc: 'Solar Heat' }],
|
|
155
156
|
[251, { name: 'heater', desc: 'Heater' }],
|
|
156
157
|
[252, { name: 'solar', desc: 'Solar' }],
|
|
157
|
-
[255, { name: 'poolHeatEnable', desc: 'Pool Heat Enable' }]
|
|
158
|
+
[255, { name: 'poolHeatEnable', desc: 'Pool Heat Enable' }],
|
|
159
|
+
[258, { name: 'anyHeater', desc: 'Any Heater' }]
|
|
158
160
|
]);
|
|
159
161
|
this.valueMaps.msgBroadcastActions.merge([
|
|
160
162
|
[1, { name: 'ack', desc: 'Command Ack' }],
|
|
161
163
|
[30, { name: 'config', desc: 'Configuration' }],
|
|
162
|
-
[164, {name: 'getconfig', desc: 'Get Configuration'}],
|
|
164
|
+
[164, { name: 'getconfig', desc: 'Get Configuration' }],
|
|
163
165
|
[168, { name: 'setdata', desc: 'Set Data' }],
|
|
164
166
|
[204, { name: 'stateext', desc: 'State Extension' }],
|
|
165
167
|
[222, { name: 'getdata', desc: 'Get Data' }],
|
|
166
|
-
[228, {name: 'getversions', desc: 'Get Versions'}]
|
|
168
|
+
[228, { name: 'getversions', desc: 'Get Versions' }]
|
|
167
169
|
]);
|
|
168
170
|
this.valueMaps.clockSources.merge([
|
|
169
171
|
[1, { name: 'manual', desc: 'Manual' }],
|
|
@@ -175,7 +177,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
175
177
|
[2, { name: 'sunset', desc: 'Sunset' }]
|
|
176
178
|
]);
|
|
177
179
|
this.valueMaps.lightThemes = new byteValueMap([
|
|
178
|
-
[0, { name: 'white', desc: 'White', sequence: 11, types:['intellibrite', 'magicstream'] }],
|
|
180
|
+
[0, { name: 'white', desc: 'White', sequence: 11, types: ['intellibrite', 'magicstream'] }],
|
|
179
181
|
[1, { name: 'green', desc: 'Green', sequence: 9, types: ['intellibrite', 'magicstream'] }],
|
|
180
182
|
[2, { name: 'blue', desc: 'Blue', sequence: 8, types: ['intellibrite', 'magicstream'] }],
|
|
181
183
|
[3, { name: 'magenta', desc: 'Magenta', sequence: 12, types: ['intellibrite', 'magicstream'] }],
|
|
@@ -244,8 +246,9 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
244
246
|
[1, { name: 'heater', desc: 'Heater' }],
|
|
245
247
|
[2, { name: 'solar', desc: 'Solar' }],
|
|
246
248
|
[3, { name: 'cooling', desc: 'Cooling' }],
|
|
247
|
-
[6, { name: 'mtheat', desc: 'Heater' }],
|
|
248
249
|
[4, { name: 'hpheat', desc: 'Heating' }],
|
|
250
|
+
[5, { name: 'hybheat', desc: 'Heating' }],
|
|
251
|
+
[6, { name: 'mtheat', desc: 'Heater' }],
|
|
249
252
|
[8, { name: 'hpcool', desc: 'Cooling' }]
|
|
250
253
|
]);
|
|
251
254
|
this.valueMaps.scheduleTypes = new byteValueMap([
|
|
@@ -281,7 +284,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
281
284
|
this.modulesAcquired = false;
|
|
282
285
|
}
|
|
283
286
|
public checkConfiguration() {
|
|
284
|
-
if (!conn.
|
|
287
|
+
if (!conn.mock) {
|
|
285
288
|
(sys.board as IntelliCenterBoard).needsConfigChanges = true;
|
|
286
289
|
// Send out a message to the outdoor panel that we need info about
|
|
287
290
|
// our current configuration.
|
|
@@ -316,7 +319,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
316
319
|
sys.configVersion.valves = ver.valves;
|
|
317
320
|
}
|
|
318
321
|
}
|
|
319
|
-
public async stopAsync() { this._configQueue.close(); return super.stopAsync();}
|
|
322
|
+
public async stopAsync() { this._configQueue.close(); return super.stopAsync(); }
|
|
320
323
|
public initExpansionModules(ocp0A: number, ocp0B: number, xcp1A: number, xcp1B: number, xcp2A: number, xcp2B: number, xcp3A: number, xcp3B: number) {
|
|
321
324
|
state.equipment.controllerType = 'intellicenter';
|
|
322
325
|
let inv = { bodies: 0, circuits: 0, valves: 0, shared: false, dual: false, covers: 0, chlorinators: 0, chemControllers: 0 };
|
|
@@ -345,6 +348,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
345
348
|
sys.equipment.maxChemControllers = inv.chemControllers;
|
|
346
349
|
sys.equipment.shared = inv.shared;
|
|
347
350
|
sys.equipment.dual = inv.dual;
|
|
351
|
+
sys.equipment.single = (inv.shared === false && inv.dual === false);
|
|
348
352
|
sys.equipment.maxPumps = 16;
|
|
349
353
|
sys.equipment.maxLightGroups = 40;
|
|
350
354
|
sys.equipment.maxCircuitGroups = 16;
|
|
@@ -359,6 +363,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
359
363
|
state.equipment.maxPumps = sys.equipment.maxPumps;
|
|
360
364
|
state.equipment.maxSchedules = sys.equipment.maxSchedules;
|
|
361
365
|
state.equipment.maxValves = sys.equipment.maxValves;
|
|
366
|
+
state.equipment.single = sys.equipment.single;
|
|
362
367
|
state.equipment.shared = sys.equipment.shared;
|
|
363
368
|
state.equipment.dual = sys.equipment.dual;
|
|
364
369
|
//let pb = sys.equipment.modules.getItemById(0);
|
|
@@ -383,7 +388,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
383
388
|
sys.general.options.master = 0;
|
|
384
389
|
for (let i = 0; i < sys.circuits.length; i++) {
|
|
385
390
|
let c = sys.circuits.getItemByIndex(i);
|
|
386
|
-
if(c.id <= 40) c.master = 0;
|
|
391
|
+
if (c.id <= 40) c.master = 0;
|
|
387
392
|
}
|
|
388
393
|
for (let i = 0; i < sys.valves.length; i++) {
|
|
389
394
|
let v = sys.valves.getItemByIndex(i);
|
|
@@ -399,7 +404,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
399
404
|
public processMasterModules(modules: ExpansionModuleCollection, ocpA: number, ocpB: number, inv?) {
|
|
400
405
|
// Map the expansion panels to their specific types through the valuemaps. Sadly this means that
|
|
401
406
|
// we need to determine if anything needs to be removed or added before actually doing it.
|
|
402
|
-
if (typeof inv === 'undefined') inv = { bodies: 0, circuits: 0, valves: 0, shared: false, covers: 0, chlorinators: 0, chemControllers: 0};
|
|
407
|
+
if (typeof inv === 'undefined') inv = { bodies: 0, circuits: 0, valves: 0, shared: false, covers: 0, chlorinators: 0, chemControllers: 0 };
|
|
403
408
|
let slot0 = ocpA & 0x0F;
|
|
404
409
|
let slot1 = (ocpA & 0xF0) >> 4;
|
|
405
410
|
let slot2 = (ocpB & 0xF0) >> 4;
|
|
@@ -429,6 +434,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
429
434
|
if (typeof mt.covers !== 'undefined') inv.covers += mt.covers;
|
|
430
435
|
if (typeof mt.chlorinators !== 'undefined') inv.chlorinators += mt.chlorinators;
|
|
431
436
|
if (typeof mt.chemControllers !== 'undefined') inv.chemControllers += mt.chemControllers;
|
|
437
|
+
if (typeof mt.single !== 'undefined') inv.single = mt.single;
|
|
432
438
|
if (typeof mt.shared !== 'undefined') inv.shared = mt.shared;
|
|
433
439
|
if (typeof mt.dual !== 'undefined') inv.dual = mt.dual;
|
|
434
440
|
if (slot1 === 0) modules.removeItemById(1);
|
|
@@ -506,7 +512,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
506
512
|
let slot2 = (ocpB & 0xF0) >> 4;
|
|
507
513
|
let slot3 = ocpB & 0xF;
|
|
508
514
|
// Slot 0 always has to have a personality card but on an expansion module it cannot be 0. At this point we only know that an i10x = 6 for slot 0.
|
|
509
|
-
if (slot0 <= 2) {
|
|
515
|
+
if (slot0 <= 2) {
|
|
510
516
|
modules.removeItemById(0);
|
|
511
517
|
panel.isActive = false;
|
|
512
518
|
}
|
|
@@ -529,6 +535,7 @@ export class IntelliCenterBoard extends SystemBoard {
|
|
|
529
535
|
if (typeof mt.valves !== 'undefined') inv.valves += mt.valves;
|
|
530
536
|
if (typeof mt.covers !== 'undefined') inv.covers += mt.covers;
|
|
531
537
|
if (typeof mt.chlorinators !== 'undefined') inv.chlorinators += mt.chlorinators;
|
|
538
|
+
if (typeof mt.single !== 'undefined') inv.single = mt.single;
|
|
532
539
|
if (typeof mt.shared !== 'undefined') inv.shared = mt.shared;
|
|
533
540
|
if (typeof mt.dual !== 'undefined') inv.dual = mt.dual;
|
|
534
541
|
if (typeof mt.chemControllers !== 'undefined') inv.chemControllers += mt.chemControllers;
|
|
@@ -667,10 +674,23 @@ class IntelliCenterConfigQueue extends ConfigQueue {
|
|
|
667
674
|
// as both boards are processing at the same time and sending an outbound ack.
|
|
668
675
|
let out = Outbound.create({
|
|
669
676
|
action: 222, payload: [this.curr.category, itm], retries: 5,
|
|
670
|
-
response: Response.create({
|
|
677
|
+
response: Response.create({
|
|
678
|
+
dest: -1, action: 30, payload: [this.curr.category, itm]
|
|
679
|
+
// , callback: () => { self.processNext(out); }
|
|
680
|
+
})
|
|
671
681
|
});
|
|
672
682
|
logger.verbose(`Requesting config for: ${ConfigCategories[this.curr.category]} - Item: ${itm}`);
|
|
673
683
|
setTimeout(() => { conn.queueSendMessage(out) }, 50);
|
|
684
|
+
out.sendAsync()
|
|
685
|
+
.then(() => {
|
|
686
|
+
//logger.debug(`msg ${out.toShortPacket()} sent successfully`);
|
|
687
|
+
})
|
|
688
|
+
.catch((err) => {
|
|
689
|
+
logger.error(`Error sending configuration request message on port ${out.portId}: ${err.message};`);
|
|
690
|
+
})
|
|
691
|
+
.finally(() => {
|
|
692
|
+
setTimeout(() => { self.processNext(out); }, 10);
|
|
693
|
+
})
|
|
674
694
|
} else {
|
|
675
695
|
// Now that we are done check the configuration a final time. If we have anything outstanding
|
|
676
696
|
// it will get picked up.
|
|
@@ -687,7 +707,7 @@ class IntelliCenterConfigQueue extends ConfigQueue {
|
|
|
687
707
|
}
|
|
688
708
|
public queueChanges(ver: ConfigVersion) {
|
|
689
709
|
let curr: ConfigVersion = sys.configVersion;
|
|
690
|
-
|
|
710
|
+
|
|
691
711
|
if (this._processing) {
|
|
692
712
|
if (curr.hasChanges(ver)) this._newRequest = true;
|
|
693
713
|
if (sys.configVersion.lastUpdated.getTime() > new Date().getTime() - 90000)
|
|
@@ -719,7 +739,7 @@ class IntelliCenterConfigQueue extends ConfigQueue {
|
|
|
719
739
|
req.oncomplete = function (req: IntelliCenterConfigRequest) {
|
|
720
740
|
let maxId = sys.features.getMaxId(true, 0) - sys.board.equipmentIds.features.start + 1;
|
|
721
741
|
// We only need to get the feature names required. This will fill these after we know we have them.
|
|
722
|
-
if(maxId > 0) req.fillRange(6, Math.min(Math.ceil(maxId / 2) + 6, 21));
|
|
742
|
+
if (maxId > 0) req.fillRange(6, Math.min(Math.ceil(maxId / 2) + 6, 21));
|
|
723
743
|
};
|
|
724
744
|
this.push(req);
|
|
725
745
|
}
|
|
@@ -744,7 +764,7 @@ class IntelliCenterConfigQueue extends ConfigQueue {
|
|
|
744
764
|
this.push(req);
|
|
745
765
|
}
|
|
746
766
|
if (this.compareVersions(curr.circuitGroups, ver.circuitGroups)) {
|
|
747
|
-
let req = new IntelliCenterConfigRequest(ConfigCategories.circuitGroups, ver.circuitGroups, [32,33], function (req: IntelliCenterConfigRequest) {
|
|
767
|
+
let req = new IntelliCenterConfigRequest(ConfigCategories.circuitGroups, ver.circuitGroups, [32, 33], function (req: IntelliCenterConfigRequest) {
|
|
748
768
|
// Only get group attributes for the ones we have defined. The total number of message for all potential groups exceeds 50.
|
|
749
769
|
if (sys.circuitGroups.length + sys.lightGroups.length > 0) {
|
|
750
770
|
let maxId = (Math.max(sys.circuitGroups.getMaxId(true, 0), sys.lightGroups.getMaxId(true, 0)) - sys.board.equipmentIds.circuitGroups.start) + 1;
|
|
@@ -824,7 +844,9 @@ class IntelliCenterConfigQueue extends ConfigQueue {
|
|
|
824
844
|
setTimeout(() => { sys.board.checkConfiguration(); }, 250);
|
|
825
845
|
}
|
|
826
846
|
state.status = 1;
|
|
847
|
+
state.equipment.single = sys.equipment.single;
|
|
827
848
|
state.equipment.shared = sys.equipment.shared;
|
|
849
|
+
state.equipment.dual = sys.equipment.dual;
|
|
828
850
|
state.equipment.model = sys.equipment.model;
|
|
829
851
|
state.equipment.controllerType = sys.controllerType;
|
|
830
852
|
state.equipment.maxBodies = sys.equipment.maxBodies;
|
|
@@ -852,60 +874,56 @@ class IntelliCenterSystemCommands extends SystemCommands {
|
|
|
852
874
|
});
|
|
853
875
|
}
|
|
854
876
|
public async setGeneralAsync(obj?: any): Promise<General> {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
console.log(`Caught reject from setOptionsAsync`);
|
|
874
|
-
throw err;
|
|
875
|
-
});
|
|
876
|
-
if (typeof obj.location !== 'undefined') await sys.board.system.setLocationAsync(obj.location);
|
|
877
|
-
if (typeof obj.owner !== 'undefined') await sys.board.system.setOwnerAsync(obj.owner);
|
|
878
|
-
resolve(sys.general);
|
|
879
|
-
}
|
|
880
|
-
catch (err) {
|
|
881
|
-
console.log(`Rejected setGeneralAsync`);
|
|
882
|
-
reject(err);
|
|
877
|
+
try {
|
|
878
|
+
if (typeof obj.alias === 'string' && obj.alias !== sys.general.alias) {
|
|
879
|
+
let out = Outbound.create({
|
|
880
|
+
action: 168,
|
|
881
|
+
payload: [12, 0, 0],
|
|
882
|
+
retries: 3
|
|
883
|
+
}).appendPayloadString(obj.alias, 16);
|
|
884
|
+
await out.sendAsync();
|
|
885
|
+
sys.general.alias = obj.alias;
|
|
886
|
+
}
|
|
887
|
+
if (typeof obj.options !== 'undefined') {
|
|
888
|
+
try {
|
|
889
|
+
await sys.board.system.setOptionsAsync(obj.options)
|
|
890
|
+
}
|
|
891
|
+
catch (err) {
|
|
892
|
+
logger.error(`Caught reject from setOptionsAsync`);
|
|
893
|
+
return Promise.reject(err);
|
|
894
|
+
}
|
|
883
895
|
}
|
|
884
|
-
|
|
896
|
+
if (typeof obj.location !== 'undefined') await sys.board.system.setLocationAsync(obj.location);
|
|
897
|
+
if (typeof obj.owner !== 'undefined') await sys.board.system.setOwnerAsync(obj.owner);
|
|
898
|
+
return sys.general;
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
console.log(`Rejected setGeneralAsync: ${err.message}`);
|
|
902
|
+
return Promise.reject(err);
|
|
903
|
+
}
|
|
885
904
|
}
|
|
886
905
|
public async setTempSensorsAsync(obj?: any): Promise<TempSensorCollection> {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
});
|
|
906
|
+
try {
|
|
907
|
+
let sensors = {
|
|
908
|
+
waterTempAdj1: obj.waterTempAdj1,
|
|
909
|
+
waterTempAdj2: obj.waterTempAdj2,
|
|
910
|
+
waterTempAdj3: obj.waterTempAdj3,
|
|
911
|
+
waterTempAdj4: obj.waterTempAdj4,
|
|
912
|
+
airTempAdj: obj.airTempAdj,
|
|
913
|
+
solarTempAdj1: obj.solarTempAdj1,
|
|
914
|
+
solarTempAdj2: obj.solarTempAdj2,
|
|
915
|
+
solarTempAdj3: obj.solarTempAdj3,
|
|
916
|
+
solarTempAdj4: obj.solarTempAdj4,
|
|
917
|
+
}
|
|
918
|
+
await this.setOptionsAsync(sensors); // Map this to the options message as these are one in the same.
|
|
919
|
+
return sys.equipment.tempSensors;
|
|
920
|
+
}
|
|
921
|
+
catch (err) { return Promise.reject(err); }
|
|
922
|
+
|
|
905
923
|
}
|
|
906
|
-
public async setOptionsAsync(obj?: any)
|
|
924
|
+
public async setOptionsAsync(obj?: any): Promise<Options> {
|
|
907
925
|
let fnToByte = function (num) { return num < 0 ? Math.abs(num) | 0x80 : Math.abs(num) || 0; }
|
|
908
|
-
|
|
926
|
+
|
|
909
927
|
let payload = [0, 0, 0,
|
|
910
928
|
fnToByte(sys.equipment.tempSensors.getCalibration('water2')),
|
|
911
929
|
fnToByte(sys.equipment.tempSensors.getCalibration('water1')),
|
|
@@ -934,7 +952,7 @@ class IntelliCenterSystemCommands extends SystemCommands {
|
|
|
934
952
|
15,
|
|
935
953
|
sys.general.options.pumpDelay ? 1 : 0, // 30
|
|
936
954
|
sys.general.options.cooldownDelay ? 1 : 0,
|
|
937
|
-
0, 0, 100, 0, 0, 0, 0,
|
|
955
|
+
0, 0, 100, 0, 0, 0, 0,
|
|
938
956
|
sys.general.options.manualPriority ? 1 : 0, // 39
|
|
939
957
|
sys.general.options.manualHeat ? 1 : 0];
|
|
940
958
|
let arr = [];
|
|
@@ -942,273 +960,193 @@ class IntelliCenterSystemCommands extends SystemCommands {
|
|
|
942
960
|
if (typeof obj.waterTempAdj1 != 'undefined' && obj.waterTempAdj1 !== sys.equipment.tempSensors.getCalibration('water1')) {
|
|
943
961
|
payload[2] = 1;
|
|
944
962
|
payload[4] = fnToByte(parseInt(obj.waterTempAdj1, 10)) || 0;
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
951
|
-
onComplete: (err, msg) => {
|
|
952
|
-
if (err) reject(err);
|
|
953
|
-
else { sys.equipment.tempSensors.setCalibration('water1', parseInt(obj.waterTempAdj1, 10)); resolve(); }
|
|
954
|
-
}
|
|
955
|
-
});
|
|
956
|
-
conn.queueSendMessage(out);
|
|
963
|
+
let out = Outbound.create({
|
|
964
|
+
action: 168,
|
|
965
|
+
retries: 5,
|
|
966
|
+
payload: payload,
|
|
967
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
957
968
|
});
|
|
969
|
+
await out.sendAsync();
|
|
970
|
+
sys.equipment.tempSensors.setCalibration('water1', parseInt(obj.waterTempAdj1, 10));
|
|
958
971
|
}
|
|
959
972
|
if (typeof obj.waterTempAdj2 != 'undefined' && obj.waterTempAdj2 !== sys.equipment.tempSensors.getCalibration('water2')) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
968
|
-
onComplete: (err, msg) => {
|
|
969
|
-
if (err) reject(err);
|
|
970
|
-
else { sys.equipment.tempSensors.setCalibration('water2', parseInt(obj.waterTempAdj2, 10)); resolve(); }
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
conn.queueSendMessage(out);
|
|
973
|
+
payload[2] = 4;
|
|
974
|
+
payload[7] = fnToByte(parseInt(obj.waterTempAdj2, 10)) || 0;
|
|
975
|
+
let out = Outbound.create({
|
|
976
|
+
action: 168,
|
|
977
|
+
retries: 5,
|
|
978
|
+
payload: payload,
|
|
979
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
974
980
|
});
|
|
981
|
+
await out.sendAsync();
|
|
982
|
+
sys.equipment.tempSensors.setCalibration('water2', parseInt(obj.waterTempAdj2, 10));
|
|
975
983
|
}
|
|
976
984
|
if (typeof obj.waterTempAdj3 != 'undefined' && obj.waterTempAdj3 !== sys.equipment.tempSensors.getCalibration('water3')) {
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
985
|
-
onComplete: (err, msg) => {
|
|
986
|
-
if (err) reject(err);
|
|
987
|
-
else { sys.equipment.tempSensors.setCalibration('water3', parseInt(obj.waterTempAdj3, 10)); resolve(); }
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
conn.queueSendMessage(out);
|
|
985
|
+
payload[2] = 6;
|
|
986
|
+
payload[9] = fnToByte(parseInt(obj.waterTempAdj3, 10)) || 0;
|
|
987
|
+
let out = Outbound.create({
|
|
988
|
+
action: 168,
|
|
989
|
+
retries: 5,
|
|
990
|
+
payload: payload,
|
|
991
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
991
992
|
});
|
|
993
|
+
await out.sendAsync();
|
|
994
|
+
sys.equipment.tempSensors.setCalibration('water3', parseInt(obj.waterTempAdj3, 10));
|
|
992
995
|
}
|
|
993
996
|
if (typeof obj.waterTempAdj4 != 'undefined' && obj.waterTempAdj4 !== sys.equipment.tempSensors.getCalibration('water4')) {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
payload: payload,
|
|
1002
|
-
onComplete: (err, msg) => {
|
|
1003
|
-
if (err) reject(err);
|
|
1004
|
-
else { sys.equipment.tempSensors.setCalibration('water4', parseInt(obj.waterTempAdj3, 10)); resolve(); }
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
conn.queueSendMessage(out);
|
|
997
|
+
payload[2] = 8;
|
|
998
|
+
payload[11] = fnToByte(parseInt(obj.waterTempAdj4, 10)) || 0;
|
|
999
|
+
let out = Outbound.create({
|
|
1000
|
+
action: 168,
|
|
1001
|
+
retries: 5,
|
|
1002
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1003
|
+
payload: payload
|
|
1008
1004
|
});
|
|
1005
|
+
await out.sendAsync();
|
|
1006
|
+
sys.equipment.tempSensors.setCalibration('water4', parseInt(obj.waterTempAdj3, 10));
|
|
1009
1007
|
}
|
|
1010
1008
|
|
|
1011
1009
|
if (typeof obj.solarTempAdj1 != 'undefined' && obj.solarTempAdj1 !== sys.equipment.tempSensors.getCalibration('solar1')) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1020
|
-
onComplete: (err, msg) => {
|
|
1021
|
-
if (err) reject(err);
|
|
1022
|
-
else { sys.equipment.tempSensors.setCalibration('solar1', parseInt(obj.solarTempAdj1, 10)); resolve(); }
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
conn.queueSendMessage(out);
|
|
1010
|
+
payload[2] = 2;
|
|
1011
|
+
payload[5] = fnToByte(parseInt(obj.solarTempAdj1, 10)) || 0;
|
|
1012
|
+
let out = Outbound.create({
|
|
1013
|
+
action: 168,
|
|
1014
|
+
retries: 5,
|
|
1015
|
+
payload: payload,
|
|
1016
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1026
1017
|
});
|
|
1018
|
+
await out.sendAsync();
|
|
1019
|
+
sys.equipment.tempSensors.setCalibration('solar1', parseInt(obj.solarTempAdj1, 10));
|
|
1027
1020
|
}
|
|
1028
1021
|
if (typeof obj.solarTempAdj2 != 'undefined' && obj.solarTempAdj2 !== sys.equipment.tempSensors.getCalibration('solar2')) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1037
|
-
onComplete: (err, msg) => {
|
|
1038
|
-
if (err) reject(err);
|
|
1039
|
-
else { sys.equipment.tempSensors.setCalibration('solar2', parseInt(obj.solarTempAdj2, 10)); resolve(); }
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
conn.queueSendMessage(out);
|
|
1022
|
+
payload[2] = 5;
|
|
1023
|
+
payload[8] = fnToByte(parseInt(obj.solarTempAdj2, 10)) || 0;
|
|
1024
|
+
let out = Outbound.create({
|
|
1025
|
+
action: 168,
|
|
1026
|
+
retries: 5,
|
|
1027
|
+
payload: payload,
|
|
1028
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1043
1029
|
});
|
|
1030
|
+
await out.sendAsync();
|
|
1031
|
+
sys.equipment.tempSensors.setCalibration('solar2', parseInt(obj.solarTempAdj2, 10));
|
|
1044
1032
|
}
|
|
1045
1033
|
if (typeof obj.solarTempAdj3 != 'undefined' && obj.solarTempAdj3 !== sys.equipment.tempSensors.getCalibration('solar3')) {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1054
|
-
onComplete: (err, msg) => {
|
|
1055
|
-
if (err) reject(err);
|
|
1056
|
-
else { sys.equipment.tempSensors.setCalibration('solar3', parseInt(obj.solarTempAdj3, 10)); resolve(); }
|
|
1057
|
-
}
|
|
1058
|
-
});
|
|
1059
|
-
conn.queueSendMessage(out);
|
|
1034
|
+
payload[2] = 7;
|
|
1035
|
+
payload[10] = fnToByte(parseInt(obj.solarTempAdj3, 10)) || 0;
|
|
1036
|
+
let out = Outbound.create({
|
|
1037
|
+
action: 168,
|
|
1038
|
+
retries: 5,
|
|
1039
|
+
payload: payload,
|
|
1040
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1060
1041
|
});
|
|
1042
|
+
await out.sendAsync();
|
|
1043
|
+
sys.equipment.tempSensors.setCalibration('solar3', parseInt(obj.solarTempAdj3, 10));
|
|
1061
1044
|
}
|
|
1062
1045
|
if (typeof obj.solarTempAdj4 != 'undefined' && obj.solarTempAdj4 !== sys.equipment.tempSensors.getCalibration('solar4')) {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1071
|
-
onComplete: (err, msg) => {
|
|
1072
|
-
if (err) reject(err);
|
|
1073
|
-
else { sys.equipment.tempSensors.setCalibration('solar3', parseInt(obj.solarTempAdj3, 10)); resolve(); }
|
|
1074
|
-
}
|
|
1075
|
-
});
|
|
1076
|
-
conn.queueSendMessage(out);
|
|
1046
|
+
payload[2] = 8;
|
|
1047
|
+
payload[12] = fnToByte(parseInt(obj.solarTempAdj4, 10)) || 0;
|
|
1048
|
+
let out = Outbound.create({
|
|
1049
|
+
action: 168,
|
|
1050
|
+
retries: 5,
|
|
1051
|
+
payload: payload,
|
|
1052
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1077
1053
|
});
|
|
1054
|
+
await out.sendAsync();
|
|
1055
|
+
sys.equipment.tempSensors.setCalibration('solar3', parseInt(obj.solarTempAdj3, 10));
|
|
1078
1056
|
}
|
|
1079
1057
|
if (typeof obj.airTempAdj != 'undefined' && obj.airTempAdj !== sys.equipment.tempSensors.getCalibration('air')) {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
payload: payload,
|
|
1088
|
-
onComplete: (err, msg) => {
|
|
1089
|
-
if (err) reject(err);
|
|
1090
|
-
else { sys.equipment.tempSensors.setCalibration('air', parseInt(obj.airTempAdj, 10)); resolve(); }
|
|
1091
|
-
}
|
|
1092
|
-
});
|
|
1093
|
-
conn.queueSendMessage(out);
|
|
1058
|
+
payload[2] = 3;
|
|
1059
|
+
payload[6] = fnToByte(parseInt(obj.airTempAdj, 10)) || 0;
|
|
1060
|
+
let out = Outbound.create({
|
|
1061
|
+
action: 168,
|
|
1062
|
+
retries: 5,
|
|
1063
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1064
|
+
payload: payload
|
|
1094
1065
|
});
|
|
1066
|
+
await out.sendAsync();
|
|
1067
|
+
sys.equipment.tempSensors.setCalibration('air', parseInt(obj.airTempAdj, 10));
|
|
1095
1068
|
}
|
|
1096
1069
|
if ((typeof obj.clockMode !== 'undefined' && obj.clockMode !== sys.general.options.clockMode) ||
|
|
1097
1070
|
(typeof obj.adjustDST !== 'undefined' && obj.adjustDST !== sys.general.options.adjustDST)) {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
payload: payload,
|
|
1111
|
-
onComplete: (err, msg) => {
|
|
1112
|
-
if (err) reject(err);
|
|
1113
|
-
else {
|
|
1114
|
-
if (typeof obj.clockMode !== 'undefined') sys.general.options.clockMode = obj.clockMode === 24 ? 24 : 12;
|
|
1115
|
-
if (typeof obj.adjustDST !== 'undefined' || sys.general.options.clockSource !== 'server') sys.general.options.adjustDST = obj.adjustDST ? true : false;
|
|
1116
|
-
resolve();
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
conn.queueSendMessage(out);
|
|
1071
|
+
let byte = 0x30; // These bits are always set.
|
|
1072
|
+
if (typeof obj.clockMode === 'undefined') byte |= sys.general.options.clockMode === 24 ? 0x40 : 0x00;
|
|
1073
|
+
else byte |= obj.clockMode === 24 ? 0x40 : 0x00;
|
|
1074
|
+
if (typeof obj.adjustDST === 'undefined') byte |= sys.general.options.adjustDST ? 0x80 : 0x00;
|
|
1075
|
+
else byte |= obj.adjustDST ? 0x80 : 0x00;
|
|
1076
|
+
payload[2] = 11;
|
|
1077
|
+
payload[14] = byte;
|
|
1078
|
+
let out = Outbound.create({
|
|
1079
|
+
action: 168,
|
|
1080
|
+
retries: 5,
|
|
1081
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1082
|
+
payload: payload
|
|
1121
1083
|
});
|
|
1084
|
+
await out.sendAsync();
|
|
1085
|
+
if (typeof obj.clockMode !== 'undefined') sys.general.options.clockMode = obj.clockMode === 24 ? 24 : 12;
|
|
1086
|
+
if (typeof obj.adjustDST !== 'undefined' || sys.general.options.clockSource !== 'server') sys.general.options.adjustDST = obj.adjustDST ? true : false;
|
|
1122
1087
|
}
|
|
1088
|
+
|
|
1123
1089
|
if (typeof obj.clockSource != 'undefined' && obj.clockSource !== sys.general.options.clockSource) {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1132
|
-
onComplete: (err, msg) => {
|
|
1133
|
-
if (err) reject(err);
|
|
1134
|
-
else {
|
|
1135
|
-
if (obj.clockSource === 'internet' || obj.clockSource === 'server' || obj.clockSource === 'manual')
|
|
1136
|
-
sys.general.options.clockSource = obj.clockSource;
|
|
1137
|
-
sys.board.system.setTZ();
|
|
1138
|
-
resolve();
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
conn.queueSendMessage(out);
|
|
1090
|
+
payload[2] = 11;
|
|
1091
|
+
payload[17] = obj.clockSource === 'internet' ? 0x01 : 0x00;
|
|
1092
|
+
let out = Outbound.create({
|
|
1093
|
+
action: 168,
|
|
1094
|
+
retries: 5,
|
|
1095
|
+
payload: payload,
|
|
1096
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1143
1097
|
});
|
|
1098
|
+
await out.sendAsync();
|
|
1099
|
+
if (obj.clockSource === 'internet' || obj.clockSource === 'server' || obj.clockSource === 'manual')
|
|
1100
|
+
sys.general.options.clockSource = obj.clockSource;
|
|
1101
|
+
sys.board.system.setTZ();
|
|
1144
1102
|
}
|
|
1145
1103
|
if (typeof obj.pumpDelay !== 'undefined' && obj.pumpDelay !== sys.general.options.pumpDelay) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
payload: payload,
|
|
1154
|
-
onComplete: (err, msg) => {
|
|
1155
|
-
if (err) reject(err);
|
|
1156
|
-
else { sys.general.options.pumpDelay = obj.pumpDelay ? true : false; resolve(); }
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
conn.queueSendMessage(out);
|
|
1104
|
+
payload[2] = 27;
|
|
1105
|
+
payload[30] = obj.pumpDelay ? 0x01 : 0x00;
|
|
1106
|
+
let out = Outbound.create({
|
|
1107
|
+
action: 168,
|
|
1108
|
+
retries: 5,
|
|
1109
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1110
|
+
payload: payload
|
|
1160
1111
|
});
|
|
1112
|
+
await out.sendAsync();
|
|
1113
|
+
sys.general.options.pumpDelay = obj.pumpDelay ? true : false;
|
|
1161
1114
|
}
|
|
1162
1115
|
if (typeof obj.cooldownDelay !== 'undefined' && obj.cooldownDelay !== sys.general.options.cooldownDelay) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1171
|
-
onComplete: (err, msg) => {
|
|
1172
|
-
if (err) reject(err);
|
|
1173
|
-
else { sys.general.options.cooldownDelay = obj.cooldownDelay ? true : false; resolve(); }
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
conn.queueSendMessage(out);
|
|
1116
|
+
payload[2] = 28;
|
|
1117
|
+
payload[31] = obj.cooldownDelay ? 0x01 : 0x00;
|
|
1118
|
+
let out = Outbound.create({
|
|
1119
|
+
action: 168,
|
|
1120
|
+
retries: 5,
|
|
1121
|
+
payload: payload,
|
|
1122
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1177
1123
|
});
|
|
1124
|
+
await out.sendAsync();
|
|
1125
|
+
sys.general.options.cooldownDelay = obj.cooldownDelay ? true : false;
|
|
1178
1126
|
}
|
|
1179
1127
|
if (typeof obj.manualPriority !== 'undefined' && obj.manualPriority !== sys.general.options.manualPriority) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1188
|
-
onComplete: (err, msg) => {
|
|
1189
|
-
if (err) reject(err);
|
|
1190
|
-
else { sys.general.options.manualPriority = obj.manualPriority ? true : false; resolve(); }
|
|
1191
|
-
}
|
|
1192
|
-
});
|
|
1193
|
-
conn.queueSendMessage(out);
|
|
1128
|
+
payload[2] = 36;
|
|
1129
|
+
payload[39] = obj.manualPriority ? 0x01 : 0x00;
|
|
1130
|
+
let out = Outbound.create({
|
|
1131
|
+
action: 168,
|
|
1132
|
+
retries: 5,
|
|
1133
|
+
payload: payload,
|
|
1134
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1194
1135
|
});
|
|
1136
|
+
await out.sendAsync();
|
|
1137
|
+
sys.general.options.manualPriority = obj.manualPriority ? true : false;
|
|
1195
1138
|
}
|
|
1196
1139
|
if (typeof obj.manualHeat !== 'undefined' && obj.manualHeat !== sys.general.options.manualHeat) {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1205
|
-
onComplete: (err, msg) => {
|
|
1206
|
-
if (err) reject(err);
|
|
1207
|
-
else { sys.general.options.manualHeat = obj.manualHeat ? true : false; resolve(); }
|
|
1208
|
-
}
|
|
1209
|
-
});
|
|
1210
|
-
conn.queueSendMessage(out);
|
|
1140
|
+
payload[2] = 37;
|
|
1141
|
+
payload[40] = obj.manualHeat ? 0x01 : 0x00;
|
|
1142
|
+
let out = Outbound.create({
|
|
1143
|
+
action: 168,
|
|
1144
|
+
retries: 5,
|
|
1145
|
+
payload: payload,
|
|
1146
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1211
1147
|
});
|
|
1148
|
+
await out.sendAsync();
|
|
1149
|
+
sys.general.options.manualHeat = obj.manualHeat ? true : false;
|
|
1212
1150
|
}
|
|
1213
1151
|
return Promise.resolve(sys.general.options);
|
|
1214
1152
|
}
|
|
@@ -1218,136 +1156,96 @@ class IntelliCenterSystemCommands extends SystemCommands {
|
|
|
1218
1156
|
try {
|
|
1219
1157
|
let arr = [];
|
|
1220
1158
|
if (typeof obj.address === 'string' && obj.address !== sys.general.location.address) {
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1227
|
-
onComplete: (err, msg) => {
|
|
1228
|
-
if (err) reject(err);
|
|
1229
|
-
else { sys.general.location.address = obj.address; resolve(); }
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
out.appendPayloadString(obj.address, 32);
|
|
1233
|
-
conn.queueSendMessage(out);
|
|
1159
|
+
let out = Outbound.create({
|
|
1160
|
+
action: 168,
|
|
1161
|
+
retries: 5,
|
|
1162
|
+
payload: [12, 0, 1],
|
|
1163
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1234
1164
|
});
|
|
1165
|
+
out.appendPayloadString(obj.address, 32);
|
|
1166
|
+
await out.sendAsync();
|
|
1167
|
+
sys.general.location.address = obj.address;
|
|
1235
1168
|
}
|
|
1236
1169
|
if (typeof obj.country === 'string' && obj.country !== sys.general.location.country) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1243
|
-
onComplete: (err, msg) => {
|
|
1244
|
-
if (err) reject(err);
|
|
1245
|
-
else { sys.general.location.country = obj.country; resolve(); }
|
|
1246
|
-
}
|
|
1247
|
-
});
|
|
1248
|
-
out.appendPayloadString(obj.country, 32);
|
|
1249
|
-
conn.queueSendMessage(out);
|
|
1170
|
+
let out = Outbound.create({
|
|
1171
|
+
action: 168,
|
|
1172
|
+
retries: 5,
|
|
1173
|
+
payload: [12, 0, 8],
|
|
1174
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1250
1175
|
});
|
|
1176
|
+
out.appendPayloadString(obj.country, 32);
|
|
1177
|
+
await out.sendAsync();
|
|
1178
|
+
sys.general.location.country = obj.country;
|
|
1251
1179
|
}
|
|
1252
1180
|
if (typeof obj.city === 'string' && obj.city !== sys.general.location.city) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1259
|
-
onComplete: (err, msg) => {
|
|
1260
|
-
if (err) reject(err);
|
|
1261
|
-
else { sys.general.location.city = obj.city; resolve(); }
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
out.appendPayloadString(obj.city, 32);
|
|
1265
|
-
conn.queueSendMessage(out);
|
|
1181
|
+
let out = Outbound.create({
|
|
1182
|
+
action: 168,
|
|
1183
|
+
retries: 5,
|
|
1184
|
+
payload: [12, 0, 9],
|
|
1185
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1266
1186
|
});
|
|
1187
|
+
out.appendPayloadString(obj.city, 32);
|
|
1188
|
+
await out.sendAsync();
|
|
1189
|
+
sys.general.location.city = obj.city;
|
|
1267
1190
|
}
|
|
1268
1191
|
if (typeof obj.state === 'string' && obj.state !== sys.general.location.state) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1275
|
-
onComplete: (err, msg) => {
|
|
1276
|
-
if (err) reject(err);
|
|
1277
|
-
else { sys.general.location.state = obj.state; resolve(); }
|
|
1278
|
-
}
|
|
1279
|
-
});
|
|
1280
|
-
out.appendPayloadString(obj.state, 32);
|
|
1281
|
-
conn.queueSendMessage(out);
|
|
1192
|
+
let out = Outbound.create({
|
|
1193
|
+
action: 168,
|
|
1194
|
+
retries: 5,
|
|
1195
|
+
payload: [12, 0, 10],
|
|
1196
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1282
1197
|
});
|
|
1198
|
+
out.appendPayloadString(obj.state, 32);
|
|
1199
|
+
await out.sendAsync();
|
|
1200
|
+
sys.general.location.state = obj.state;
|
|
1283
1201
|
}
|
|
1284
1202
|
if (typeof obj.zip === 'string' && obj.zip !== sys.general.location.zip) {
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1291
|
-
onComplete: (err, msg) => {
|
|
1292
|
-
if (err) reject(err);
|
|
1293
|
-
else { sys.general.location.zip = obj.zip; resolve(); }
|
|
1294
|
-
}
|
|
1295
|
-
});
|
|
1296
|
-
out.appendPayloadString(obj.zip, 6);
|
|
1297
|
-
conn.queueSendMessage(out);
|
|
1203
|
+
let out = Outbound.create({
|
|
1204
|
+
action: 168,
|
|
1205
|
+
retries: 5,
|
|
1206
|
+
payload: [12, 0, 7],
|
|
1207
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1298
1208
|
});
|
|
1209
|
+
out.appendPayloadString(obj.zip, 6);
|
|
1210
|
+
await out.sendAsync();
|
|
1211
|
+
sys.general.location.zip = obj.zip;
|
|
1299
1212
|
}
|
|
1300
1213
|
|
|
1301
1214
|
if (typeof obj.latitude === 'number' && obj.latitude !== sys.general.location.latitude) {
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1311
|
-
onComplete: (err, msg) => {
|
|
1312
|
-
if (err) reject(err);
|
|
1313
|
-
else { sys.general.location.longitude = lat / 100; resolve(); }
|
|
1314
|
-
}
|
|
1315
|
-
});
|
|
1316
|
-
conn.queueSendMessage(out);
|
|
1215
|
+
let lat = Math.round(Math.abs(obj.latitude) * 100);
|
|
1216
|
+
let out = Outbound.create({
|
|
1217
|
+
action: 168,
|
|
1218
|
+
retries: 5,
|
|
1219
|
+
payload: [12, 0, 11,
|
|
1220
|
+
Math.floor(lat / 256),
|
|
1221
|
+
lat - Math.floor(lat / 256)],
|
|
1222
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1317
1223
|
});
|
|
1224
|
+
await out.sendAsync();
|
|
1225
|
+
sys.general.location.longitude = lat / 100;
|
|
1318
1226
|
}
|
|
1319
1227
|
if (typeof obj.longitude === 'number' && obj.longitude !== sys.general.location.longitude) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1329
|
-
onComplete: (err, msg) => {
|
|
1330
|
-
if (err) reject(err);
|
|
1331
|
-
else { sys.general.location.longitude = -(lon / 100); resolve(); }
|
|
1332
|
-
}
|
|
1333
|
-
});
|
|
1334
|
-
conn.queueSendMessage(out);
|
|
1228
|
+
let lon = Math.round(Math.abs(obj.longitude) * 100);
|
|
1229
|
+
let out = Outbound.create({
|
|
1230
|
+
action: 168,
|
|
1231
|
+
retries: 5,
|
|
1232
|
+
payload: [12, 0, 12,
|
|
1233
|
+
Math.floor(lon / 256),
|
|
1234
|
+
lon - Math.floor(lon / 256)],
|
|
1235
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1335
1236
|
});
|
|
1237
|
+
await out.sendAsync();
|
|
1238
|
+
sys.general.location.longitude = -(lon / 100);
|
|
1336
1239
|
}
|
|
1337
1240
|
if (typeof obj.timeZone === 'number' && obj.timeZone !== sys.general.location.timeZone) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1344
|
-
onComplete: (err, msg) => {
|
|
1345
|
-
if (err) reject(err);
|
|
1346
|
-
else { sys.general.location.timeZone = parseInt(obj.timeZone, 10); resolve(); }
|
|
1347
|
-
}
|
|
1348
|
-
});
|
|
1349
|
-
conn.queueSendMessage(out);
|
|
1241
|
+
let out = Outbound.create({
|
|
1242
|
+
action: 168,
|
|
1243
|
+
retries: 5,
|
|
1244
|
+
payload: [12, 0, 13, parseInt(obj.timeZone, 10)],
|
|
1245
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1350
1246
|
});
|
|
1247
|
+
await out.sendAsync();
|
|
1248
|
+
sys.general.location.timeZone = parseInt(obj.timeZone, 10);
|
|
1351
1249
|
}
|
|
1352
1250
|
return Promise.resolve(sys.general.location);
|
|
1353
1251
|
}
|
|
@@ -1357,84 +1255,59 @@ class IntelliCenterSystemCommands extends SystemCommands {
|
|
|
1357
1255
|
let arr = [];
|
|
1358
1256
|
try {
|
|
1359
1257
|
if (typeof obj.name === 'string' && obj.name !== sys.general.owner.name) {
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1366
|
-
onComplete: (err, msg) => {
|
|
1367
|
-
if (err) reject(err);
|
|
1368
|
-
else { sys.general.owner.name = obj.name; resolve(); }
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
out.appendPayloadString(obj.name, 16);
|
|
1372
|
-
conn.queueSendMessage(out);
|
|
1258
|
+
let out = Outbound.create({
|
|
1259
|
+
action: 168,
|
|
1260
|
+
retries: 5,
|
|
1261
|
+
payload: [12, 0, 2],
|
|
1262
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1373
1263
|
});
|
|
1264
|
+
out.appendPayloadString(obj.name, 16);
|
|
1265
|
+
await out.sendAsync();
|
|
1266
|
+
sys.general.owner.name = obj.name;
|
|
1374
1267
|
}
|
|
1375
1268
|
if (typeof obj.email === 'string' && obj.email !== sys.general.owner.email) {
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1382
|
-
onComplete: (err, msg) => {
|
|
1383
|
-
if (err) reject(err);
|
|
1384
|
-
else { sys.general.owner.email = obj.email; resolve(); }
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
out.appendPayloadString(obj.email, 32);
|
|
1388
|
-
conn.queueSendMessage(out);
|
|
1269
|
+
let out = Outbound.create({
|
|
1270
|
+
action: 168,
|
|
1271
|
+
retries: 5,
|
|
1272
|
+
payload: [12, 0, 3],
|
|
1273
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1389
1274
|
});
|
|
1275
|
+
out.appendPayloadString(obj.email, 32);
|
|
1276
|
+
await out.sendAsync();
|
|
1277
|
+
sys.general.owner.email = obj.email;
|
|
1390
1278
|
}
|
|
1391
1279
|
if (typeof obj.email2 === 'string' && obj.email2 !== sys.general.owner.email2) {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
payload: [12, 0, 4],
|
|
1398
|
-
onComplete: (err, msg) => {
|
|
1399
|
-
if (err) reject(err);
|
|
1400
|
-
else { sys.general.owner.email2 = obj.email2; resolve(); }
|
|
1401
|
-
}
|
|
1402
|
-
});
|
|
1403
|
-
out.appendPayloadString(obj.email2, 32);
|
|
1404
|
-
conn.queueSendMessage(out);
|
|
1280
|
+
let out = Outbound.create({
|
|
1281
|
+
action: 168,
|
|
1282
|
+
retries: 5,
|
|
1283
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1284
|
+
payload: [12, 0, 4]
|
|
1405
1285
|
});
|
|
1286
|
+
out.appendPayloadString(obj.email2, 32);
|
|
1287
|
+
await out.sendAsync();
|
|
1288
|
+
sys.general.owner.email2 = obj.email2;
|
|
1406
1289
|
}
|
|
1407
1290
|
if (typeof obj.phone2 === 'string' && obj.phone2 !== sys.general.owner.phone2) {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1414
|
-
onComplete: (err, msg) => {
|
|
1415
|
-
if (err) reject(err);
|
|
1416
|
-
else { sys.general.owner.phone2 = obj.phone2; resolve(); }
|
|
1417
|
-
}
|
|
1418
|
-
});
|
|
1419
|
-
out.appendPayloadString(obj.phone2, 16);
|
|
1420
|
-
conn.queueSendMessage(out);
|
|
1291
|
+
let out = Outbound.create({
|
|
1292
|
+
action: 168,
|
|
1293
|
+
retries: 5,
|
|
1294
|
+
payload: [12, 0, 6],
|
|
1295
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1421
1296
|
});
|
|
1297
|
+
out.appendPayloadString(obj.phone2, 16);
|
|
1298
|
+
await out.sendAsync();
|
|
1299
|
+
sys.general.owner.phone2 = obj.phone2;
|
|
1422
1300
|
}
|
|
1423
1301
|
if (typeof obj.phone === 'string' && obj.phone !== sys.general.owner.phone) {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
1430
|
-
onComplete: (err, msg) => {
|
|
1431
|
-
if (err) reject(err);
|
|
1432
|
-
else { sys.general.owner.phone = obj.phone; resolve(); }
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
out.appendPayloadString(obj.phone, 16);
|
|
1436
|
-
conn.queueSendMessage(out);
|
|
1302
|
+
let out = Outbound.create({
|
|
1303
|
+
action: 168,
|
|
1304
|
+
retries: 5,
|
|
1305
|
+
payload: [12, 0, 5],
|
|
1306
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
1437
1307
|
});
|
|
1308
|
+
out.appendPayloadString(obj.phone, 16);
|
|
1309
|
+
await out.sendAsync();
|
|
1310
|
+
sys.general.owner.phone = obj.phone;
|
|
1438
1311
|
}
|
|
1439
1312
|
return Promise.resolve(sys.general.owner);
|
|
1440
1313
|
}
|
|
@@ -1457,12 +1330,13 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1457
1330
|
} catch (err) { logger.error(`checkEggTimerExpiration: Error synchronizing circuit relays ${err.message}`); }
|
|
1458
1331
|
}
|
|
1459
1332
|
public async setCircuitAsync(data: any): Promise<ICircuit> {
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1333
|
+
try {
|
|
1334
|
+
|
|
1335
|
+
let id = parseInt(data.id, 10);
|
|
1336
|
+
let circuit = sys.circuits.getItemById(id, false);
|
|
1337
|
+
// Alright check to see if we are adding a nixie circuit.
|
|
1338
|
+
if (id === -1 || circuit.master !== 0)
|
|
1339
|
+
return await super.setCircuitAsync(data);
|
|
1466
1340
|
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError('Circuit Id has not been defined', data.id, 'Circuit'));
|
|
1467
1341
|
if (!sys.board.equipmentIds.circuits.isInRange(id)) return Promise.reject(new InvalidEquipmentIdError(`Circuit Id ${id}: is out of range.`, id, 'Circuit'));
|
|
1468
1342
|
let eggTimer = Math.min(typeof data.eggTimer !== 'undefined' ? parseInt(data.eggTimer, 10) : circuit.eggTimer, 1440);
|
|
@@ -1482,37 +1356,36 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1482
1356
|
(typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : circuit.freeze) ? 1 : 0,
|
|
1483
1357
|
(typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : circuit.showInFeatures) ? 1 : 0,
|
|
1484
1358
|
theme,
|
|
1485
|
-
eggHrs, eggMins, data.dontStop ? 1 : 0]
|
|
1486
|
-
onComplete: (err, msg) => {
|
|
1487
|
-
if (err) reject(err);
|
|
1488
|
-
else {
|
|
1489
|
-
let scircuit = state.circuits.getItemById(circuit.id, true);
|
|
1490
|
-
circuit.eggTimer = eggTimer;
|
|
1491
|
-
circuit.dontStop = data.dontStop;
|
|
1492
|
-
circuit.freeze = (typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : circuit.freeze);
|
|
1493
|
-
circuit.showInFeatures = (typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : circuit.showInFeatures);
|
|
1494
|
-
if (type === 9) scircuit.level = circuit.level = theme;
|
|
1495
|
-
else {
|
|
1496
|
-
let t = sys.board.valueMaps.circuitFunctions.transform(type);
|
|
1497
|
-
if (t.isLight == true) scircuit.lightingTheme = circuit.lightingTheme = theme;
|
|
1498
|
-
else {
|
|
1499
|
-
scircuit.lightingTheme = undefined;
|
|
1500
|
-
circuit.lightingTheme = 0;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
scircuit.name = circuit.name = typeof data.name !== 'undefined' ? data.name.toString().substring(0, 16) : circuit.name;
|
|
1504
|
-
scircuit.type = circuit.type = type;
|
|
1505
|
-
scircuit.isActive = circuit.isActive = true;
|
|
1506
|
-
circuit.master = 0;
|
|
1507
|
-
resolve(circuit);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1359
|
+
eggHrs, eggMins, data.dontStop ? 1 : 0]
|
|
1510
1360
|
});
|
|
1511
1361
|
out.appendPayloadString(typeof data.name !== 'undefined' ? data.name.toString() : circuit.name, 16);
|
|
1512
1362
|
out.retries = 5;
|
|
1513
1363
|
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
1514
|
-
|
|
1515
|
-
|
|
1364
|
+
await out.sendAsync();
|
|
1365
|
+
let scircuit = state.circuits.getItemById(circuit.id, true);
|
|
1366
|
+
circuit.eggTimer = eggTimer;
|
|
1367
|
+
circuit.dontStop = data.dontStop;
|
|
1368
|
+
circuit.freeze = (typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : circuit.freeze);
|
|
1369
|
+
scircuit.showInFeatures = circuit.showInFeatures = (typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : circuit.showInFeatures);
|
|
1370
|
+
if (type === 9) scircuit.level = circuit.level = theme;
|
|
1371
|
+
else {
|
|
1372
|
+
let t = sys.board.valueMaps.circuitFunctions.transform(type);
|
|
1373
|
+
if (t.isLight == true) scircuit.lightingTheme = circuit.lightingTheme = theme;
|
|
1374
|
+
else {
|
|
1375
|
+
scircuit.lightingTheme = undefined;
|
|
1376
|
+
circuit.lightingTheme = 0;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
scircuit.name = circuit.name = typeof data.name !== 'undefined' ? data.name.toString().substring(0, 16) : circuit.name;
|
|
1380
|
+
scircuit.type = circuit.type = type;
|
|
1381
|
+
scircuit.isActive = circuit.isActive = true;
|
|
1382
|
+
circuit.master = 0;
|
|
1383
|
+
return circuit;
|
|
1384
|
+
}
|
|
1385
|
+
catch (err) {
|
|
1386
|
+
return Promise.reject(err);
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1516
1389
|
}
|
|
1517
1390
|
public async setCircuitGroupAsync(obj: any): Promise<CircuitGroup> {
|
|
1518
1391
|
// When we save circuit groups we are going to reorder the whole mess. IntelliCenter does some goofy
|
|
@@ -1547,110 +1420,89 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1547
1420
|
if (typeof id === 'undefined') return Promise.reject(new InvalidEquipmentIdError(`Max circuit group ids exceeded: ${id}`, id, 'circuitGroup'));
|
|
1548
1421
|
if (isNaN(id) || !sys.board.equipmentIds.circuitGroups.isInRange(id)) return Promise.reject(new InvalidEquipmentIdError(`Invalid circuit group id: ${obj.id}`, obj.id, 'circuitGroup'));
|
|
1549
1422
|
try {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
obj.dontStop = (eggTimer === 1440);
|
|
1423
|
+
let eggTimer = (typeof obj.eggTimer !== 'undefined') ? parseInt(obj.eggTimer, 10) : group.eggTimer;
|
|
1424
|
+
if (isNaN(eggTimer)) eggTimer = 720;
|
|
1425
|
+
eggTimer = Math.max(Math.min(1440, eggTimer), 1);
|
|
1426
|
+
if (obj.dontStop === true) eggTimer = 1440;
|
|
1427
|
+
let eggHours = Math.floor(eggTimer / 60);
|
|
1428
|
+
let eggMins = eggTimer - (eggHours * 60);
|
|
1429
|
+
obj.dontStop = (eggTimer === 1440);
|
|
1558
1430
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
out.payload.push(c.circuit ? c.circuit - 1 : 255);
|
|
1591
|
-
}
|
|
1592
|
-
else {
|
|
1593
|
-
for (let i = 0; i < 16; i++)
|
|
1594
|
-
(i < obj.circuits.length) ? out.payload.push(obj.circuits[i].circuit - 1) : out.payload.push(255);
|
|
1431
|
+
let out = Outbound.create({
|
|
1432
|
+
action: 168,
|
|
1433
|
+
payload: [6, 0, id - sys.board.equipmentIds.circuitGroups.start, 2, 0, 0], // The last byte here should be don't stop but I believe this to be a current bug.
|
|
1434
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1435
|
+
retries: 5
|
|
1436
|
+
});
|
|
1437
|
+
// Add in all the info for the circuits.
|
|
1438
|
+
if (typeof obj.circuits === 'undefined')
|
|
1439
|
+
for (let i = 0; i < 16; i++) {
|
|
1440
|
+
let c = group.circuits.getItemByIndex(i, false);
|
|
1441
|
+
out.payload.push(c.circuit ? c.circuit - 1 : 255);
|
|
1442
|
+
}
|
|
1443
|
+
else {
|
|
1444
|
+
for (let i = 0; i < 16; i++)
|
|
1445
|
+
(i < obj.circuits.length) ? out.payload.push(obj.circuits[i].circuit - 1) : out.payload.push(255);
|
|
1446
|
+
}
|
|
1447
|
+
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1448
|
+
out.payload.push(eggHours);
|
|
1449
|
+
out.payload.push(eggMins);
|
|
1450
|
+
await out.sendAsync();
|
|
1451
|
+
group.eggTimer = eggTimer;
|
|
1452
|
+
group.dontStop = obj.dontStop;
|
|
1453
|
+
sgroup.type = group.type = 2;
|
|
1454
|
+
sgroup.isActive = group.isActive = true;
|
|
1455
|
+
if (typeof obj.showInFeatures !== 'undefined') group.showInFeatures = utils.makeBool(obj.showInFeatures);
|
|
1456
|
+
sgroup.showInFeatures = group.showInFeatures;
|
|
1457
|
+
if (typeof obj.circuits !== 'undefined') {
|
|
1458
|
+
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1459
|
+
let c = group.circuits.getItemByIndex(i, true);
|
|
1460
|
+
c.id = i + 1;
|
|
1461
|
+
c.circuit = obj.circuits[i].circuit;
|
|
1595
1462
|
}
|
|
1596
|
-
for (let i =
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1463
|
+
for (let i = obj.circuits.length; i < group.circuits.length; i++)
|
|
1464
|
+
group.circuits.removeItemByIndex(i);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
out = Outbound.create({
|
|
1468
|
+
action: 168,
|
|
1469
|
+
payload: [6, 1, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1470
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1471
|
+
retries: 3
|
|
1600
1472
|
});
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
if (typeof obj.name !== 'undefined') sgroup.name = group.name = obj.name.toString().substring(0, 16);
|
|
1611
|
-
resolve();
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1616
|
-
out.appendPayloadString(typeof obj.name !== 'undefined' ? obj.name : group.name, 16);
|
|
1617
|
-
conn.queueSendMessage(out);
|
|
1473
|
+
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1474
|
+
out.appendPayloadString(typeof obj.name !== 'undefined' ? obj.name : group.name, 16);
|
|
1475
|
+
await out.sendAsync();
|
|
1476
|
+
if (typeof obj.name !== 'undefined') sgroup.name = group.name = obj.name.toString().substring(0, 16);
|
|
1477
|
+
out = Outbound.create({
|
|
1478
|
+
action: 168,
|
|
1479
|
+
payload: [6, 2, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1480
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1481
|
+
retries: 3
|
|
1618
1482
|
});
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
onComplete: (err, msg) => {
|
|
1626
|
-
if (err) reject(err);
|
|
1627
|
-
else {
|
|
1628
|
-
if (typeof obj.circuits !== 'undefined') {
|
|
1629
|
-
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1630
|
-
let c = group.circuits.getItemByIndex(i);
|
|
1631
|
-
c.desiredState = obj.circuits[i].desiredState || 1;
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
resolve();
|
|
1635
|
-
}
|
|
1636
|
-
}
|
|
1637
|
-
});
|
|
1638
|
-
for (let i = 0; i < 16; i++) out.payload.push(0); // Push the 0s for the color
|
|
1639
|
-
// Add in the desired State.
|
|
1640
|
-
if (typeof obj.circuits === 'undefined')
|
|
1641
|
-
for (let i = 0; i < 16; i++) {
|
|
1642
|
-
let c = group.circuits.getItemByIndex(i, false);
|
|
1643
|
-
typeof c.desiredState !== 'undefined' ? out.payload.push(c.desiredState) : out.payload.push(255);
|
|
1644
|
-
}
|
|
1645
|
-
else {
|
|
1646
|
-
for (let i = 0; i < 16; i++)
|
|
1647
|
-
(i < obj.circuits.length) ? out.payload.push(obj.circuits[i].desiredState || 1) : out.payload.push(255);
|
|
1483
|
+
for (let i = 0; i < 16; i++) out.payload.push(0); // Push the 0s for the color
|
|
1484
|
+
// Add in the desired State.
|
|
1485
|
+
if (typeof obj.circuits === 'undefined')
|
|
1486
|
+
for (let i = 0; i < 16; i++) {
|
|
1487
|
+
let c = group.circuits.getItemByIndex(i, false);
|
|
1488
|
+
typeof c.desiredState !== 'undefined' ? out.payload.push(c.desiredState) : out.payload.push(255);
|
|
1648
1489
|
}
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1490
|
+
else {
|
|
1491
|
+
for (let i = 0; i < 16; i++)
|
|
1492
|
+
(i < obj.circuits.length) ? out.payload.push(obj.circuits[i].desiredState || 1) : out.payload.push(255);
|
|
1493
|
+
}
|
|
1494
|
+
await out.sendAsync();
|
|
1495
|
+
if (typeof obj.circuits !== 'undefined') {
|
|
1496
|
+
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1497
|
+
let c = group.circuits.getItemByIndex(i);
|
|
1498
|
+
c.desiredState = obj.circuits[i].desiredState || 1;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
return group;
|
|
1502
|
+
}
|
|
1503
|
+
catch (err) {
|
|
1504
|
+
return Promise.reject(err);
|
|
1652
1505
|
}
|
|
1653
|
-
catch (err) { return Promise.reject(err); }
|
|
1654
1506
|
}
|
|
1655
1507
|
public async deleteCircuitGroupAsync(obj: any): Promise<CircuitGroup> {
|
|
1656
1508
|
let group: CircuitGroup = null;
|
|
@@ -1658,62 +1510,41 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1658
1510
|
if (isNaN(id) || !sys.board.equipmentIds.circuitGroups.isInRange(id)) return Promise.reject(new EquipmentNotFoundError(`Invalid group id: ${obj.id}`, 'CircuitGroup'));
|
|
1659
1511
|
group = sys.circuitGroups.getItemById(id);
|
|
1660
1512
|
try {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
retries: 5,
|
|
1667
|
-
onComplete: (err, msg) => {
|
|
1668
|
-
if (err) reject(err);
|
|
1669
|
-
else {
|
|
1670
|
-
let gstate = state.circuitGroups.getItemById(id);
|
|
1671
|
-
gstate.isActive = false;
|
|
1672
|
-
gstate.emitEquipmentChange();
|
|
1673
|
-
sys.circuitGroups.removeItemById(id);
|
|
1674
|
-
state.circuitGroups.removeItemById(id);
|
|
1675
|
-
resolve();
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
});
|
|
1679
|
-
for (let i = 0; i < 16; i++) i < group.circuits.length ? out.payload.push(group.circuits.getItemByIndex(i).circuit - 1) : out.payload.push(255);
|
|
1680
|
-
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1681
|
-
out.payload.push(12);
|
|
1682
|
-
out.payload.push(0);
|
|
1683
|
-
conn.queueSendMessage(out);
|
|
1513
|
+
let out = Outbound.create({
|
|
1514
|
+
action: 168,
|
|
1515
|
+
payload: [6, 0, id - sys.board.equipmentIds.circuitGroups.start, 0, 0, 0],
|
|
1516
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1517
|
+
retries: 5
|
|
1684
1518
|
});
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1519
|
+
for (let i = 0; i < 16; i++) i < group.circuits.length ? out.payload.push(group.circuits.getItemByIndex(i).circuit - 1) : out.payload.push(255);
|
|
1520
|
+
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1521
|
+
out.payload.push(12);
|
|
1522
|
+
out.payload.push(0);
|
|
1523
|
+
await out.sendAsync();
|
|
1524
|
+
let gstate = state.circuitGroups.getItemById(id);
|
|
1525
|
+
gstate.isActive = false;
|
|
1526
|
+
gstate.emitEquipmentChange();
|
|
1527
|
+
sys.circuitGroups.removeItemById(id);
|
|
1528
|
+
state.circuitGroups.removeItemById(id);
|
|
1529
|
+
|
|
1530
|
+
out = Outbound.create({
|
|
1531
|
+
action: 168,
|
|
1532
|
+
payload: [6, 1, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1533
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1534
|
+
retries: 3
|
|
1701
1535
|
});
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
else { resolve(); }
|
|
1711
|
-
}
|
|
1712
|
-
});
|
|
1713
|
-
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1714
|
-
conn.queueSendMessage(out);
|
|
1536
|
+
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1537
|
+
out.appendPayloadString(group.name || '', 16);
|
|
1538
|
+
await out.sendAsync();
|
|
1539
|
+
out = Outbound.create({
|
|
1540
|
+
action: 168,
|
|
1541
|
+
payload: [6, 2, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1542
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1543
|
+
retries: 3
|
|
1715
1544
|
});
|
|
1716
|
-
|
|
1545
|
+
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1546
|
+
await out.sendAsync();
|
|
1547
|
+
return group;
|
|
1717
1548
|
}
|
|
1718
1549
|
catch (err) { return Promise.reject(err); }
|
|
1719
1550
|
}
|
|
@@ -1738,141 +1569,119 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1738
1569
|
if (typeof id === 'undefined') return Promise.reject(new Error(`Max light group ids exceeded`));
|
|
1739
1570
|
if (isNaN(id) || !sys.board.equipmentIds.circuitGroups.isInRange(id)) return Promise.reject(new Error(`Invalid light group id: ${obj.id}`));
|
|
1740
1571
|
try {
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
group.dontStop = obj.dontStop;
|
|
1763
|
-
if (typeof obj.circuits !== 'undefined') {
|
|
1764
|
-
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1765
|
-
let c = group.circuits.getItemByIndex(i, true, { id: i + 1 });
|
|
1766
|
-
c.circuit = obj.circuits[i].circuit;
|
|
1767
|
-
c.swimDelay = obj.circuits[i].swimDelay;
|
|
1768
|
-
if(typeof obj.circuits[i].color !== 'undefined') c.color = obj.circuits[i].color;
|
|
1769
|
-
}
|
|
1770
|
-
group.circuits.length = obj.circuits.length;
|
|
1771
|
-
}
|
|
1772
|
-
resolve();
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
});
|
|
1776
|
-
// Add in all the info for the circuits.
|
|
1777
|
-
if (typeof obj.circuits === 'undefined') {
|
|
1778
|
-
// Circuits
|
|
1779
|
-
for (let i = 0; i < 16; i++) {
|
|
1780
|
-
let c = group.circuits.getItemByIndex(i, false);
|
|
1781
|
-
out.payload.push(c.circuit ? c.circuit - 1 : 255);
|
|
1782
|
-
}
|
|
1783
|
-
// Swim Delay
|
|
1784
|
-
for (let i = 0; i < 16; i++) {
|
|
1785
|
-
let c = group.circuits.getItemByIndex(i, false);
|
|
1786
|
-
out.payload.push(c.circuit ? c.swimDelay : 255);
|
|
1787
|
-
}
|
|
1572
|
+
let eggTimer = (typeof obj.eggTimer !== 'undefined') ? parseInt(obj.eggTimer, 10) : group.eggTimer;
|
|
1573
|
+
if (isNaN(eggTimer)) eggTimer = 720;
|
|
1574
|
+
eggTimer = Math.max(Math.min(1440, eggTimer), 1);
|
|
1575
|
+
if (obj.dontStop === true) eggTimer = 1440;
|
|
1576
|
+
let eggHours = Math.floor(eggTimer / 60);
|
|
1577
|
+
let eggMins = eggTimer - (eggHours * 60);
|
|
1578
|
+
obj.dontStop = (eggTimer === 1440);
|
|
1579
|
+
sgroup = state.lightGroups.getItemById(id, true);
|
|
1580
|
+
let theme = typeof obj.lightingTheme === 'undefined' ? group.lightingTheme || 0 : obj.lightingTheme;
|
|
1581
|
+
let out = Outbound.create({
|
|
1582
|
+
action: 168,
|
|
1583
|
+
payload: [6, 0, id - sys.board.equipmentIds.circuitGroups.start, 1, (theme << 2) + 1, 0], // The last byte here should be don't stop but I believe this to be a current bug.
|
|
1584
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1585
|
+
retries: 5
|
|
1586
|
+
});
|
|
1587
|
+
// Add in all the info for the circuits.
|
|
1588
|
+
if (typeof obj.circuits === 'undefined') {
|
|
1589
|
+
// Circuits
|
|
1590
|
+
for (let i = 0; i < 16; i++) {
|
|
1591
|
+
let c = group.circuits.getItemByIndex(i, false);
|
|
1592
|
+
out.payload.push(c.circuit ? c.circuit - 1 : 255);
|
|
1788
1593
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1594
|
+
// Swim Delay
|
|
1595
|
+
for (let i = 0; i < 16; i++) {
|
|
1596
|
+
let c = group.circuits.getItemByIndex(i, false);
|
|
1597
|
+
out.payload.push(c.circuit ? c.swimDelay : 255);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
else {
|
|
1601
|
+
// Circuits
|
|
1602
|
+
for (let i = 0; i < 16; i++) {
|
|
1603
|
+
if (i < obj.circuits.length) {
|
|
1604
|
+
let c = parseInt(obj.circuits[i].circuit, 10);
|
|
1605
|
+
out.payload.push(!isNaN(c) ? c - 1 : 255);
|
|
1797
1606
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1607
|
+
else out.payload.push(255);
|
|
1608
|
+
}
|
|
1609
|
+
// Swim Delay
|
|
1610
|
+
for (let i = 0; i < 16; i++) {
|
|
1611
|
+
if (i < obj.circuits.length) {
|
|
1612
|
+
let delay = parseInt(obj.circuits[i].swimDelay, 10);
|
|
1613
|
+
out.payload.push(!isNaN(delay) ? delay : 10);
|
|
1805
1614
|
}
|
|
1615
|
+
else out.payload.push(0);
|
|
1806
1616
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1617
|
+
}
|
|
1618
|
+
out.payload.push(eggHours);
|
|
1619
|
+
out.payload.push(eggMins);
|
|
1620
|
+
await out.sendAsync();
|
|
1621
|
+
sgroup.type = group.type = 1;
|
|
1622
|
+
sgroup.lightingTheme = group.lightingTheme = theme;
|
|
1623
|
+
group.eggTimer = eggTimer;
|
|
1624
|
+
group.dontStop = obj.dontStop;
|
|
1625
|
+
if (typeof obj.circuits !== 'undefined') {
|
|
1626
|
+
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1627
|
+
let c = group.circuits.getItemByIndex(i, true, { id: i + 1 });
|
|
1628
|
+
c.circuit = obj.circuits[i].circuit;
|
|
1629
|
+
c.swimDelay = obj.circuits[i].swimDelay;
|
|
1630
|
+
if (typeof obj.circuits[i].color !== 'undefined') c.color = obj.circuits[i].color;
|
|
1631
|
+
}
|
|
1632
|
+
group.circuits.length = obj.circuits.length;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
out = Outbound.create({
|
|
1636
|
+
action: 168,
|
|
1637
|
+
payload: [6, 1, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1638
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1639
|
+
retries: 3
|
|
1810
1640
|
});
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
});
|
|
1825
|
-
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1826
|
-
out.payload[3] = 10;
|
|
1827
|
-
out.appendPayloadString(typeof obj.name !== 'undefined' ? obj.name : group.name, 16);
|
|
1828
|
-
conn.queueSendMessage(out);
|
|
1641
|
+
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1642
|
+
out.payload[3] = 10;
|
|
1643
|
+
out.appendPayloadString(typeof obj.name !== 'undefined' ? obj.name : group.name, 16);
|
|
1644
|
+
await out.sendAsync();
|
|
1645
|
+
if (typeof obj.name !== 'undefined') sgroup.name = group.name = obj.name.toString().substring(0, 16);
|
|
1646
|
+
|
|
1647
|
+
out = Outbound.create({
|
|
1648
|
+
action: 168,
|
|
1649
|
+
payload: [6, 2, id - sys.board.equipmentIds.circuitGroups.start],
|
|
1650
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1651
|
+
retries: 3
|
|
1829
1652
|
});
|
|
1830
|
-
|
|
1831
|
-
let
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
if (err) reject(err);
|
|
1838
|
-
else {
|
|
1839
|
-
if (typeof obj.circuits !== 'undefined') {
|
|
1840
|
-
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1841
|
-
let circ = group.circuits.getItemByIndex(i, true);
|
|
1842
|
-
let color = 0;
|
|
1843
|
-
if (i < obj.circuits.length) {
|
|
1844
|
-
color = parseInt(obj.circuits[i].color, 10);
|
|
1845
|
-
if (isNaN(color)) { color = circ.color || 0; }
|
|
1846
|
-
//console.log(`Setting Color: {0}`, color);
|
|
1847
|
-
}
|
|
1848
|
-
circ.color = color;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
resolve();
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
});
|
|
1855
|
-
if (typeof obj.circuits !== 'undefined') {
|
|
1856
|
-
for (let i = 0; i < 16; i++) {
|
|
1857
|
-
let color = 0;
|
|
1858
|
-
if (i < obj.circuits.length) {
|
|
1859
|
-
color = parseInt(obj.circuits[i].color, 10);
|
|
1860
|
-
if (isNaN(color)) {
|
|
1861
|
-
color = group.circuits.getItemByIndex(i, false).color;
|
|
1862
|
-
}
|
|
1653
|
+
if (typeof obj.circuits !== 'undefined') {
|
|
1654
|
+
for (let i = 0; i < 16; i++) {
|
|
1655
|
+
let color = 0;
|
|
1656
|
+
if (i < obj.circuits.length) {
|
|
1657
|
+
color = parseInt(obj.circuits[i].color, 10);
|
|
1658
|
+
if (isNaN(color)) {
|
|
1659
|
+
color = group.circuits.getItemByIndex(i, false).color;
|
|
1863
1660
|
}
|
|
1864
|
-
out.payload.push(color);
|
|
1865
1661
|
}
|
|
1662
|
+
out.payload.push(color);
|
|
1866
1663
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1664
|
+
}
|
|
1665
|
+
else {
|
|
1666
|
+
for (let i = 0; i < 16; i++) {
|
|
1667
|
+
out.payload.push(group.circuits.getItemByIndex(i, false).color);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
out.appendPayloadString(obj.name || group.name, 16);
|
|
1671
|
+
await out.sendAsync();
|
|
1672
|
+
if (typeof obj.circuits !== 'undefined') {
|
|
1673
|
+
for (let i = 0; i < obj.circuits.length; i++) {
|
|
1674
|
+
let circ = group.circuits.getItemByIndex(i, true);
|
|
1675
|
+
let color = 0;
|
|
1676
|
+
if (i < obj.circuits.length) {
|
|
1677
|
+
color = parseInt(obj.circuits[i].color, 10);
|
|
1678
|
+
if (isNaN(color)) { color = circ.color || 0; }
|
|
1679
|
+
//console.log(`Setting Color: {0}`, color);
|
|
1870
1680
|
}
|
|
1681
|
+
circ.color = color;
|
|
1871
1682
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
});
|
|
1875
|
-
return Promise.resolve(group);
|
|
1683
|
+
}
|
|
1684
|
+
return group;
|
|
1876
1685
|
}
|
|
1877
1686
|
catch (err) { return Promise.reject(err); }
|
|
1878
1687
|
}
|
|
@@ -1882,62 +1691,42 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1882
1691
|
if (isNaN(id) || !sys.board.equipmentIds.circuitGroups.isInRange(id)) return Promise.reject(new Error(`Invalid light group id: ${obj.id}`));
|
|
1883
1692
|
group = sys.lightGroups.getItemById(id);
|
|
1884
1693
|
try {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
retries: 5,
|
|
1891
|
-
onComplete: (err, msg) => {
|
|
1892
|
-
if (err) reject(err);
|
|
1893
|
-
else {
|
|
1894
|
-
let gstate = state.lightGroups.getItemById(id);
|
|
1895
|
-
gstate.isActive = false;
|
|
1896
|
-
gstate.emitEquipmentChange();
|
|
1897
|
-
sys.lightGroups.removeItemById(id);
|
|
1898
|
-
state.lightGroups.removeItemById(id);
|
|
1899
|
-
resolve();
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
});
|
|
1903
|
-
for (let i = 0; i < 16; i++) i < group.circuits.length ? out.payload.push(group.circuits.getItemByIndex(i).circuit - 1) : out.payload.push(255);
|
|
1904
|
-
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1905
|
-
out.payload.push(12);
|
|
1906
|
-
out.payload.push(0);
|
|
1907
|
-
conn.queueSendMessage(out);
|
|
1694
|
+
let out = Outbound.create({
|
|
1695
|
+
action: 168,
|
|
1696
|
+
payload: [6, 0, id - sys.board.equipmentIds.circuitGroups.start, 0, 0, 0],
|
|
1697
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1698
|
+
retries: 5
|
|
1908
1699
|
});
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
conn.queueSendMessage(out);
|
|
1700
|
+
for (let i = 0; i < 16; i++) i < group.circuits.length ? out.payload.push(group.circuits.getItemByIndex(i).circuit - 1) : out.payload.push(255);
|
|
1701
|
+
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1702
|
+
out.payload.push(12);
|
|
1703
|
+
out.payload.push(0);
|
|
1704
|
+
await out.sendAsync();
|
|
1705
|
+
let gstate = state.lightGroups.getItemById(id);
|
|
1706
|
+
gstate.isActive = false;
|
|
1707
|
+
gstate.emitEquipmentChange();
|
|
1708
|
+
sys.lightGroups.removeItemById(id);
|
|
1709
|
+
state.lightGroups.removeItemById(id);
|
|
1710
|
+
out = Outbound.create({
|
|
1711
|
+
action: 168,
|
|
1712
|
+
retries: 5,
|
|
1713
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1714
|
+
payload: [6, 1, id - sys.board.equipmentIds.circuitGroups.start]
|
|
1925
1715
|
});
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
1936
|
-
});
|
|
1937
|
-
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1938
|
-
conn.queueSendMessage(out);
|
|
1716
|
+
for (let i = 0; i < 16; i++) out.payload.push(255);
|
|
1717
|
+
out.appendPayloadString(group.name);
|
|
1718
|
+
await out.sendAsync();
|
|
1719
|
+
|
|
1720
|
+
out = Outbound.create({
|
|
1721
|
+
action: 168,
|
|
1722
|
+
retries: 5,
|
|
1723
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
1724
|
+
payload: [6, 2, id - sys.board.equipmentIds.circuitGroups.start]
|
|
1939
1725
|
});
|
|
1940
|
-
|
|
1726
|
+
for (let i = 0; i < 16; i++) out.payload.push(0);
|
|
1727
|
+
await out.sendAsync();
|
|
1728
|
+
|
|
1729
|
+
return group;
|
|
1941
1730
|
}
|
|
1942
1731
|
catch (err) { return Promise.reject(err); }
|
|
1943
1732
|
}
|
|
@@ -1959,47 +1748,28 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
1959
1748
|
msgs.msg1.payload[i + 3] = circuit ? circuit.color || 0 : 255;
|
|
1960
1749
|
msgs.msg2.payload[i + 3] = circuit ? circuit.color || 0 : 0;
|
|
1961
1750
|
}
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
await new Promise<void>((resolve, reject) => {
|
|
1985
|
-
msgs.msg1.response = IntelliCenterBoard.getAckResponse(168);
|
|
1986
|
-
msgs.msg1.retries = 5;
|
|
1987
|
-
msgs.msg1.onComplete = (err) => {
|
|
1988
|
-
if (!err) { resolve(); }
|
|
1989
|
-
else reject(err);
|
|
1990
|
-
}
|
|
1991
|
-
conn.queueSendMessage(msgs.msg1);
|
|
1992
|
-
});
|
|
1993
|
-
await new Promise<void>((resolve, reject) => {
|
|
1994
|
-
msgs.msg2.response = IntelliCenterBoard.getAckResponse(168);
|
|
1995
|
-
msgs.msg2.retries = 5;
|
|
1996
|
-
msgs.msg2.onComplete = (err) => {
|
|
1997
|
-
if (!err) { resolve(); }
|
|
1998
|
-
else reject(err);
|
|
1999
|
-
}
|
|
2000
|
-
conn.queueSendMessage(msgs.msg2);
|
|
2001
|
-
});
|
|
2002
|
-
return Promise.resolve(grp);
|
|
1751
|
+
msgs.msg0.response = IntelliCenterBoard.getAckResponse(168);
|
|
1752
|
+
msgs.msg0.retries = 5;
|
|
1753
|
+
await msgs.msg0.sendAsync();
|
|
1754
|
+
for (let i = 0; i < group.circuits.length; i++) {
|
|
1755
|
+
let c = group.circuits[i];
|
|
1756
|
+
let circuit = grp.circuits.getItemByIndex(i, true);
|
|
1757
|
+
circuit.circuit = parseInt(c.circuit, 10);
|
|
1758
|
+
circuit.swimDelay = parseInt(c.swimDelay, 10);
|
|
1759
|
+
circuit.color = parseInt(c.color, 10);
|
|
1760
|
+
circuit.position = i + 1;
|
|
1761
|
+
//grp.circuits.add({ id: i, circuit: circuit.circuit, color: circuit.color, position: i, swimDelay: circuit.swimDelay });
|
|
1762
|
+
}
|
|
1763
|
+
// Trim anything that was removed.
|
|
1764
|
+
grp.circuits.length = group.circuits.length;
|
|
1765
|
+
|
|
1766
|
+
msgs.msg1.response = IntelliCenterBoard.getAckResponse(168);
|
|
1767
|
+
msgs.msg1.retries = 5;
|
|
1768
|
+
await msgs.msg1.sendAsync();
|
|
1769
|
+
msgs.msg2.response = IntelliCenterBoard.getAckResponse(168);
|
|
1770
|
+
msgs.msg2.retries = 5;
|
|
1771
|
+
await msgs.msg2.sendAsync();
|
|
1772
|
+
return grp;
|
|
2003
1773
|
}
|
|
2004
1774
|
catch (err) { return Promise.reject(err); }
|
|
2005
1775
|
}
|
|
@@ -2104,24 +1874,16 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2104
1874
|
sgroup.emitEquipmentChange();
|
|
2105
1875
|
out.payload[28 + byteNdx] = byte;
|
|
2106
1876
|
// So now we have all the info we need to sequence the group.
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
sgroup.action = sys.board.valueMaps.circuitActions.getValue(cmd.name);
|
|
2113
|
-
state.emitEquipmentChanges();
|
|
2114
|
-
resolve(sgroup);
|
|
2115
|
-
}
|
|
2116
|
-
else {
|
|
2117
|
-
sgroup.action = 0;
|
|
2118
|
-
reject(err);
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
conn.queueSendMessage(out);
|
|
2122
|
-
});
|
|
1877
|
+
out.retries = 5;
|
|
1878
|
+
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
1879
|
+
await out.sendAsync();
|
|
1880
|
+
sgroup.action = sys.board.valueMaps.circuitActions.getValue(cmd.name);
|
|
1881
|
+
state.emitEquipmentChanges();
|
|
2123
1882
|
return sgroup;
|
|
2124
|
-
} catch (err) {
|
|
1883
|
+
} catch (err) {
|
|
1884
|
+
sgroup.action = 0;
|
|
1885
|
+
return Promise.reject(new InvalidOperationError(`Error Sequencing Light Group: ${err.message}`, 'sequenceLightGroupAsync'));
|
|
1886
|
+
}
|
|
2125
1887
|
//let nop = sys.board.valueMaps.circuitActions.getValue(operation);
|
|
2126
1888
|
//if (nop > 0) {
|
|
2127
1889
|
// let out = this.createCircuitStateMessage(id, true);
|
|
@@ -2161,7 +1923,7 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2161
1923
|
// }
|
|
2162
1924
|
// else reject(err);
|
|
2163
1925
|
// };
|
|
2164
|
-
//
|
|
1926
|
+
// await out.sendAsync();
|
|
2165
1927
|
// });
|
|
2166
1928
|
//}
|
|
2167
1929
|
//return Promise.resolve(sgroup);
|
|
@@ -2179,63 +1941,48 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2179
1941
|
// }
|
|
2180
1942
|
//}
|
|
2181
1943
|
private async verifyVersionAsync(): Promise<boolean> {
|
|
2182
|
-
|
|
1944
|
+
try {
|
|
2183
1945
|
let out = Outbound.create({
|
|
2184
1946
|
action: 228,
|
|
2185
1947
|
retries: 3,
|
|
2186
1948
|
response: Response.create({ dest: -1, action: 164 }),
|
|
2187
|
-
payload: [0]
|
|
2188
|
-
onComplete: (err) => {
|
|
2189
|
-
if (err) reject(err);
|
|
2190
|
-
else {
|
|
2191
|
-
// Send an ACK to the OCP.
|
|
2192
|
-
let ack = Outbound.create({ action: 1, destination: 16, payload: [164] });
|
|
2193
|
-
conn.queueSendMessage(ack);
|
|
2194
|
-
resolve(true);
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
1949
|
+
payload: [0]
|
|
2197
1950
|
});
|
|
2198
|
-
|
|
2199
|
-
|
|
1951
|
+
await out.sendAsync();
|
|
1952
|
+
let ack = Outbound.create({ action: 1, destination: 16, payload: [164] });
|
|
1953
|
+
let res = await ack.sendAsync();
|
|
1954
|
+
return res;
|
|
1955
|
+
}
|
|
1956
|
+
catch (err) {
|
|
1957
|
+
return Promise.reject(err);
|
|
1958
|
+
}
|
|
2200
1959
|
}
|
|
2201
1960
|
private async getConfigAsync(payload: number[]): Promise<boolean> {
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
onComplete: (err) => {
|
|
2209
|
-
if (err) reject(err);
|
|
2210
|
-
else {
|
|
2211
|
-
let ack = Outbound.create({ action: 1, destination: 16, payload: [30] });
|
|
2212
|
-
conn.queueSendMessage(ack);
|
|
2213
|
-
resolve(true);
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
});
|
|
2217
|
-
conn.queueSendMessage(out);
|
|
1961
|
+
|
|
1962
|
+
let out = Outbound.create({
|
|
1963
|
+
action: 222,
|
|
1964
|
+
retries: 3,
|
|
1965
|
+
payload: payload,
|
|
1966
|
+
response: Response.create({ dest: -1, action: 30, payload: payload })
|
|
2218
1967
|
});
|
|
1968
|
+
await out.sendAsync();
|
|
1969
|
+
let ack = Outbound.create({ action: 1, destination: 16, payload: [30] });
|
|
1970
|
+
await ack.sendAsync();
|
|
1971
|
+
return true;
|
|
2219
1972
|
|
|
2220
1973
|
}
|
|
2221
1974
|
private async verifyStateAsync(): Promise<boolean> {
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
response: Response.create({ dest: -1, action: 30, payload: [15, 0] }),
|
|
2228
|
-
onComplete: (err) => {
|
|
2229
|
-
if (err) reject(err);
|
|
2230
|
-
else {
|
|
2231
|
-
let ack = Outbound.create({ action: 1, destination: 16, payload: [30] });
|
|
2232
|
-
conn.queueSendMessage(ack);
|
|
2233
|
-
resolve(true);
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
});
|
|
2237
|
-
conn.queueSendMessage(out);
|
|
1975
|
+
let out = Outbound.create({
|
|
1976
|
+
action: 222,
|
|
1977
|
+
retries: 3,
|
|
1978
|
+
payload: [15, 0],
|
|
1979
|
+
response: Response.create({ dest: -1, action: 30, payload: [15, 0] })
|
|
2238
1980
|
});
|
|
1981
|
+
await out.sendAsync();
|
|
1982
|
+
let ack = Outbound.create({ action: 1, destination: 16, payload: [30] });
|
|
1983
|
+
await ack.sendAsync();
|
|
1984
|
+
return true;
|
|
1985
|
+
|
|
2239
1986
|
}
|
|
2240
1987
|
public async setCircuitStateAsync(id: number, val: boolean, ignoreDelays?: boolean): Promise<ICircuitState> {
|
|
2241
1988
|
let c = sys.circuits.getInterfaceById(id);
|
|
@@ -2265,44 +2012,36 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2265
2012
|
try {
|
|
2266
2013
|
//let b = await this.verifyVersionAsync();
|
|
2267
2014
|
//if (b) b = await this.getConfigAsync([15, 0]);
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
};
|
|
2288
|
-
out.scope = `circuitState${id}`;
|
|
2289
|
-
out.retries = 5;
|
|
2290
|
-
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
2291
|
-
conn.queueSendMessage(out);
|
|
2292
|
-
});
|
|
2015
|
+
let out = this.createCircuitStateMessage(id, val);
|
|
2016
|
+
//if (sys.equipment.dual && id === 6) out.setPayloadByte(35, 1);
|
|
2017
|
+
out.setPayloadByte(34, 1);
|
|
2018
|
+
out.source = 16;
|
|
2019
|
+
out.scope = `circuitState${id}`;
|
|
2020
|
+
out.retries = 5;
|
|
2021
|
+
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
2022
|
+
await out.sendAsync();
|
|
2023
|
+
// There is a current bug in 1.047 where one controller will reset the settings
|
|
2024
|
+
// of another when they are not the controller that set it. Either this is a BS bug
|
|
2025
|
+
// or there is some piece of information we do not have.
|
|
2026
|
+
let b = await this.getConfigAsync([15, 0]);
|
|
2027
|
+
let circ = state.circuits.getInterfaceById(id);
|
|
2028
|
+
// This doesn't work to set it back because the ICP will set it back but often this
|
|
2029
|
+
// can take several seconds to do so.
|
|
2030
|
+
//if (circ.isOn !== utils.makeBool(val)) await this.setCircuitStateAsync(id, val);
|
|
2031
|
+
state.emitEquipmentChanges();
|
|
2032
|
+
return circ;
|
|
2033
|
+
|
|
2293
2034
|
}
|
|
2294
2035
|
catch (err) { return Promise.reject(err); }
|
|
2295
2036
|
}
|
|
2296
2037
|
public async setCircuitGroupStateAsync(id: number, val: boolean): Promise<ICircuitGroupState> {
|
|
2297
2038
|
let grp = sys.circuitGroups.getItemById(id, false, { isActive: false });
|
|
2298
2039
|
let gstate = (grp.dataName === 'circuitGroupConfig') ? state.circuitGroups.getItemById(grp.id, grp.isActive !== false) : state.lightGroups.getItemById(grp.id, grp.isActive !== false);
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
catch (err) { reject(err); }
|
|
2305
|
-
});
|
|
2040
|
+
try {
|
|
2041
|
+
await sys.board.circuits.setCircuitStateAsync(id, val);
|
|
2042
|
+
return state.circuitGroups.getInterfaceById(id);
|
|
2043
|
+
}
|
|
2044
|
+
catch (err) { return Promise.reject(err); }
|
|
2306
2045
|
}
|
|
2307
2046
|
public async setLightGroupStateAsync(id: number, val: boolean): Promise<ICircuitGroupState> { return this.setCircuitGroupStateAsync(id, val); }
|
|
2308
2047
|
public async setLightGroupThemeAsync(id: number, theme: number): Promise<ICircuitState> {
|
|
@@ -2311,21 +2050,14 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2311
2050
|
let sgroup = state.lightGroups.getItemById(id);
|
|
2312
2051
|
let msgs = this.createLightGroupMessages(group);
|
|
2313
2052
|
msgs.msg0.payload[4] = (theme << 2) + 1;
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
sgroup.lightingTheme = theme;
|
|
2321
|
-
resolve();
|
|
2322
|
-
}
|
|
2323
|
-
else reject(err);
|
|
2324
|
-
};
|
|
2325
|
-
conn.queueSendMessage(msgs.msg0);
|
|
2326
|
-
});
|
|
2053
|
+
msgs.msg0.response = IntelliCenterBoard.getAckResponse(168);
|
|
2054
|
+
msgs.msg0.retries = 5;
|
|
2055
|
+
await msgs.msg0.sendAsync();
|
|
2056
|
+
group.lightingTheme = theme;
|
|
2057
|
+
sgroup.lightingTheme = theme;
|
|
2058
|
+
|
|
2327
2059
|
state.emitEquipmentChanges();
|
|
2328
|
-
return
|
|
2060
|
+
return sgroup;
|
|
2329
2061
|
}
|
|
2330
2062
|
catch (err) { return Promise.reject(err); }
|
|
2331
2063
|
}
|
|
@@ -2371,21 +2103,11 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2371
2103
|
cstate.action = sys.board.valueMaps.circuitActions.getValue('lighttheme');
|
|
2372
2104
|
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
2373
2105
|
out.retries = 5;
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
resolve();
|
|
2380
|
-
}
|
|
2381
|
-
else {
|
|
2382
|
-
reject(err);
|
|
2383
|
-
}
|
|
2384
|
-
cstate.action = 0;
|
|
2385
|
-
};
|
|
2386
|
-
out.appendPayloadString(circuit.name, 16);
|
|
2387
|
-
conn.queueSendMessage(out);
|
|
2388
|
-
});
|
|
2106
|
+
out.appendPayloadString(circuit.name, 16);
|
|
2107
|
+
await out.sendAsync();
|
|
2108
|
+
circuit.lightingTheme = theme;
|
|
2109
|
+
cstate.lightingTheme = theme;
|
|
2110
|
+
cstate.action = 0;
|
|
2389
2111
|
if (!cstate.isOn) await this.setCircuitStateAsync(id, true);
|
|
2390
2112
|
state.emitEquipmentChanges();
|
|
2391
2113
|
return Promise.resolve(cstate);
|
|
@@ -2553,28 +2275,20 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
|
|
|
2553
2275
|
try {
|
|
2554
2276
|
if (!cstate.isOn)
|
|
2555
2277
|
await this.setCircuitStateAsync(id, true);
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
retries: 5,
|
|
2562
|
-
onComplete: (err, msg) => {
|
|
2563
|
-
if (!err) {
|
|
2564
|
-
circuit.level = level;
|
|
2565
|
-
cstate.level = level;
|
|
2566
|
-
sys.board.circuits.setEndTime(circuit, cstate, true);
|
|
2567
|
-
cstate.isOn = true;
|
|
2568
|
-
state.emitEquipmentChanges();
|
|
2569
|
-
resolve();
|
|
2570
|
-
}
|
|
2571
|
-
else reject(err);
|
|
2572
|
-
}
|
|
2573
|
-
});
|
|
2574
|
-
out.appendPayloadString(circuit.name, 16);
|
|
2575
|
-
conn.queueSendMessage(out);
|
|
2278
|
+
let out = Outbound.create({
|
|
2279
|
+
action: 168, payload: [1, 0, id - 1, circuit.type, circuit.freeze ? 1 : 0, circuit.showInFeatures ? 1 : 0,
|
|
2280
|
+
level, Math.floor(circuit.eggTimer / 60), circuit.eggTimer - ((Math.floor(circuit.eggTimer) / 60) * 60), circuit.dontStop ? 1 : 0],
|
|
2281
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2282
|
+
retries: 5
|
|
2576
2283
|
});
|
|
2577
|
-
|
|
2284
|
+
out.appendPayloadString(circuit.name, 16);
|
|
2285
|
+
await out.sendAsync();
|
|
2286
|
+
circuit.level = level;
|
|
2287
|
+
cstate.level = level;
|
|
2288
|
+
sys.board.circuits.setEndTime(circuit, cstate, true);
|
|
2289
|
+
cstate.isOn = true;
|
|
2290
|
+
state.emitEquipmentChanges();
|
|
2291
|
+
return cstate;
|
|
2578
2292
|
}
|
|
2579
2293
|
catch (err) { return Promise.reject(err); }
|
|
2580
2294
|
}
|
|
@@ -2587,83 +2301,70 @@ class IntelliCenterFeatureCommands extends FeatureCommands {
|
|
|
2587
2301
|
declare board: IntelliCenterBoard;
|
|
2588
2302
|
public async setFeatureStateAsync(id, val): Promise<ICircuitState> { return sys.board.circuits.setCircuitStateAsync(id, val); }
|
|
2589
2303
|
public async toggleFeatureStateAsync(id): Promise<ICircuitState> { return sys.board.circuits.toggleCircuitStateAsync(id); }
|
|
2590
|
-
public syncGroupStates() { } // Do nothing and let IntelliCenter do it.
|
|
2591
|
-
public async setFeatureAsync(data: any): Promise<Feature> {
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
onComplete: (err, msg) => {
|
|
2619
|
-
if (err) reject(err);
|
|
2620
|
-
else {
|
|
2621
|
-
feature = sys.features.getItemById(id, true);
|
|
2622
|
-
let fstate = state.features.getItemById(id, true);
|
|
2623
|
-
|
|
2624
|
-
feature.eggTimer = eggTimer;
|
|
2625
|
-
feature.dontStop = data.dontStop;
|
|
2626
|
-
feature.freeze = (typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : feature.freeze);
|
|
2627
|
-
fstate.showInFeatures = feature.showInFeatures = (typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : feature.showInFeatures);
|
|
2628
|
-
fstate.name = feature.name = typeof data.name !== 'undefined' ? data.name.toString().substring(0, 16) : feature.name;
|
|
2629
|
-
fstate.type = feature.type = typeof data.type !== 'undefined' ? parseInt(data.type, 10) : feature.type;
|
|
2630
|
-
fstate.emitEquipmentChange();
|
|
2631
|
-
resolve(feature);
|
|
2632
|
-
}
|
|
2633
|
-
}
|
|
2634
|
-
});
|
|
2635
|
-
out.appendPayloadString(typeof data.name !== 'undefined' ? data.name.toString() : feature.name, 16);
|
|
2636
|
-
conn.queueSendMessage(out);
|
|
2304
|
+
public syncGroupStates() { } // Do nothing and let IntelliCenter do it.
|
|
2305
|
+
public async setFeatureAsync(data: any): Promise<Feature> {
|
|
2306
|
+
|
|
2307
|
+
let id = parseInt(data.id, 10);
|
|
2308
|
+
let feature: Feature;
|
|
2309
|
+
if (id <= 0) {
|
|
2310
|
+
id = sys.features.getNextEquipmentId(sys.board.equipmentIds.features);
|
|
2311
|
+
feature = sys.features.getItemById(id, false, { isActive: true, freeze: false });
|
|
2312
|
+
}
|
|
2313
|
+
else
|
|
2314
|
+
feature = sys.features.getItemById(id, false);
|
|
2315
|
+
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError('feature Id has not been defined', data.id, 'Feature'));
|
|
2316
|
+
if (!sys.board.equipmentIds.features.isInRange(id)) return Promise.reject(new InvalidEquipmentIdError(`feature Id ${id}: is out of range.`, id, 'Feature'));
|
|
2317
|
+
let eggTimer = Math.min(typeof data.eggTimer !== 'undefined' ? parseInt(data.eggTimer, 10) : feature.eggTimer, 1440);
|
|
2318
|
+
if (isNaN(eggTimer)) eggTimer = feature.eggTimer;
|
|
2319
|
+
if (data.dontStop === true) eggTimer = 1440;
|
|
2320
|
+
data.dontStop = (eggTimer === 1440);
|
|
2321
|
+
let eggHrs = Math.floor(eggTimer / 60);
|
|
2322
|
+
let eggMins = eggTimer - (eggHrs * 60);
|
|
2323
|
+
let out = Outbound.create({
|
|
2324
|
+
action: 168,
|
|
2325
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2326
|
+
retries: 5,
|
|
2327
|
+
payload: [2, 0, id - sys.board.equipmentIds.features.start,
|
|
2328
|
+
typeof data.type !== 'undefined' ? parseInt(data.type, 10) : feature.type,
|
|
2329
|
+
(typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : feature.freeze) ? 1 : 0,
|
|
2330
|
+
(typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : feature.showInFeatures) ? 1 : 0,
|
|
2331
|
+
eggHrs, eggMins, data.dontStop ? 1 : 0]
|
|
2637
2332
|
});
|
|
2333
|
+
out.appendPayloadString(typeof data.name !== 'undefined' ? data.name.toString() : feature.name, 16);
|
|
2334
|
+
await out.sendAsync();
|
|
2335
|
+
feature = sys.features.getItemById(id, true);
|
|
2336
|
+
let fstate = state.features.getItemById(id, true);
|
|
2337
|
+
|
|
2338
|
+
feature.eggTimer = eggTimer;
|
|
2339
|
+
feature.dontStop = data.dontStop;
|
|
2340
|
+
feature.freeze = (typeof data.freeze !== 'undefined' ? utils.makeBool(data.freeze) : feature.freeze);
|
|
2341
|
+
fstate.showInFeatures = feature.showInFeatures = (typeof data.showInFeatures !== 'undefined' ? utils.makeBool(data.showInFeatures) : feature.showInFeatures);
|
|
2342
|
+
fstate.name = feature.name = typeof data.name !== 'undefined' ? data.name.toString().substring(0, 16) : feature.name;
|
|
2343
|
+
fstate.type = feature.type = typeof data.type !== 'undefined' ? parseInt(data.type, 10) : feature.type;
|
|
2344
|
+
fstate.emitEquipmentChange();
|
|
2345
|
+
return feature;
|
|
2346
|
+
|
|
2638
2347
|
}
|
|
2639
2348
|
public async deleteFeatureAsync(data: any): Promise<Feature> {
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
retries: 5,
|
|
2651
|
-
onComplete: (err, msg) => {
|
|
2652
|
-
if (err) reject(err);
|
|
2653
|
-
else {
|
|
2654
|
-
sys.features.removeItemById(id);
|
|
2655
|
-
feature.isActive = false;
|
|
2656
|
-
let fstate = state.features.getItemById(id, false);
|
|
2657
|
-
fstate.showInFeatures = false;
|
|
2658
|
-
state.features.removeItemById(id);
|
|
2659
|
-
resolve(feature);
|
|
2660
|
-
}
|
|
2661
|
-
}
|
|
2662
|
-
});
|
|
2663
|
-
out.appendPayloadString(typeof data.name !== 'undefined' ? data.name.toString() : feature.name, 16);
|
|
2664
|
-
conn.queueSendMessage(out);
|
|
2349
|
+
let id = parseInt(data.id, 10);
|
|
2350
|
+
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError('feature Id has not been defined', data.id, 'Feature'));
|
|
2351
|
+
let feature = sys.features.getItemById(id, false);
|
|
2352
|
+
let out = Outbound.create({
|
|
2353
|
+
action: 168,
|
|
2354
|
+
payload: [2, 0, id - sys.board.equipmentIds.features.start,
|
|
2355
|
+
255, // Delete the feature
|
|
2356
|
+
0, 0, 12, 0, 0],
|
|
2357
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2358
|
+
retries: 5
|
|
2665
2359
|
});
|
|
2666
|
-
|
|
2360
|
+
out.appendPayloadString(typeof data.name !== 'undefined' ? data.name.toString() : feature.name, 16);
|
|
2361
|
+
await out.sendAsync();
|
|
2362
|
+
sys.features.removeItemById(id);
|
|
2363
|
+
feature.isActive = false;
|
|
2364
|
+
let fstate = state.features.getItemById(id, false);
|
|
2365
|
+
fstate.showInFeatures = false;
|
|
2366
|
+
state.features.removeItemById(id);
|
|
2367
|
+
return feature;
|
|
2667
2368
|
}
|
|
2668
2369
|
|
|
2669
2370
|
}
|
|
@@ -2693,6 +2394,8 @@ class IntelliCenterChlorinatorCommands extends ChlorinatorCommands {
|
|
|
2693
2394
|
//let spaSetpoint = isDosing ? 100 : disabled ? 0 : parseInt(obj.spaSetpoint, 10);
|
|
2694
2395
|
let poolSetpoint = typeof obj.poolSetpoint !== 'undefined' ? parseInt(obj.poolSetpoint, 10) : chlor.poolSetpoint;
|
|
2695
2396
|
let spaSetpoint = typeof obj.spaSetpoint !== 'undefined' ? parseInt(obj.spaSetpoint, 10) : chlor.spaSetpoint;
|
|
2397
|
+
let saltTarget = typeof obj.saltTarget === 'number' ? parseInt(obj.saltTarget, 10) : chlor.saltTarget;
|
|
2398
|
+
|
|
2696
2399
|
if (poolSetpoint === 0) console.log(obj);
|
|
2697
2400
|
let model = typeof obj.model !== 'undefined' ? sys.board.valueMaps.chlorinatorModel.encode(obj.model) : chlor.model || 0;
|
|
2698
2401
|
let chlorType = typeof obj.type !== 'undefined' ? sys.board.valueMaps.chlorinatorType.encode(obj.type) : chlor.type || 0;
|
|
@@ -2718,39 +2421,35 @@ class IntelliCenterChlorinatorCommands extends ChlorinatorCommands {
|
|
|
2718
2421
|
let portId = typeof obj.portId !== 'undefined' ? parseInt(obj.portId, 10) : chlor.portId;
|
|
2719
2422
|
if (portId !== chlor.portId && sys.chlorinators.count(elem => elem.id !== chlor.id && elem.portId === portId && elem.master !== 2) > 0) return Promise.reject(new InvalidEquipmentDataError(`Another chlorinator is installed on port #${portId}. Only one chlorinator can be installed per port.`, 'Chlorinator', portId));
|
|
2720
2423
|
if (typeof obj.ignoreSaltReading !== 'undefined') chlor.ignoreSaltReading = utils.makeBool(obj.ignoreSaltReading);
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
onComplete: (err, msg) => {
|
|
2731
|
-
if (err) reject(err);
|
|
2732
|
-
else {
|
|
2733
|
-
let schlor = state.chlorinators.getItemById(id, true);
|
|
2734
|
-
let cchlor = sys.chlorinators.getItemById(id, true);
|
|
2735
|
-
chlor.master = 0;
|
|
2736
|
-
schlor.body = chlor.body = body.val;
|
|
2737
|
-
chlor.disabled = disabled;
|
|
2738
|
-
schlor.model = chlor.model = model;
|
|
2739
|
-
schlor.type = chlor.type = chlorType;
|
|
2740
|
-
chlor.name = schlor.name = name;
|
|
2741
|
-
chlor.isDosing = isDosing;
|
|
2742
|
-
schlor.isActive = cchlor.isActive = true;
|
|
2743
|
-
schlor.poolSetpoint = cchlor.poolSetpoint = poolSetpoint;
|
|
2744
|
-
schlor.spaSetpoint = cchlor.spaSetpoint = spaSetpoint;
|
|
2745
|
-
schlor.superChlorHours = cchlor.superChlorHours = superChlorHours;
|
|
2746
|
-
schlor.superChlor = cchlor.superChlor = superChlorinate;
|
|
2747
|
-
state.emitEquipmentChanges();
|
|
2748
|
-
resolve(schlor);
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
});
|
|
2752
|
-
conn.queueSendMessage(out);
|
|
2424
|
+
|
|
2425
|
+
let out = Outbound.create({
|
|
2426
|
+
action: 168,
|
|
2427
|
+
payload: [7, 0, id - 1, body.val, 1,
|
|
2428
|
+
disabled ? 0 : isDosing ? 100 : poolSetpoint,
|
|
2429
|
+
disabled ? 0 : isDosing ? 100 : spaSetpoint,
|
|
2430
|
+
superChlorinate ? 1 : 0, superChlorHours, 0, 1],
|
|
2431
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2432
|
+
retries: 5
|
|
2753
2433
|
});
|
|
2434
|
+
await out.sendAsync();
|
|
2435
|
+
let schlor = state.chlorinators.getItemById(id, true);
|
|
2436
|
+
let cchlor = sys.chlorinators.getItemById(id, true);
|
|
2437
|
+
chlor.master = 0;
|
|
2438
|
+
schlor.body = chlor.body = body.val;
|
|
2439
|
+
chlor.disabled = disabled;
|
|
2440
|
+
schlor.model = chlor.model = model;
|
|
2441
|
+
schlor.type = chlor.type = chlorType;
|
|
2442
|
+
chlor.name = schlor.name = name;
|
|
2443
|
+
chlor.isDosing = isDosing;
|
|
2444
|
+
chlor.saltTarget = saltTarget;
|
|
2445
|
+
schlor.isActive = cchlor.isActive = true;
|
|
2446
|
+
schlor.poolSetpoint = cchlor.poolSetpoint = poolSetpoint;
|
|
2447
|
+
schlor.spaSetpoint = cchlor.spaSetpoint = spaSetpoint;
|
|
2448
|
+
schlor.superChlorHours = cchlor.superChlorHours = superChlorHours;
|
|
2449
|
+
schlor.superChlor = cchlor.superChlor = superChlorinate;
|
|
2450
|
+
state.emitEquipmentChanges();
|
|
2451
|
+
return schlor;
|
|
2452
|
+
|
|
2754
2453
|
}
|
|
2755
2454
|
public async deleteChlorAsync(obj: any): Promise<ChlorinatorState> {
|
|
2756
2455
|
let id = parseInt(obj.id, 10);
|
|
@@ -2759,25 +2458,18 @@ class IntelliCenterChlorinatorCommands extends ChlorinatorCommands {
|
|
|
2759
2458
|
if (chlor.master === 1) return await super.deleteChlorAsync(obj);
|
|
2760
2459
|
let schlor = state.chlorinators.getItemById(id);
|
|
2761
2460
|
// Verify the data.
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
retries: 5,
|
|
2768
|
-
onComplete: (err, msg) => {
|
|
2769
|
-
if (err) reject(err);
|
|
2770
|
-
else {
|
|
2771
|
-
ncp.chlorinators.deleteChlorinatorAsync(id).then(()=>{});
|
|
2772
|
-
schlor = state.chlorinators.getItemById(id, true);
|
|
2773
|
-
state.chlorinators.removeItemById(id);
|
|
2774
|
-
sys.chlorinators.removeItemById(id);
|
|
2775
|
-
resolve(schlor);
|
|
2776
|
-
}
|
|
2777
|
-
}
|
|
2778
|
-
});
|
|
2779
|
-
conn.queueSendMessage(out);
|
|
2461
|
+
let out = Outbound.create({
|
|
2462
|
+
action: 168,
|
|
2463
|
+
payload: [7, 0, id - 1, schlor.body || 0, 0, schlor.poolSetpoint || 0, schlor.spaSetpoint || 0, 0, schlor.superChlorHours || 0, 0, 0],
|
|
2464
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2465
|
+
retries: 5
|
|
2780
2466
|
});
|
|
2467
|
+
await out.sendAsync();
|
|
2468
|
+
ncp.chlorinators.deleteChlorinatorAsync(id).then(() => { });
|
|
2469
|
+
schlor = state.chlorinators.getItemById(id, true);
|
|
2470
|
+
state.chlorinators.removeItemById(id);
|
|
2471
|
+
sys.chlorinators.removeItemById(id);
|
|
2472
|
+
return schlor;
|
|
2781
2473
|
}
|
|
2782
2474
|
}
|
|
2783
2475
|
class IntelliCenterPumpCommands extends PumpCommands {
|
|
@@ -2785,10 +2477,10 @@ class IntelliCenterPumpCommands extends PumpCommands {
|
|
|
2785
2477
|
let arr: Outbound[] = [];
|
|
2786
2478
|
let outSettings = Outbound.createMessage(
|
|
2787
2479
|
168, [4, 0, pump.id - 1, pump.type, 0, pump.address, pump.minSpeed - Math.floor(pump.minSpeed / 256) * 256, Math.floor(pump.minSpeed / 256), pump.maxSpeed - Math.floor(pump.maxSpeed / 256) * 256
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2480
|
+
, Math.floor(pump.maxSpeed / 256), pump.minFlow, pump.maxFlow, pump.flowStepSize, pump.primingSpeed - Math.floor(pump.primingSpeed / 256) * 256
|
|
2481
|
+
, Math.floor(pump.primingSpeed / 256), pump.speedStepSize / 10, pump.primingTime
|
|
2482
|
+
, 5, 255, 255, 255, 255, 255, 255, 255, 255
|
|
2483
|
+
, 0, 0, 0, 0, 0, 0, 0, 0], 0); // All the circuits and units.
|
|
2792
2484
|
let outName = Outbound.createMessage(
|
|
2793
2485
|
168, [4, 1, pump.id - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 0);
|
|
2794
2486
|
for (let i = 0; i < 8; i++) {
|
|
@@ -2842,46 +2534,46 @@ class IntelliCenterPumpCommands extends PumpCommands {
|
|
|
2842
2534
|
outName.appendPayloadString(pump.name, 16);
|
|
2843
2535
|
return [outSettings, outName];
|
|
2844
2536
|
}
|
|
2845
|
-
/* public setPumpCircuit(pump: Pump, pumpCircuitDeltas: any) {
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2537
|
+
/* public setPumpCircuit(pump: Pump, pumpCircuitDeltas: any) {
|
|
2538
|
+
let { result, reason } = super.setPumpCircuit(pump, pumpCircuitDeltas);
|
|
2539
|
+
if (result === 'OK') this.setPump(pump);
|
|
2540
|
+
return { result: result, reason: reason };
|
|
2541
|
+
}
|
|
2542
|
+
public setPump(pump: Pump, obj?: any) {
|
|
2543
|
+
super.setPump(pump, obj);
|
|
2544
|
+
let msgs: Outbound[] = this.createPumpConfigMessages(pump);
|
|
2545
|
+
for (let i = 0; i < msgs.length; i++){
|
|
2546
|
+
conn.queueSendMessage(msgs[i]);
|
|
2547
|
+
}
|
|
2548
|
+
} */
|
|
2857
2549
|
public async setPumpAsync(data: any): Promise<Pump> {
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2550
|
+
try {
|
|
2551
|
+
let id = (typeof data.id === 'undefined' || data.id <= 0) ? sys.pumps.getNextEquipmentId(sys.board.equipmentIds.pumps) : parseInt(data.id, 10);
|
|
2552
|
+
if (isNaN(id)) return Promise.reject(new Error(`Invalid pump id: ${data.id}`));
|
|
2553
|
+
let pump = sys.pumps.getItemById(id, false);
|
|
2554
|
+
if (data.master > 0 || pump.master > 0) return await super.setPumpAsync(data);
|
|
2862
2555
|
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2556
|
+
// 0 6 10 11 12 15
|
|
2557
|
+
//[255, 0, 255][165, 63, 15, 16, 168, 34][4, 0, 0, 3, 0, 96, 194, 1, 122, 13, 15, 130, 1, 196, 9, 128, 2, 255, 5, 0, 251, 128, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0][11, 218]
|
|
2558
|
+
//[255, 0, 255][165, 63, 15, 16, 168, 34][4, 0, 0, 3, 0, 96, 194, 1, 122, 13, 15, 130, 1, 196, 9, 1, 2, 255, 5, 0, 251, 128, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0][11, 91]
|
|
2559
|
+
//[255, 0, 255][165, 63, 15, 16, 168, 34][4, 0, 0, 3, 0, 96, 194, 1, 122, 13, 15, 130, 1, 196, 9, 128, 2, 255, 5, 0, 251, 128, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0][11, 218]
|
|
2867
2560
|
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
try {
|
|
2561
|
+
//[255, 0, 255][165, 63, 15, 33, 168, 33][4, 0, 0, 3, 0, 96, 194, 1, 122, 13, 15, 130, 1, 196, 9, 640, 255, 255, 5, 0, 251, 128, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0][14, 231]
|
|
2562
|
+
//[255, 0, 255][165, 63, 15, 33, 168, 34][4, 0, 0, 3, 0, 96, 194, 1, 122, 13, 15, 130, 1, 196, 9, 300, 255, 3, 5, 0, 251, 128, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0][12, 152]
|
|
2563
|
+
if (isNaN(id)) return Promise.reject(new Error(`Invalid pump id: ${data.id}`));
|
|
2564
|
+
else if (id >= sys.equipment.maxPumps) return Promise.reject(new Error(`Pump id out of range: ${data.id}`));
|
|
2565
|
+
// We now need to get the type for the pump. If the incoming data doesn't include it then we need to
|
|
2566
|
+
// get it from the current pump configuration.
|
|
2567
|
+
let ntype = (typeof data.type === 'undefined' || isNaN(parseInt(data.type, 10))) ? pump.type : parseInt(data.type, 10);
|
|
2568
|
+
// While we are dealing with adds in the setPumpConfig we are not dealing with deletes so this needs to be a value greater than nopump. If someone sends
|
|
2569
|
+
// us a type that is <= 0 we need to throw an error. If they dont define it or give us an invalid number we can move on.
|
|
2570
|
+
if (isNaN(ntype) || ntype <= 0) return Promise.reject(new Error(`Invalid pump type: ${data.id} - ${data.type}`));
|
|
2571
|
+
let type = sys.board.valueMaps.pumpTypes.transform(ntype);
|
|
2572
|
+
if (typeof type.name === 'undefined') return Promise.reject(new Error(`Invalid pump type: ${data.id} - ${ntype}`));
|
|
2573
|
+
// Build out our messsages. We are merging data together so that the data items from the current config can be overridden. If they are not
|
|
2574
|
+
// supplied then we will use what we already have. This will make sure the information is valid and any change can be applied without the complete
|
|
2575
|
+
// definition of the pump. This is important since additional attributes may be added in the future and this keeps us current no matter what
|
|
2576
|
+
// the endpoint capability is.
|
|
2885
2577
|
let outc = Outbound.create({ action: 168, payload: [4, 0, id - 1, ntype, 0] });
|
|
2886
2578
|
outc.appendPayloadByte(parseInt(data.address, 10), id + 95); // 5
|
|
2887
2579
|
outc.appendPayloadInt(parseInt(data.minSpeed, 10), pump.minSpeed); // 6
|
|
@@ -2927,6 +2619,7 @@ class IntelliCenterPumpCommands extends PumpCommands {
|
|
|
2927
2619
|
// The endpoint isn't changing the circuits and is just setting the attributes.
|
|
2928
2620
|
for (let i = 0; i < 8; i++) {
|
|
2929
2621
|
let circ = pump.circuits.getItemByIndex(i, false, { circuit: 255 });
|
|
2622
|
+
circ.id = i + 1;
|
|
2930
2623
|
outc.setPayloadByte(i + 18, circ.circuit);
|
|
2931
2624
|
}
|
|
2932
2625
|
}
|
|
@@ -2971,117 +2664,105 @@ class IntelliCenterPumpCommands extends PumpCommands {
|
|
|
2971
2664
|
}
|
|
2972
2665
|
}
|
|
2973
2666
|
// We now have our messages. Let's send them off and update our values.
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2667
|
+
outc.response = IntelliCenterBoard.getAckResponse(168);
|
|
2668
|
+
outc.retries = 5;
|
|
2669
|
+
await outc.sendAsync();
|
|
2670
|
+
// We have been successful so lets set our pump with the new data.
|
|
2671
|
+
pump = sys.pumps.getItemById(id, true);
|
|
2672
|
+
let spump = state.pumps.getItemById(id, true);
|
|
2673
|
+
spump.type = pump.type = ntype;
|
|
2674
|
+
if (typeof data.model !== 'undefined') pump.model = data.model;
|
|
2675
|
+
if (type.name === 'ss') {
|
|
2676
|
+
pump.address = undefined;
|
|
2677
|
+
pump.primingTime = 0;
|
|
2678
|
+
pump.primingSpeed = type.primingSpeed || 2500;
|
|
2679
|
+
pump.minSpeed = type.minSpeed || 450;
|
|
2680
|
+
pump.maxSpeed = type.maxSpeed || 3450;
|
|
2681
|
+
pump.minFlow = type.minFlow, 0;
|
|
2682
|
+
pump.maxFlow = type.maxFlow, 130;
|
|
2683
|
+
pump.circuits.clear();
|
|
2684
|
+
if (typeof data.body !== 'undefined') pump.body = parseInt(data.body, 10);
|
|
2685
|
+
}
|
|
2686
|
+
else if (type.name === 'ds') {
|
|
2687
|
+
pump.address = undefined;
|
|
2688
|
+
pump.primingTime = 0;
|
|
2689
|
+
pump.primingSpeed = type.primingSpeed || 2500;
|
|
2690
|
+
pump.minSpeed = type.minSpeed || 450;
|
|
2691
|
+
pump.maxSpeed = type.maxSpeed || 3450;
|
|
2692
|
+
pump.minFlow = type.minFlow, 0;
|
|
2693
|
+
pump.maxFlow = type.maxFlow, 130;
|
|
2694
|
+
if (typeof data.body !== 'undefined') pump.body = parseInt(data.body, 10);
|
|
2695
|
+
}
|
|
2696
|
+
else {
|
|
2697
|
+
if (typeof data.address !== 'undefined') pump.address = data.address;
|
|
2698
|
+
if (typeof data.primingTime !== 'undefined') pump.primingTime = parseInt(data.primingTime, 10);
|
|
2699
|
+
if (typeof data.primingSpeed !== 'undefined') pump.primingSpeed = parseInt(data.primingSpeed, 10);
|
|
2700
|
+
if (typeof data.minSpeed !== 'undefined') pump.minSpeed = parseInt(data.minSpeed, 10);
|
|
2701
|
+
if (typeof data.maxSpeed !== 'undefined') pump.maxSpeed = parseInt(data.maxSpeed, 10);
|
|
2702
|
+
if (typeof data.minFlow !== 'undefined') pump.minFlow = parseInt(data.minFlow, 10);
|
|
2703
|
+
if (typeof data.maxFlow !== 'undefined') pump.maxFlow = parseInt(data.maxFlow, 10);
|
|
2704
|
+
if (typeof data.flowStepSize !== 'undefined') pump.flowStepSize = parseInt(data.flowStepSize, 10);
|
|
2705
|
+
if (typeof data.speedStepSize !== 'undefined') pump.speedStepSize = parseInt(data.speedStepSize, 10);
|
|
2706
|
+
}
|
|
2707
|
+
if (typeof data.circuits !== 'undefined' && type.name !== 'undefined') {
|
|
2708
|
+
// Set all the circuits
|
|
2709
|
+
let id = 1;
|
|
2710
|
+
for (let i = 0; i < 8; i++) {
|
|
2711
|
+
if (i >= data.circuits.length) pump.circuits.removeItemByIndex(i);
|
|
2979
2712
|
else {
|
|
2980
|
-
|
|
2981
|
-
let
|
|
2982
|
-
|
|
2983
|
-
spump.type = pump.type = ntype;
|
|
2984
|
-
if (typeof data.model !== 'undefined') pump.model = data.model;
|
|
2985
|
-
if (type.name === 'ss') {
|
|
2986
|
-
pump.address = undefined;
|
|
2987
|
-
pump.primingTime = 0;
|
|
2988
|
-
pump.primingSpeed = type.primingSpeed || 2500;
|
|
2989
|
-
pump.minSpeed = type.minSpeed || 450;
|
|
2990
|
-
pump.maxSpeed = type.maxSpeed || 3450;
|
|
2991
|
-
pump.minFlow = type.minFlow, 0;
|
|
2992
|
-
pump.maxFlow = type.maxFlow, 130;
|
|
2993
|
-
pump.circuits.clear();
|
|
2994
|
-
if (typeof data.body !== 'undefined') pump.body = parseInt(data.body, 10);
|
|
2995
|
-
}
|
|
2996
|
-
else if (type.name === 'ds') {
|
|
2997
|
-
pump.address = undefined;
|
|
2998
|
-
pump.primingTime = 0;
|
|
2999
|
-
pump.primingSpeed = type.primingSpeed || 2500;
|
|
3000
|
-
pump.minSpeed = type.minSpeed || 450;
|
|
3001
|
-
pump.maxSpeed = type.maxSpeed || 3450;
|
|
3002
|
-
pump.minFlow = type.minFlow, 0;
|
|
3003
|
-
pump.maxFlow = type.maxFlow, 130;
|
|
3004
|
-
if (typeof data.body !== 'undefined') pump.body = parseInt(data.body, 10);
|
|
3005
|
-
}
|
|
2713
|
+
let c = data.circuits[i];
|
|
2714
|
+
let circuitId = parseInt(c.circuit, 10);
|
|
2715
|
+
if (isNaN(circuitId)) pump.circuits.removeItemByIndex(i);
|
|
3006
2716
|
else {
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
if (
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
if (typeof data.speedStepSize !== 'undefined') pump.speedStepSize = parseInt(data.speedStepSize, 10);
|
|
3016
|
-
}
|
|
3017
|
-
if (typeof data.circuits !== 'undefined' && type.name !== 'undefined') {
|
|
3018
|
-
// Set all the circuits
|
|
3019
|
-
for (let i = 0; i < 8; i++) {
|
|
3020
|
-
if (i >= data.circuits.length) pump.circuits.removeItemByIndex(i);
|
|
3021
|
-
else {
|
|
3022
|
-
let c = data.circuits[i];
|
|
3023
|
-
let circuitId = parseInt(c.circuit, 10);
|
|
3024
|
-
if (isNaN(circuitId)) pump.circuits.removeItemByIndex(i);
|
|
3025
|
-
else {
|
|
3026
|
-
let circ = pump.circuits.getItemByIndex(i, true);
|
|
3027
|
-
circ.circuit = circuitId;
|
|
3028
|
-
if (type.name === 'ds') circ.units = undefined;
|
|
3029
|
-
else {
|
|
3030
|
-
// Need to validate this earlier.
|
|
3031
|
-
let units = c.units !== 'undefined' ? parseInt(c.units, 10) : 0
|
|
3032
|
-
circ.units = units;
|
|
3033
|
-
}
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
2717
|
+
let circ = pump.circuits.getItemByIndex(i, true);
|
|
2718
|
+
circ.circuit = circuitId;
|
|
2719
|
+
circ.id = id++;
|
|
2720
|
+
if (type.name === 'ds') circ.units = undefined;
|
|
2721
|
+
else {
|
|
2722
|
+
// Need to validate this earlier.
|
|
2723
|
+
let units = c.units !== 'undefined' ? parseInt(c.units, 10) : 0
|
|
2724
|
+
circ.units = units;
|
|
3036
2725
|
}
|
|
3037
2726
|
}
|
|
3038
|
-
resolve();
|
|
3039
2727
|
}
|
|
3040
|
-
}
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
else if (circ.units === 0 && typeof type.minSpeed !== 'undefined')
|
|
3073
|
-
circ.speed = Math.max(speed, type.minSpeed);
|
|
3074
|
-
}
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
|
|
2732
|
+
outn.response = IntelliCenterBoard.getAckResponse(168);
|
|
2733
|
+
outn.retries = 5;
|
|
2734
|
+
await outn.sendAsync();
|
|
2735
|
+
// We have been successful so lets set our pump with the new data.
|
|
2736
|
+
pump = sys.pumps.getItemById(id, true);
|
|
2737
|
+
spump = state.pumps.getItemById(id, true);
|
|
2738
|
+
if (typeof data.name !== 'undefined') spump.name = pump.name = data.name;
|
|
2739
|
+
spump.type = pump.type = ntype;
|
|
2740
|
+
if (type.name !== 'ss') {
|
|
2741
|
+
if (typeof data.circuits !== 'undefined') {
|
|
2742
|
+
// Set all the circuits
|
|
2743
|
+
for (let i = 0; i < 8; i++) {
|
|
2744
|
+
if (i >= data.circuits.length) pump.circuits.removeItemByIndex(i);
|
|
2745
|
+
else {
|
|
2746
|
+
let c = data.circuits[i];
|
|
2747
|
+
let circuitId = typeof c.circuit !== 'undefined' ? parseInt(c.circuit, 10) : pump.circuits.getItemById(i, false).circuit;
|
|
2748
|
+
let circ = pump.circuits.getItemByIndex(i, true);
|
|
2749
|
+
circ.circuit = circuitId;
|
|
2750
|
+
circ.units = parseInt(c.units || circ.units, 10);
|
|
2751
|
+
let speed = parseInt(c.speed, 10);
|
|
2752
|
+
let flow = parseInt(c.flow, 10);
|
|
2753
|
+
if (isNaN(speed)) speed = type.minSpeed || 0;
|
|
2754
|
+
if (isNaN(flow)) flow = type.minFlow || 0;
|
|
2755
|
+
//console.log({ flow: flow, speed: speed, type: JSON.stringify(type) });
|
|
2756
|
+
if (circ.units === 1 && typeof type.minFlow !== 'undefined')
|
|
2757
|
+
circ.flow = Math.max(flow, type.minFlow);
|
|
2758
|
+
else if (circ.units === 0 && typeof type.minSpeed !== 'undefined')
|
|
2759
|
+
circ.speed = Math.max(speed, type.minSpeed);
|
|
3077
2760
|
}
|
|
3078
|
-
state.emitEquipmentChanges();
|
|
3079
|
-
resolve();
|
|
3080
2761
|
}
|
|
3081
|
-
}
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
return
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
state.emitEquipmentChanges();
|
|
2765
|
+
return sys.pumps.getItemById(id);
|
|
3085
2766
|
}
|
|
3086
2767
|
catch (err) { return Promise.reject(err); }
|
|
3087
2768
|
}
|
|
@@ -3111,30 +2792,20 @@ class IntelliCenterPumpCommands extends PumpCommands {
|
|
|
3111
2792
|
outn.appendPayloadString('Pump -' + (id + 1), 16);
|
|
3112
2793
|
// We now have our messages. Let's send them off and update our values.
|
|
3113
2794
|
try {
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
spump.emitEquipmentChange();
|
|
2795
|
+
outc.retries = 5;
|
|
2796
|
+
outc.response = IntelliCenterBoard.getAckResponse(168);
|
|
2797
|
+
await outc.sendAsync();
|
|
2798
|
+
let spump = state.pumps.getItemById(id);
|
|
2799
|
+
sys.pumps.removeItemById(id);
|
|
2800
|
+
state.pumps.removeItemById(id);
|
|
2801
|
+
spump.isActive = false;
|
|
2802
|
+
spump.emitEquipmentChange();
|
|
3123
2803
|
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
outn.response = IntelliCenterBoard.getAckResponse(168);
|
|
3130
|
-
outn.retries = 2;
|
|
3131
|
-
outn.onComplete = (err) => {
|
|
3132
|
-
state.emitEquipmentChanges();
|
|
3133
|
-
resolve();
|
|
3134
|
-
};
|
|
3135
|
-
conn.queueSendMessage(outn);
|
|
3136
|
-
});
|
|
3137
|
-
return Promise.resolve(pump);
|
|
2804
|
+
outn.response = IntelliCenterBoard.getAckResponse(168);
|
|
2805
|
+
outn.retries = 2;
|
|
2806
|
+
await outn.sendAsync();
|
|
2807
|
+
state.emitEquipmentChanges();
|
|
2808
|
+
return pump;
|
|
3138
2809
|
} catch (err) { return Promise.reject(err); }
|
|
3139
2810
|
}
|
|
3140
2811
|
}
|
|
@@ -3184,35 +2855,29 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3184
2855
|
bhs.body1.heatSetpoint, bhs.body1.coolSetpoint, bhs.body2.heatSetpoint, bhs.body2.coolSetpoint, bhs.body1.heatMode, bhs.body2.heatMode, 0, 0, 15,
|
|
3185
2856
|
sys.general.options.pumpDelay ? 1 : 0, sys.general.options.cooldownDelay ? 1 : 0, 0, 100, 0, 0, 0, 0, sys.general.options.manualPriority ? 1 : 0, sys.general.options.manualHeat ? 1 : 0, 0
|
|
3186
2857
|
];
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
onComplete: (err, msg) => {
|
|
3194
|
-
bhs.processing = false;
|
|
3195
|
-
if (err) reject(err);
|
|
3196
|
-
else {
|
|
3197
|
-
let body1 = sys.bodies.getItemById(1);
|
|
3198
|
-
let sbody1 = state.temps.bodies.getItemById(1);
|
|
3199
|
-
body1.heatMode = sbody1.heatMode = bhs.body1.heatMode;
|
|
3200
|
-
body1.heatSetpoint = sbody1.heatSetpoint = bhs.body1.heatSetpoint;
|
|
3201
|
-
body1.coolSetpoint = sbody1.coolSetpoint = bhs.body1.coolSetpoint;
|
|
3202
|
-
if (sys.equipment.dual || sys.equipment.shared) {
|
|
3203
|
-
let body2 = sys.bodies.getItemById(2);
|
|
3204
|
-
let sbody2 = state.temps.bodies.getItemById(2);
|
|
3205
|
-
body2.heatMode = sbody2.heatMode = bhs.body2.heatMode;
|
|
3206
|
-
body2.heatSetpoint = sbody2.heatSetpoint = bhs.body2.heatSetpoint;
|
|
3207
|
-
body2.coolSetpoint = sbody2.coolSetpoint = bhs.body2.coolSetpoint;
|
|
3208
|
-
}
|
|
3209
|
-
state.emitEquipmentChanges();
|
|
3210
|
-
resolve(true);
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
});
|
|
3214
|
-
conn.queueSendMessage(out);
|
|
2858
|
+
|
|
2859
|
+
let out = Outbound.create({
|
|
2860
|
+
action: 168,
|
|
2861
|
+
payload: payload,
|
|
2862
|
+
retries: 2,
|
|
2863
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
3215
2864
|
});
|
|
2865
|
+
await out.sendAsync();
|
|
2866
|
+
let body1 = sys.bodies.getItemById(1);
|
|
2867
|
+
let sbody1 = state.temps.bodies.getItemById(1);
|
|
2868
|
+
body1.heatMode = sbody1.heatMode = bhs.body1.heatMode;
|
|
2869
|
+
body1.heatSetpoint = sbody1.heatSetpoint = bhs.body1.heatSetpoint;
|
|
2870
|
+
body1.coolSetpoint = sbody1.coolSetpoint = bhs.body1.coolSetpoint;
|
|
2871
|
+
if (sys.equipment.dual || sys.equipment.shared) {
|
|
2872
|
+
let body2 = sys.bodies.getItemById(2);
|
|
2873
|
+
let sbody2 = state.temps.bodies.getItemById(2);
|
|
2874
|
+
body2.heatMode = sbody2.heatMode = bhs.body2.heatMode;
|
|
2875
|
+
body2.heatSetpoint = sbody2.heatSetpoint = bhs.body2.heatSetpoint;
|
|
2876
|
+
body2.coolSetpoint = sbody2.coolSetpoint = bhs.body2.coolSetpoint;
|
|
2877
|
+
}
|
|
2878
|
+
bhs.processing = false;
|
|
2879
|
+
state.emitEquipmentChanges();
|
|
2880
|
+
return true;
|
|
3216
2881
|
}
|
|
3217
2882
|
else {
|
|
3218
2883
|
// Try every second to re-try if we have a bunch at once.
|
|
@@ -3248,61 +2913,48 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3248
2913
|
}
|
|
3249
2914
|
try {
|
|
3250
2915
|
if (typeof obj.name === 'string' && obj.name !== body.name) {
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
response: IntelliCenterBoard.getAckResponse(168),
|
|
3257
|
-
onComplete: (err, msg) => {
|
|
3258
|
-
if (err) reject(err);
|
|
3259
|
-
else { body.name = obj.name; resolve(body); }
|
|
3260
|
-
}
|
|
3261
|
-
});
|
|
3262
|
-
out.appendPayloadString(obj.name, 16);
|
|
3263
|
-
conn.queueSendMessage(out);
|
|
2916
|
+
let out = Outbound.create({
|
|
2917
|
+
action: 168,
|
|
2918
|
+
payload: [13, 0, byte],
|
|
2919
|
+
retries: 5,
|
|
2920
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
3264
2921
|
});
|
|
2922
|
+
|
|
2923
|
+
out.appendPayloadString(obj.name, 16);
|
|
2924
|
+
await out.sendAsync();
|
|
2925
|
+
body.name = obj.name;
|
|
3265
2926
|
}
|
|
3266
2927
|
if (typeof obj.capacity !== 'undefined') {
|
|
3267
2928
|
let cap = parseInt(obj.capacity, 10);
|
|
3268
2929
|
if (cap !== body.capacity) {
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
payload: [13, 0, byte + 4, Math.floor(cap / 1000)],
|
|
3275
|
-
onComplete: (err, msg) => {
|
|
3276
|
-
if (err) reject(err);
|
|
3277
|
-
else { body.capacity = cap; resolve(); }
|
|
3278
|
-
}
|
|
3279
|
-
});
|
|
3280
|
-
conn.queueSendMessage(out);
|
|
2930
|
+
let out = Outbound.create({
|
|
2931
|
+
action: 168,
|
|
2932
|
+
retries: 2,
|
|
2933
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
2934
|
+
payload: [13, 0, byte + 4, Math.floor(cap / 1000)]
|
|
3281
2935
|
});
|
|
2936
|
+
await out.sendAsync();
|
|
2937
|
+
body.capacity = cap;
|
|
3282
2938
|
}
|
|
3283
2939
|
}
|
|
3284
2940
|
if (typeof obj.manualHeat !== 'undefined') {
|
|
3285
2941
|
let manHeat = utils.makeBool(obj.manualHeat);
|
|
3286
2942
|
if (manHeat !== body.manualHeat) {
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
payload: [13, 0, byte + 8, manHeat ? 1 : 0],
|
|
3291
|
-
onComplete: (err, msg) => {
|
|
3292
|
-
if (err) reject(err);
|
|
3293
|
-
else { body.manualHeat = manHeat; resolve(); }
|
|
3294
|
-
}
|
|
3295
|
-
});
|
|
3296
|
-
conn.queueSendMessage(out);
|
|
2943
|
+
let out = Outbound.create({
|
|
2944
|
+
action: 168,
|
|
2945
|
+
payload: [13, 0, byte + 8, manHeat ? 1 : 0]
|
|
3297
2946
|
});
|
|
2947
|
+
await out.sendAsync();
|
|
2948
|
+
body.manualHeat = manHeat;
|
|
3298
2949
|
}
|
|
3299
2950
|
}
|
|
3300
|
-
if (typeof obj.
|
|
2951
|
+
if (typeof obj.showInDashboard !== 'undefined') {
|
|
3301
2952
|
let sbody = state.temps.bodies.getItemById(id, false);
|
|
3302
2953
|
body.showInDashboard = sbody.showInDashboard = utils.makeBool(obj.showInDashboard);
|
|
3303
2954
|
}
|
|
3304
|
-
return
|
|
2955
|
+
return body;
|
|
3305
2956
|
}
|
|
2957
|
+
|
|
3306
2958
|
catch (err) { return Promise.reject(err); }
|
|
3307
2959
|
}
|
|
3308
2960
|
public async setHeatModeAsync(body: Body, mode: number): Promise<BodyTempState> {
|
|
@@ -3311,23 +2963,23 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3311
2963
|
await this.queueBodyHeatSettings(body.id, body.id === 2 ? 23 : 22, { heatMode: mode });
|
|
3312
2964
|
return state.temps.bodies.getItemById(body.id);
|
|
3313
2965
|
/*
|
|
3314
|
-
|
|
2966
|
+
|
|
3315
2967
|
let byte2 = 22;
|
|
3316
2968
|
let body1 = sys.bodies.getItemById(1);
|
|
3317
2969
|
let body2 = sys.bodies.getItemById(2);
|
|
3318
|
-
|
|
2970
|
+
|
|
3319
2971
|
let heat1 = body1.heatSetpoint || 78;
|
|
3320
2972
|
let cool1 = body1.coolSetpoint || 100;
|
|
3321
2973
|
let heat2 = body2.heatSetpoint || 78;
|
|
3322
2974
|
let cool2 = body2.coolSetpoint || 103;
|
|
3323
|
-
|
|
2975
|
+
|
|
3324
2976
|
let mode1 = body1.heatMode || 1;
|
|
3325
2977
|
let mode2 = body2.heatMode || 1;
|
|
3326
2978
|
let bitopts = 0;
|
|
3327
2979
|
if (sys.general.options.clockSource) bitopts += 32;
|
|
3328
2980
|
if (sys.general.options.clockMode === 24) bitopts += 64;
|
|
3329
2981
|
if (sys.general.options.adjustDST) bitopts += 128;
|
|
3330
|
-
|
|
2982
|
+
|
|
3331
2983
|
switch (body.id) {
|
|
3332
2984
|
case 1:
|
|
3333
2985
|
byte2 = 22;
|
|
@@ -3357,7 +3009,7 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3357
3009
|
}
|
|
3358
3010
|
}
|
|
3359
3011
|
})
|
|
3360
|
-
|
|
3012
|
+
await out.sendAsync();
|
|
3361
3013
|
});
|
|
3362
3014
|
*/
|
|
3363
3015
|
}
|
|
@@ -3409,7 +3061,7 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3409
3061
|
resolve(bstate);
|
|
3410
3062
|
}
|
|
3411
3063
|
};
|
|
3412
|
-
|
|
3064
|
+
await out.sendAsync();
|
|
3413
3065
|
});
|
|
3414
3066
|
*/
|
|
3415
3067
|
}
|
|
@@ -3461,7 +3113,7 @@ class IntelliCenterBodyCommands extends BodyCommands {
|
|
|
3461
3113
|
resolve(bstate);
|
|
3462
3114
|
}
|
|
3463
3115
|
};
|
|
3464
|
-
|
|
3116
|
+
await out.sendAsync();
|
|
3465
3117
|
});
|
|
3466
3118
|
*/
|
|
3467
3119
|
}
|
|
@@ -3539,37 +3191,32 @@ class IntelliCenterScheduleCommands extends ScheduleCommands {
|
|
|
3539
3191
|
],
|
|
3540
3192
|
0
|
|
3541
3193
|
);
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
}
|
|
3569
|
-
else reject(err);
|
|
3570
|
-
};
|
|
3571
|
-
conn.queueSendMessage(out); // Send it off in a letter to yourself.
|
|
3572
|
-
});
|
|
3194
|
+
|
|
3195
|
+
out.response = IntelliCenterBoard.getAckResponse(168);
|
|
3196
|
+
out.retries = 5;
|
|
3197
|
+
|
|
3198
|
+
await out.sendAsync(); // Send it off in a letter to yourself.
|
|
3199
|
+
sched = sys.schedules.getItemById(id, true);
|
|
3200
|
+
ssched = state.schedules.getItemById(id, true);
|
|
3201
|
+
sched.circuit = ssched.circuit = circuit;
|
|
3202
|
+
sched.scheduleDays = ssched.scheduleDays = schedDays;
|
|
3203
|
+
sched.scheduleType = ssched.scheduleType = schedType;
|
|
3204
|
+
sched.heatSetpoint = ssched.heatSetpoint = heatSetpoint;
|
|
3205
|
+
sched.coolSetpoint = ssched.coolSetpoint = coolSetpoint;
|
|
3206
|
+
sched.heatSource = ssched.heatSource = heatSource;
|
|
3207
|
+
sched.startTime = ssched.startTime = startTime;
|
|
3208
|
+
sched.endTime = ssched.endTime = endTime;
|
|
3209
|
+
sched.startTimeType = ssched.startTimeType = startTimeType;
|
|
3210
|
+
sched.endTimeType = ssched.endTimeType = endTimeType;
|
|
3211
|
+
sched.startDate = ssched.startDate = startDate;
|
|
3212
|
+
sched.startMonth = startDate.getMonth() + 1;
|
|
3213
|
+
sched.startYear = startDate.getFullYear();
|
|
3214
|
+
sched.startDay = startDate.getDate();
|
|
3215
|
+
ssched.startDate = startDate;
|
|
3216
|
+
ssched.isActive = sched.isActive = true;
|
|
3217
|
+
ssched.display = sched.display = display;
|
|
3218
|
+
ssched.emitEquipmentChange();
|
|
3219
|
+
return sched;
|
|
3573
3220
|
}
|
|
3574
3221
|
else
|
|
3575
3222
|
return Promise.reject(new InvalidEquipmentIdError('No schedule information provided', undefined, 'Schedule'));
|
|
@@ -3605,19 +3252,13 @@ class IntelliCenterScheduleCommands extends ScheduleCommands {
|
|
|
3605
3252
|
retries: 5,
|
|
3606
3253
|
response: IntelliCenterBoard.getAckResponse(168)
|
|
3607
3254
|
});
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
resolve(sched);
|
|
3616
|
-
}
|
|
3617
|
-
else reject(err);
|
|
3618
|
-
};
|
|
3619
|
-
conn.queueSendMessage(out);
|
|
3620
|
-
});
|
|
3255
|
+
|
|
3256
|
+
await out.sendAsync();
|
|
3257
|
+
sys.schedules.removeItemById(id);
|
|
3258
|
+
state.schedules.removeItemById(id);
|
|
3259
|
+
ssched.emitEquipmentChange();
|
|
3260
|
+
ssched.isActive = sched.isActive = false;
|
|
3261
|
+
return sched;
|
|
3621
3262
|
|
|
3622
3263
|
}
|
|
3623
3264
|
else
|
|
@@ -3630,179 +3271,164 @@ class IntelliCenterHeaterCommands extends HeaterCommands {
|
|
|
3630
3271
|
private createHeaterConfigMessage(heater: Heater): Outbound {
|
|
3631
3272
|
let out = Outbound.createMessage(
|
|
3632
3273
|
168, [10, 0, heater.id, heater.type, heater.body, heater.differentialTemp, heater.startTempDelta, heater.stopTempDelta, heater.coolingEnabled ? 1 : 0,
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3274
|
+
heater.cooldownDelay || 6, heater.address,
|
|
3275
|
+
//, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // Name
|
|
3276
|
+
heater.efficiencyMode, heater.maxBoostTemp, heater.economyTime], 0);
|
|
3636
3277
|
out.insertPayloadString(11, heater.name, 16);
|
|
3637
3278
|
return out;
|
|
3638
3279
|
}
|
|
3639
|
-
public setHeater(heater: Heater, obj?: any) {
|
|
3280
|
+
public async setHeater(heater: Heater, obj?: any) {
|
|
3640
3281
|
super.setHeater(heater, obj);
|
|
3641
3282
|
let out = this.createHeaterConfigMessage(heater);
|
|
3642
|
-
|
|
3283
|
+
await out.sendAsync();
|
|
3643
3284
|
}
|
|
3644
3285
|
public async setHeaterAsync(obj: any): Promise<Heater> {
|
|
3645
3286
|
if (obj.master === 1 || parseInt(obj.id, 10) > 255) return super.setHeaterAsync(obj);
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
if (
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
if (
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
}
|
|
3725
|
-
|
|
3726
|
-
let out = Outbound.create({
|
|
3727
|
-
action: 168,
|
|
3728
|
-
payload: [10, 0, heater.id - 1,
|
|
3729
|
-
type,
|
|
3730
|
-
body,
|
|
3731
|
-
cooldownDelay,
|
|
3732
|
-
startTempDelta,
|
|
3733
|
-
stopTempDelta,
|
|
3734
|
-
(typeof obj.coolingEnabled !== 'undefined' ? utils.makeBool(obj.coolingEnabled) : utils.makeBool(heater.coolingEnabled)) ? 1 : 0,
|
|
3735
|
-
differentialTemp,
|
|
3736
|
-
address
|
|
3737
|
-
],
|
|
3738
|
-
retries: 5,
|
|
3739
|
-
response: IntelliCenterBoard.getAckResponse(168)
|
|
3740
|
-
});
|
|
3741
|
-
out.appendPayloadString(obj.name || heater.name, 16);
|
|
3742
|
-
out.appendPayloadByte(efficiencyMode);
|
|
3743
|
-
out.appendPayloadByte(maxBoostTemp);
|
|
3744
|
-
out.appendPayloadByte(economyTime);
|
|
3745
|
-
out.onComplete = (err, msg) => {
|
|
3746
|
-
if (err) reject(err);
|
|
3747
|
-
else {
|
|
3748
|
-
heater = sys.heaters.getItemById(heater.id, true);
|
|
3749
|
-
let hstate = state.heaters.getItemById(heater.id, true);
|
|
3750
|
-
hstate.type = heater.type = type;
|
|
3751
|
-
heater.body = body;
|
|
3752
|
-
heater.address = address;
|
|
3753
|
-
hstate.name = heater.name = obj.name || heater.name;
|
|
3754
|
-
heater.coolingEnabled = typeof obj.coolingEnabled !== 'undefined' ? utils.makeBool(obj.coolingEnabled) : utils.makeBool(heater.coolingEnabled);
|
|
3755
|
-
heater.differentialTemp = differentialTemp;
|
|
3756
|
-
heater.economyTime = economyTime;
|
|
3757
|
-
heater.startTempDelta = startTempDelta;
|
|
3758
|
-
heater.stopTempDelta = stopTempDelta;
|
|
3759
|
-
heater.cooldownDelay = cooldownDelay;
|
|
3760
|
-
sys.board.heaters.updateHeaterServices();
|
|
3761
|
-
sys.board.heaters.syncHeaterStates();
|
|
3762
|
-
resolve(heater);
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3765
|
-
};
|
|
3766
|
-
conn.queueSendMessage(out);
|
|
3287
|
+
let id = typeof obj.id === 'undefined' ? -1 : parseInt(obj.id, 10);
|
|
3288
|
+
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError('Heater Id is not valid.', obj.id, 'Heater'));
|
|
3289
|
+
let heater: Heater;
|
|
3290
|
+
if (id <= 0) {
|
|
3291
|
+
// We are adding a heater. In this case we need to find the first id slot that is empty.
|
|
3292
|
+
id = sys.heaters.getNextEquipmentId(new EquipmentIdRange(1, 16));
|
|
3293
|
+
}
|
|
3294
|
+
heater = sys.heaters.getItemById(id, false);
|
|
3295
|
+
let type = 0;
|
|
3296
|
+
if (typeof obj.type === 'undefined' && (heater.type === 0 || typeof heater.type === 'undefined')) return Promise.reject(new InvalidEquipmentDataError(`Heater type was not specified for new heater`, 'Heater', obj.type));
|
|
3297
|
+
else {
|
|
3298
|
+
// We only get here if the type was not previously defined.
|
|
3299
|
+
if (typeof obj.type === 'string' && isNaN(parseInt(obj.type, 10)))
|
|
3300
|
+
type = sys.board.valueMaps.heaterTypes.getValue(obj.type);
|
|
3301
|
+
else
|
|
3302
|
+
type = parseInt(obj.type, 10);
|
|
3303
|
+
if (!sys.board.valueMaps.heaterTypes.valExists(type)) return Promise.reject(new InvalidEquipmentDataError(`Heater type was not specified for new heater`, 'Heater', obj.type));
|
|
3304
|
+
heater.type = type;
|
|
3305
|
+
}
|
|
3306
|
+
let htype = sys.board.valueMaps.heaterTypes.transform(type);
|
|
3307
|
+
let address = heater.address || 112;
|
|
3308
|
+
if (htype.hasAddress) {
|
|
3309
|
+
if (typeof obj.address !== 'undefined') {
|
|
3310
|
+
address = parseInt(obj.address, 10);
|
|
3311
|
+
if (isNaN(address) || address < 112 || address > 128) return Promise.reject(new InvalidEquipmentDataError(`Invalid Heater address was specified`, 'Heater', obj.address));
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
let differentialTemp = heater.differentialTemp || 6;
|
|
3315
|
+
if (typeof obj.differentialTemp !== 'undefined') {
|
|
3316
|
+
differentialTemp = parseInt(obj.differentialTemp, 10);
|
|
3317
|
+
if (isNaN(differentialTemp) || differentialTemp < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Differential Temp was specified`, 'Heater', obj.differentialTemp));
|
|
3318
|
+
}
|
|
3319
|
+
let efficiencyMode = heater.efficiencyMode || 0;
|
|
3320
|
+
if (typeof obj.efficiencyMode !== 'undefined') {
|
|
3321
|
+
efficiencyMode = parseInt(obj.efficiencyMode, 10);
|
|
3322
|
+
if (isNaN(efficiencyMode) || efficiencyMode < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Efficiency Mode was specified`, 'Heater', obj.efficiencyMode));
|
|
3323
|
+
}
|
|
3324
|
+
let maxBoostTemp = heater.maxBoostTemp || 0;
|
|
3325
|
+
if (typeof obj.maxBoostTemp !== 'undefined') {
|
|
3326
|
+
maxBoostTemp = parseInt(obj.maxBoostTemp, 10);
|
|
3327
|
+
if (isNaN(maxBoostTemp) || maxBoostTemp < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Max Boost Temp was specified`, 'Heater', obj.maxBoostTemp));
|
|
3328
|
+
}
|
|
3329
|
+
let startTempDelta = heater.startTempDelta || 5;
|
|
3330
|
+
if (typeof obj.startTempDelta !== 'undefined') {
|
|
3331
|
+
startTempDelta = parseInt(obj.startTempDelta, 10);
|
|
3332
|
+
if (isNaN(startTempDelta) || startTempDelta < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Start Temp Delta was specified`, 'Heater', obj.startTempDelta));
|
|
3333
|
+
}
|
|
3334
|
+
let stopTempDelta = heater.stopTempDelta || 3;
|
|
3335
|
+
if (typeof obj.stopTempDelta !== 'undefined') {
|
|
3336
|
+
stopTempDelta = parseInt(obj.stopTempDelta, 10);
|
|
3337
|
+
if (isNaN(stopTempDelta) || stopTempDelta < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Stop Temp Delta was specified`, 'Heater', obj.stopTempDelta));
|
|
3338
|
+
}
|
|
3339
|
+
let economyTime = heater.economyTime || 1;
|
|
3340
|
+
if (typeof obj.economyTime !== 'undefined') {
|
|
3341
|
+
economyTime = parseInt(obj.economyTime, 10);
|
|
3342
|
+
if (isNaN(economyTime) || economyTime < 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid Economy Time was specified`, 'Heater', obj.economyTime));
|
|
3343
|
+
}
|
|
3344
|
+
let body = heater.body || 0;
|
|
3345
|
+
if (typeof obj.body !== 'undefined') {
|
|
3346
|
+
body = parseInt(obj.body, 10);
|
|
3347
|
+
if (isNaN(obj.body) && typeof obj.body === 'string') body = sys.board.valueMaps.bodies.getValue(obj.body);
|
|
3348
|
+
if (typeof body === 'undefined' || isNaN(body)) return Promise.reject(new InvalidEquipmentDataError(`Invalid Body was specified`, 'Heater', obj.body));
|
|
3349
|
+
}
|
|
3350
|
+
if (htype.hasAddress) {
|
|
3351
|
+
if (isNaN(address) || address < 112 || address > 128) return Promise.reject(new InvalidEquipmentDataError(`Invalid Heater address was specified`, 'Heater', obj.address));
|
|
3352
|
+
for (let i = 0; i < sys.heaters.length; i++) {
|
|
3353
|
+
let h = sys.heaters.getItemByIndex(i);
|
|
3354
|
+
if (h.id === id) continue;
|
|
3355
|
+
let t = sys.board.valueMaps.heaterTypes.transform(h.type);
|
|
3356
|
+
if (!t.hasAddress) continue;
|
|
3357
|
+
if (h.address === address) return Promise.reject(new InvalidEquipmentDataError(`Heater id# ${h.id} ${t.desc} is already communicating on this address.`, 'Heater', obj.address));
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
let cooldownDelay = heater.cooldownDelay || 5;
|
|
3361
|
+
if (typeof obj.cooldownDelay !== 'undefined') {
|
|
3362
|
+
cooldownDelay = parseInt(obj.cooldownDelay, 10);
|
|
3363
|
+
if (isNaN(cooldownDelay) || cooldownDelay < 0 || cooldownDelay > 20) return Promise.reject(new InvalidEquipmentDataError(`Invalid cooldown delay was specified`, 'Heater', obj.cooldownDelay));
|
|
3364
|
+
}
|
|
3767
3365
|
|
|
3366
|
+
let out = Outbound.create({
|
|
3367
|
+
action: 168,
|
|
3368
|
+
payload: [10, 0, heater.id - 1,
|
|
3369
|
+
type,
|
|
3370
|
+
body,
|
|
3371
|
+
cooldownDelay,
|
|
3372
|
+
startTempDelta,
|
|
3373
|
+
stopTempDelta,
|
|
3374
|
+
(typeof obj.coolingEnabled !== 'undefined' ? utils.makeBool(obj.coolingEnabled) : utils.makeBool(heater.coolingEnabled)) ? 1 : 0,
|
|
3375
|
+
differentialTemp,
|
|
3376
|
+
address
|
|
3377
|
+
],
|
|
3378
|
+
retries: 5,
|
|
3379
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
3768
3380
|
});
|
|
3381
|
+
out.appendPayloadString(obj.name || heater.name, 16);
|
|
3382
|
+
out.appendPayloadByte(efficiencyMode);
|
|
3383
|
+
out.appendPayloadByte(maxBoostTemp);
|
|
3384
|
+
out.appendPayloadByte(economyTime);
|
|
3385
|
+
|
|
3386
|
+
await out.sendAsync();
|
|
3387
|
+
heater = sys.heaters.getItemById(heater.id, true);
|
|
3388
|
+
let hstate = state.heaters.getItemById(heater.id, true);
|
|
3389
|
+
hstate.type = heater.type = type;
|
|
3390
|
+
heater.body = body;
|
|
3391
|
+
heater.address = address;
|
|
3392
|
+
hstate.name = heater.name = obj.name || heater.name;
|
|
3393
|
+
heater.coolingEnabled = typeof obj.coolingEnabled !== 'undefined' ? utils.makeBool(obj.coolingEnabled) : utils.makeBool(heater.coolingEnabled);
|
|
3394
|
+
heater.differentialTemp = differentialTemp;
|
|
3395
|
+
heater.economyTime = economyTime;
|
|
3396
|
+
heater.startTempDelta = startTempDelta;
|
|
3397
|
+
heater.stopTempDelta = stopTempDelta;
|
|
3398
|
+
heater.cooldownDelay = cooldownDelay;
|
|
3399
|
+
sys.board.heaters.updateHeaterServices();
|
|
3400
|
+
sys.board.heaters.syncHeaterStates();
|
|
3401
|
+
return heater;
|
|
3769
3402
|
}
|
|
3770
3403
|
public async deleteHeaterAsync(obj): Promise<Heater> {
|
|
3771
3404
|
if (obj.master === 1 || parseInt(obj.id, 10) > 255) return await super.deleteHeaterAsync(obj);
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
response: IntelliCenterBoard.getAckResponse(168)
|
|
3790
|
-
});
|
|
3791
|
-
out.appendPayloadString('', 16);
|
|
3792
|
-
out.appendPayloadByte(3);
|
|
3793
|
-
out.appendPayloadByte(5);
|
|
3794
|
-
out.appendPayloadByte(1);
|
|
3795
|
-
out.onComplete = (err, msg) => {
|
|
3796
|
-
if (err) reject(err);
|
|
3797
|
-
else {
|
|
3798
|
-
heater.isActive = false;
|
|
3799
|
-
sys.heaters.removeItemById(id);
|
|
3800
|
-
state.heaters.removeItemById(id);
|
|
3801
|
-
resolve(heater);
|
|
3802
|
-
}
|
|
3803
|
-
};
|
|
3804
|
-
conn.queueSendMessage(out);
|
|
3405
|
+
let id = parseInt(obj.id, 10);
|
|
3406
|
+
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError('Cannot delete. Heater Id is not valid.', obj.id, 'Heater'));
|
|
3407
|
+
let heater = sys.heaters.getItemById(id);
|
|
3408
|
+
let out = Outbound.create({
|
|
3409
|
+
action: 168,
|
|
3410
|
+
payload: [10, 0, heater.id - 1,
|
|
3411
|
+
0,
|
|
3412
|
+
1,
|
|
3413
|
+
5,
|
|
3414
|
+
5,
|
|
3415
|
+
3,
|
|
3416
|
+
0,
|
|
3417
|
+
6,
|
|
3418
|
+
112
|
|
3419
|
+
],
|
|
3420
|
+
retries: 5,
|
|
3421
|
+
response: IntelliCenterBoard.getAckResponse(168)
|
|
3805
3422
|
});
|
|
3423
|
+
out.appendPayloadString('', 16);
|
|
3424
|
+
out.appendPayloadByte(3);
|
|
3425
|
+
out.appendPayloadByte(5);
|
|
3426
|
+
out.appendPayloadByte(1);
|
|
3427
|
+
await out.sendAsync();
|
|
3428
|
+
heater.isActive = false;
|
|
3429
|
+
sys.heaters.removeItemById(id);
|
|
3430
|
+
state.heaters.removeItemById(id);
|
|
3431
|
+
return heater;
|
|
3806
3432
|
}
|
|
3807
3433
|
public updateHeaterServices() {
|
|
3808
3434
|
let htypes = sys.board.heaters.getInstalledHeaterTypes();
|
|
@@ -3823,6 +3449,10 @@ class IntelliCenterHeaterCommands extends HeaterCommands {
|
|
|
3823
3449
|
// 4 = Solar Preferred
|
|
3824
3450
|
// 5 = UltraTemp Only
|
|
3825
3451
|
// 6 = UltraTemp Preferred???? This might be 22
|
|
3452
|
+
// 7 = Hybrid Gas Only
|
|
3453
|
+
// 8 = Hybrid Heatpump Only
|
|
3454
|
+
// 9 = Hybrid - Hybrid Mode
|
|
3455
|
+
// 10 = Hybrid - Dual Heat
|
|
3826
3456
|
// 9 = Heat Pump
|
|
3827
3457
|
// 25 = Heat Pump Preferred
|
|
3828
3458
|
// ?? = Hybrid
|
|
@@ -3835,8 +3465,22 @@ class IntelliCenterHeaterCommands extends HeaterCommands {
|
|
|
3835
3465
|
// 3 = Solar Heater
|
|
3836
3466
|
// 4 = Solar Preferred
|
|
3837
3467
|
// 5 = Heat Pump
|
|
3838
|
-
|
|
3839
3468
|
if (sys.heaters.length > 0) sys.board.valueMaps.heatSources = new byteValueMap([[1, { name: 'off', desc: 'Off' }]]);
|
|
3469
|
+
sys.board.valueMaps.heatModes = new byteValueMap([[1, { name: 'off', desc: 'Off' }]]);
|
|
3470
|
+
if (htypes.hybrid > 0) {
|
|
3471
|
+
sys.board.valueMaps.heatModes.merge([
|
|
3472
|
+
[7, { name: 'hybheat', desc: 'Gas Only' }],
|
|
3473
|
+
[8, { name: 'hybheatpump', desc: 'Heat Pump Only' }],
|
|
3474
|
+
[9, { name: 'hybhybrid', desc: 'Hybrid' }],
|
|
3475
|
+
[10, { name: 'hybdual', desc: 'Dual Heat' }]
|
|
3476
|
+
]);
|
|
3477
|
+
sys.board.valueMaps.heatSources.merge([
|
|
3478
|
+
[7, { name: 'hybheat', desc: 'Gas Only' }],
|
|
3479
|
+
[8, { name: 'hybheatpump', desc: 'Heat Pump Only' }],
|
|
3480
|
+
[9, { name: 'hybhybrid', desc: 'Hybrid' }],
|
|
3481
|
+
[10, { name: 'hybdual', desc: 'Dual Heat' }]
|
|
3482
|
+
]);
|
|
3483
|
+
}
|
|
3840
3484
|
if (gasHeaterInstalled) sys.board.valueMaps.heatSources.merge([[2, { name: 'heater', desc: 'Heater' }]]);
|
|
3841
3485
|
if (mastertempInstalled) sys.board.valueMaps.heatSources.merge([[11, { name: 'mtheater', desc: 'MasterTemp' }]]);
|
|
3842
3486
|
if (solarInstalled && (gasHeaterInstalled || heatPumpInstalled)) sys.board.valueMaps.heatSources.merge([[3, { name: 'solar', desc: 'Solar Only', hasCoolSetpoint: htypes.hasCoolSetpoint }], [4, { name: 'solarpref', desc: 'Solar Preferred', hasCoolSetpoint: htypes.hasCoolSetpoint }]]);
|
|
@@ -3847,7 +3491,6 @@ class IntelliCenterHeaterCommands extends HeaterCommands {
|
|
|
3847
3491
|
else if (ultratempInstalled) sys.board.valueMaps.heatSources.merge([[5, { name: 'ultratemp', desc: 'UltraTemp', hasCoolSetpoint: htypes.hasCoolSetpoint }]]);
|
|
3848
3492
|
sys.board.valueMaps.heatSources.merge([[0, { name: 'nochange', desc: 'No Change' }]]);
|
|
3849
3493
|
|
|
3850
|
-
sys.board.valueMaps.heatModes = new byteValueMap([[1, { name: 'off', desc: 'Off' }]]);
|
|
3851
3494
|
if (gasHeaterInstalled) sys.board.valueMaps.heatModes.merge([[2, { name: 'heater', desc: 'Heater' }]]);
|
|
3852
3495
|
if (mastertempInstalled) sys.board.valueMaps.heatModes.merge([[11, { name: 'mtheater', desc: 'MasterTemp' }]]);
|
|
3853
3496
|
if (solarInstalled && (gasHeaterInstalled || heatPumpInstalled || mastertempInstalled)) sys.board.valueMaps.heatModes.merge([[3, { name: 'solar', desc: 'Solar Only' }], [4, { name: 'solarpref', desc: 'Solar Preferred' }]]);
|
|
@@ -3861,7 +3504,7 @@ class IntelliCenterHeaterCommands extends HeaterCommands {
|
|
|
3861
3504
|
sys.board.valueMaps.heatSources = new byteValueMap([[0, { name: 'off', desc: 'Off' }]]);
|
|
3862
3505
|
if (gasHeaterInstalled) sys.board.valueMaps.heatSources.set(3, { name: 'heater', desc: 'Heater' });
|
|
3863
3506
|
if (solarInstalled && (gasHeaterInstalled || heatPumpInstalled)) sys.board.valueMaps.heatSources.merge([[5, { name: 'solar', desc: 'Solar Only' }], [21, { name: 'solarpref', desc: 'Solar Preferred' }]]);
|
|
3864
|
-
else if(solarInstalled) sys.board.valueMaps.heatSources.set(5, { name: 'solar', desc: 'Solar' });
|
|
3507
|
+
else if (solarInstalled) sys.board.valueMaps.heatSources.set(5, { name: 'solar', desc: 'Solar' });
|
|
3865
3508
|
if (heatPumpInstalled && (gasHeaterInstalled || solarInstalled)) sys.board.valueMaps.heatSources.merge([[9, { name: 'heatpump', desc: 'Heatpump Only' }], [25, { name: 'heatpumppref', desc: 'Heat Pump Pref' }]]);
|
|
3866
3509
|
else if (heatPumpInstalled) sys.board.valueMaps.heatSources.set(9, { name: 'heatpump', desc: 'Heat Pump' });
|
|
3867
3510
|
if (sys.heaters.length > 0) sys.board.valueMaps.heatSources.set(32, { name: 'nochange', desc: 'No Change' });
|
|
@@ -3894,25 +3537,18 @@ class IntelliCenterValveCommands extends ValveCommands {
|
|
|
3894
3537
|
// RKS: The valve messages are a bit unique since they are 0 based instead of 1s based. Our configuration includes
|
|
3895
3538
|
// the ability to set these valves appropriately via the interface by subtracting 1 from the circuit and the valve id. In
|
|
3896
3539
|
// shared body systems there is a gap for the additional intake/return valves that exist in i10d.
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
valve.type = v.type;
|
|
3910
|
-
resolve(valve);
|
|
3911
|
-
}
|
|
3912
|
-
}
|
|
3913
|
-
}).appendPayloadString(v.name, 16);
|
|
3914
|
-
conn.queueSendMessage(out);
|
|
3915
|
-
});
|
|
3540
|
+
let v = extend(true, valve.get(true), obj);
|
|
3541
|
+
let out = Outbound.create({
|
|
3542
|
+
action: 168,
|
|
3543
|
+
payload: [9, 0, v.id - 1, v.circuit - 1],
|
|
3544
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
3545
|
+
retries: 5
|
|
3546
|
+
}).appendPayloadString(v.name, 16);
|
|
3547
|
+
await out.sendAsync();
|
|
3548
|
+
valve.name = v.name;
|
|
3549
|
+
valve.circuit = v.circuit;
|
|
3550
|
+
valve.type = v.type;
|
|
3551
|
+
return valve;
|
|
3916
3552
|
}
|
|
3917
3553
|
}
|
|
3918
3554
|
export class IntelliCenterChemControllerCommands extends ChemControllerCommands {
|
|
@@ -3988,102 +3624,89 @@ export class IntelliCenterChemControllerCommands extends ChemControllerCommands
|
|
|
3988
3624
|
//[255, 0, 255][165, 63, 15, 16, 168, 20][8, 0, 0, 32, 1, 144, 1, 248, 2, 144, 1, 1, 1, 29, 0, 0, 0, 100, 0, 0][4, 135]
|
|
3989
3625
|
//Us
|
|
3990
3626
|
//[255, 0, 255][165, 0, 15, 33, 168, 20][8, 0, 0, 32, 1, 144, 1, 248, 2, 144, 1, 1, 1, 33, 0, 0, 0, 100, 0, 0][4, 93]
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
//onAbort: () => { },
|
|
3999
|
-
onComplete: (err) => {
|
|
4000
|
-
if (err) reject(err);
|
|
4001
|
-
else {
|
|
4002
|
-
chem = sys.chemControllers.getItemById(data.id, true);
|
|
4003
|
-
schem = state.chemControllers.getItemById(data.id, true);
|
|
4004
|
-
chem.master = 0;
|
|
4005
|
-
// Copy the data back to the chem object.
|
|
4006
|
-
schem.name = chem.name = name;
|
|
4007
|
-
schem.type = chem.type = sys.board.valueMaps.chemControllerTypes.encode('intellichem');
|
|
4008
|
-
chem.calciumHardness = calciumHardness;
|
|
4009
|
-
chem.cyanuricAcid = cyanuricAcid;
|
|
4010
|
-
chem.alkalinity = alkalinity;
|
|
4011
|
-
chem.borates = borates;
|
|
4012
|
-
chem.body = schem.body = body;
|
|
4013
|
-
schem.isActive = chem.isActive = true;
|
|
4014
|
-
chem.lsiRange.enabled = lsiRange.enabled;
|
|
4015
|
-
chem.lsiRange.low = lsiRange.low;
|
|
4016
|
-
chem.lsiRange.high = lsiRange.high;
|
|
4017
|
-
chem.ph.tolerance.enabled = phTolerance.enabled;
|
|
4018
|
-
chem.ph.tolerance.low = phTolerance.low;
|
|
4019
|
-
chem.ph.tolerance.high = phTolerance.high;
|
|
4020
|
-
chem.orp.tolerance.enabled = orpTolerance.enabled;
|
|
4021
|
-
chem.orp.tolerance.low = orpTolerance.low;
|
|
4022
|
-
chem.orp.tolerance.high = orpTolerance.high;
|
|
4023
|
-
chem.ph.setpoint = pHSetpoint;
|
|
4024
|
-
chem.orp.setpoint = orpSetpoint;
|
|
4025
|
-
schem.siCalcType = chem.siCalcType = siCalcType;
|
|
4026
|
-
chem.address = schem.address = address;
|
|
4027
|
-
chem.name = schem.name = name;
|
|
4028
|
-
chem.flowSensor.enabled = false;
|
|
4029
|
-
resolve(chem);
|
|
4030
|
-
}
|
|
4031
|
-
}
|
|
4032
|
-
});
|
|
4033
|
-
|
|
4034
|
-
//[8, 0, chem.id - 1, body.val, 1, chem.address, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0]
|
|
4035
|
-
out.insertPayloadBytes(0, 0, 20);
|
|
4036
|
-
out.setPayloadByte(0, 8);
|
|
4037
|
-
out.setPayloadByte(1, 0);
|
|
4038
|
-
out.setPayloadByte(2, chem.id - 1);
|
|
4039
|
-
out.setPayloadByte(3, body.val);
|
|
4040
|
-
out.setPayloadByte(4, acidTankLevel + 1);
|
|
4041
|
-
out.setPayloadByte(5, address);
|
|
4042
|
-
out.setPayloadByte(6, 1);
|
|
4043
|
-
out.setPayloadInt(7, Math.round(pHSetpoint * 100), 700);
|
|
4044
|
-
out.setPayloadInt(9, orpSetpoint, 400);
|
|
4045
|
-
out.setPayloadByte(11, 1);
|
|
4046
|
-
out.setPayloadByte(12, 1);
|
|
4047
|
-
//out.setPayloadByte(11, acidTankLevel + 1, 1);
|
|
4048
|
-
//out.setPayloadByte(12, orpTankLevel + 1, 1);
|
|
4049
|
-
|
|
4050
|
-
out.setPayloadInt(13, calciumHardness, 25);
|
|
4051
|
-
out.setPayloadInt(15, cyanuricAcid, 0);
|
|
4052
|
-
out.setPayloadInt(17, alkalinity, 25);
|
|
4053
|
-
conn.queueSendMessage(out);
|
|
3627
|
+
let out = Outbound.create({
|
|
3628
|
+
protocol: Protocol.Broadcast,
|
|
3629
|
+
action: 168,
|
|
3630
|
+
payload: [],
|
|
3631
|
+
retries: 3, // We are going to try 4 times.
|
|
3632
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
3633
|
+
//onAbort: () => { },
|
|
4054
3634
|
});
|
|
3635
|
+
|
|
3636
|
+
//[8, 0, chem.id - 1, body.val, 1, chem.address, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0]
|
|
3637
|
+
out.insertPayloadBytes(0, 0, 20);
|
|
3638
|
+
out.setPayloadByte(0, 8);
|
|
3639
|
+
out.setPayloadByte(1, 0);
|
|
3640
|
+
out.setPayloadByte(2, chem.id - 1);
|
|
3641
|
+
out.setPayloadByte(3, body.val);
|
|
3642
|
+
//out.setPayloadByte(4, acidTankLevel + 1);
|
|
3643
|
+
out.setPayloadByte(4, 1);
|
|
3644
|
+
out.setPayloadByte(5, address);
|
|
3645
|
+
out.setPayloadByte(6, 1);
|
|
3646
|
+
out.setPayloadInt(7, Math.round(pHSetpoint * 100), 700);
|
|
3647
|
+
out.setPayloadInt(9, orpSetpoint, 400);
|
|
3648
|
+
//out.setPayloadByte(11, 1);
|
|
3649
|
+
//out.setPayloadByte(12, 1);
|
|
3650
|
+
out.setPayloadByte(11, acidTankLevel + 1, 1);
|
|
3651
|
+
out.setPayloadByte(12, orpTankLevel + 1, 1);
|
|
3652
|
+
|
|
3653
|
+
out.setPayloadInt(13, calciumHardness, 25);
|
|
3654
|
+
out.setPayloadInt(15, cyanuricAcid, 0);
|
|
3655
|
+
out.setPayloadInt(17, alkalinity, 25);
|
|
3656
|
+
await out.sendAsync();
|
|
3657
|
+
chem = sys.chemControllers.getItemById(data.id, true);
|
|
3658
|
+
schem = state.chemControllers.getItemById(data.id, true);
|
|
3659
|
+
chem.master = 0;
|
|
3660
|
+
// Copy the data back to the chem object.
|
|
3661
|
+
schem.name = chem.name = name;
|
|
3662
|
+
schem.type = chem.type = sys.board.valueMaps.chemControllerTypes.encode('intellichem');
|
|
3663
|
+
chem.calciumHardness = calciumHardness;
|
|
3664
|
+
chem.cyanuricAcid = cyanuricAcid;
|
|
3665
|
+
chem.alkalinity = alkalinity;
|
|
3666
|
+
chem.borates = borates;
|
|
3667
|
+
chem.body = schem.body = body;
|
|
3668
|
+
schem.isActive = chem.isActive = true;
|
|
3669
|
+
chem.lsiRange.enabled = lsiRange.enabled;
|
|
3670
|
+
chem.lsiRange.low = lsiRange.low;
|
|
3671
|
+
chem.lsiRange.high = lsiRange.high;
|
|
3672
|
+
chem.ph.tolerance.enabled = phTolerance.enabled;
|
|
3673
|
+
chem.ph.tolerance.low = phTolerance.low;
|
|
3674
|
+
chem.ph.tolerance.high = phTolerance.high;
|
|
3675
|
+
chem.orp.tolerance.enabled = orpTolerance.enabled;
|
|
3676
|
+
chem.orp.tolerance.low = orpTolerance.low;
|
|
3677
|
+
chem.orp.tolerance.high = orpTolerance.high;
|
|
3678
|
+
chem.ph.setpoint = pHSetpoint;
|
|
3679
|
+
chem.orp.setpoint = orpSetpoint;
|
|
3680
|
+
schem.siCalcType = chem.siCalcType = siCalcType;
|
|
3681
|
+
chem.address = schem.address = address;
|
|
3682
|
+
chem.name = schem.name = name;
|
|
3683
|
+
chem.flowSensor.enabled = false;
|
|
3684
|
+
return chem;
|
|
4055
3685
|
}
|
|
4056
3686
|
public async deleteChemControllerAsync(data: any): Promise<ChemController> {
|
|
4057
3687
|
let id = typeof data.id !== 'undefined' ? parseInt(data.id, 10) : -1;
|
|
4058
3688
|
if (typeof id === 'undefined' || isNaN(id)) return Promise.reject(new InvalidEquipmentIdError(`Invalid Chem Controller Id`, id, 'chemController'));
|
|
4059
3689
|
let chem = sys.chemControllers.getItemById(id);
|
|
4060
3690
|
if (chem.master === 1) return super.deleteChemControllerAsync(data);
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
payload: [8, 0, id - 1, 0, 1, chem.address || 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
|
|
4067
|
-
onComplete: (err) => {
|
|
4068
|
-
if (err) { reject(err); }
|
|
4069
|
-
else {
|
|
4070
|
-
let schem = state.chemControllers.getItemById(id);
|
|
4071
|
-
chem.isActive = false;
|
|
4072
|
-
chem.ph.tank.capacity = chem.orp.tank.capacity = 6;
|
|
4073
|
-
chem.ph.tank.units = chem.orp.tank.units = '';
|
|
4074
|
-
schem.isActive = false;
|
|
4075
|
-
sys.chemControllers.removeItemById(id);
|
|
4076
|
-
state.chemControllers.removeItemById(id);
|
|
4077
|
-
resolve(chem);
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4080
|
-
});
|
|
4081
|
-
out.setPayloadInt(7, Math.round(chem.ph.setpoint * 100), 700);
|
|
4082
|
-
out.setPayloadInt(9, chem.orp.setpoint, 400);
|
|
4083
|
-
out.setPayloadInt(13, chem.calciumHardness, 25);
|
|
4084
|
-
out.setPayloadInt(15, chem.cyanuricAcid, 0);
|
|
4085
|
-
conn.queueSendMessage(out);
|
|
3691
|
+
let out = Outbound.create({
|
|
3692
|
+
action: 168,
|
|
3693
|
+
response: IntelliCenterBoard.getAckResponse(168),
|
|
3694
|
+
retries: 3,
|
|
3695
|
+
payload: [8, 0, id - 1, 0, 1, chem.address || 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0]
|
|
4086
3696
|
});
|
|
3697
|
+
out.setPayloadInt(7, Math.round(chem.ph.setpoint * 100), 700);
|
|
3698
|
+
out.setPayloadInt(9, chem.orp.setpoint, 400);
|
|
3699
|
+
out.setPayloadInt(13, chem.calciumHardness, 25);
|
|
3700
|
+
out.setPayloadInt(15, chem.cyanuricAcid, 0);
|
|
3701
|
+
await out.sendAsync();
|
|
3702
|
+
let schem = state.chemControllers.getItemById(id);
|
|
3703
|
+
chem.isActive = false;
|
|
3704
|
+
chem.ph.tank.capacity = chem.orp.tank.capacity = 6;
|
|
3705
|
+
chem.ph.tank.units = chem.orp.tank.units = '';
|
|
3706
|
+
schem.isActive = false;
|
|
3707
|
+
sys.chemControllers.removeItemById(id);
|
|
3708
|
+
state.chemControllers.removeItemById(id);
|
|
3709
|
+
return chem;
|
|
4087
3710
|
}
|
|
4088
3711
|
//public async setChemControllerAsync(data: any): Promise<ChemController> {
|
|
4089
3712
|
// // This is a combined chem config/state setter.
|
|
@@ -4132,7 +3755,7 @@ export class IntelliCenterChemControllerCommands extends ChemControllerCommands
|
|
|
4132
3755
|
// let body = sys.board.bodies.mapBodyAssociation(typeof data.body === 'undefined' ? chem.body : data.body);
|
|
4133
3756
|
// if (typeof body === 'undefined') return Promise.reject(new InvalidEquipmentDataError(`Invalid body assignment`, 'chemController', data.body || chem.body));
|
|
4134
3757
|
// let name = (typeof data.name !== 'string') ? chem.name || 'IntelliChem' + id : data.name;
|
|
4135
|
-
|
|
3758
|
+
|
|
4136
3759
|
// return new Promise<ChemController>(async (resolve, reject) => {
|
|
4137
3760
|
// let out = Outbound.create({
|
|
4138
3761
|
// action: 168,
|
|
@@ -4171,7 +3794,7 @@ export class IntelliCenterChemControllerCommands extends ChemControllerCommands
|
|
|
4171
3794
|
// out.setPayloadInt(13, calciumHardness, 25);
|
|
4172
3795
|
// out.setPayloadInt(15, cyanuricAcid, 0);
|
|
4173
3796
|
// out.setPayloadInt(17, alkalinity, 25);
|
|
4174
|
-
//
|
|
3797
|
+
// await out.sendAsync();
|
|
4175
3798
|
|
|
4176
3799
|
// });
|
|
4177
3800
|
//}
|