nodejs-poolcontroller 8.0.4 → 8.0.5
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/controller/State.ts
CHANGED
|
@@ -1089,7 +1089,9 @@ export class ScheduleStateCollection extends EqStateCollection<ScheduleState> {
|
|
|
1089
1089
|
let ssched = this.getItemByIndex(i);
|
|
1090
1090
|
let st = ssched.scheduleTime;
|
|
1091
1091
|
let sched = sys.schedules.getItemById(ssched.id);
|
|
1092
|
-
|
|
1092
|
+
// rsg st.startTime is null when the schedule has No Days <-- WRONG. ssched.scheduleDays should be checked.
|
|
1093
|
+
// original fix #879; updated fix #1033
|
|
1094
|
+
if (!sched.isActive || ssched.disabled || ssched.scheduleDays === 0) {
|
|
1093
1095
|
continue;
|
|
1094
1096
|
}
|
|
1095
1097
|
st.calcSchedule(state.time, sys.schedules.getItemById(ssched.id));
|
|
@@ -3631,7 +3631,7 @@ export class ScheduleCommands extends BoardCommands {
|
|
|
3631
3631
|
if (heatSetpoint < 0 || heatSetpoint > 104) return Promise.reject(new InvalidEquipmentDataError(`Invalid heat setpoint: ${heatSetpoint}`, 'Schedule', heatSetpoint));
|
|
3632
3632
|
if (sys.board.circuits.getCircuitReferences(true, true, false, true).find(elem => elem.id === circuit) === undefined)
|
|
3633
3633
|
return Promise.reject(new InvalidEquipmentDataError(`Invalid circuit reference: ${circuit}`, 'Schedule', circuit));
|
|
3634
|
-
if (schedType === 128 && schedDays === 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid schedule days: ${schedDays}. You must supply days that the schedule is to run.`, 'Schedule', schedDays));
|
|
3634
|
+
if (schedType === 128 && schedDays === 0) return Promise.reject(new InvalidEquipmentDataError(`Invalid schedule days: ${schedDays}. You must supply days that the schedule is to run.`, 'Schedule', schedDays)); // rsg 2024.11.22 - some controllers allow no days.
|
|
3635
3635
|
|
|
3636
3636
|
// If we made it to here we are valid and the schedula and it state should exist.
|
|
3637
3637
|
sched = sys.schedules.getItemById(id, true);
|
|
@@ -668,6 +668,9 @@ export class RS485Port {
|
|
|
668
668
|
let opts: SerialPortOpenOptions<AutoDetectTypes> = { path: portPath, autoOpen: false, baudRate: 9600 };
|
|
669
669
|
sp = new SerialPortMock(opts);
|
|
670
670
|
}
|
|
671
|
+
else if (this._cfg.type === 'screenlogic') {
|
|
672
|
+
return await sl.openAsync();
|
|
673
|
+
}
|
|
671
674
|
else {
|
|
672
675
|
this.mock = false;
|
|
673
676
|
let opts: SerialPortOpenOptions<AutoDetectTypes> = extend(true, { path: this._cfg.rs485Port }, this._cfg.portSettings);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControllerType, Timestamp, Utils, utils } from '../../controller/Constants';
|
|
2
|
-
import { LightGroup, LightGroupCircuit, sys, Valve, Body, Pump, PumpCircuit, Remote} from '../../controller/Equipment';
|
|
2
|
+
import { LightGroup, LightGroupCircuit, sys, Valve, Body, Pump, PumpCircuit, Remote } from '../../controller/Equipment';
|
|
3
3
|
import { CircuitState, state, ValveState } from '../../controller/State';
|
|
4
4
|
import { RemoteLogin, UnitConnection, FindUnits, SLEquipmentStateData, SLIntellichlorData, SLPumpStatusData, SLScheduleData, SLSystemTimeData, HeatModes, SLControllerConfigData, SLEquipmentConfigurationData, HeaterConfig, Valves, SLChemData, SLGetCustomNamesData } from 'node-screenlogic';
|
|
5
5
|
import * as Screenlogic from 'node-screenlogic';
|
|
@@ -87,7 +87,7 @@ export class ScreenLogicComms {
|
|
|
87
87
|
logger.screenlogic(msg);
|
|
88
88
|
})
|
|
89
89
|
let ver = await this._client.getVersionAsync();
|
|
90
|
-
logger.info(`Screenlogic: connect to ${systemName} ${ver} at ${unit.ipAddr}:${unit.port}`);
|
|
90
|
+
logger.info(`Screenlogic: connect to ${systemName} ${ver.version} at ${unit.ipAddr}:${unit.port}`);
|
|
91
91
|
|
|
92
92
|
let addClient = await this._client.addClientAsync();
|
|
93
93
|
logger.silly(`Screenlogic:Add client result: ${addClient}`);
|
|
@@ -912,21 +912,21 @@ class Controller {
|
|
|
912
912
|
}
|
|
913
913
|
], */
|
|
914
914
|
}
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
915
|
+
public static decodeHighSpeed(highSpeed: number[]) {
|
|
916
|
+
let maxCircuits = sys.controllerType === ControllerType.IntelliTouch ? 8 : 4;
|
|
917
|
+
let arrCircuits = [];
|
|
918
|
+
let pump = sys.pumps.find(x => { return x.master !== 1 && x.type === 65 });
|
|
919
|
+
for (let i = 0; i < maxCircuits && i < highSpeed.length; i++) {
|
|
920
|
+
let val = highSpeed[i];
|
|
921
|
+
if (val > 0) arrCircuits.push(val);
|
|
922
|
+
else if (typeof pump !== 'undefined') pump.circuits.removeItemById(i);
|
|
923
|
+
}
|
|
924
|
+
if (arrCircuits.length > 0) {
|
|
925
|
+
let pump = sys.pumps.getDualSpeed(true);
|
|
926
|
+
for (let j = 1; j <= arrCircuits.length; j++) pump.circuits.getItemById(j, true).circuit = arrCircuits[j - 1];
|
|
927
|
+
}
|
|
928
|
+
else if (typeof pump !== 'undefined') sys.pumps.removeItemById(pump.id);
|
|
929
|
+
}
|
|
930
930
|
public static decodeRemote(remoteDataArray) {
|
|
931
931
|
if (sys.controllerType === ControllerType.EasyTouch) {
|
|
932
932
|
|
|
@@ -980,11 +980,11 @@ class Controller {
|
|
|
980
980
|
remote6.button3 = remote.button8;
|
|
981
981
|
remote6.button4 = remote.button9;
|
|
982
982
|
if (!remote5.button1 && !remote5.button2 && !remote5.button3 && !remote5.button4) remote5.isActive = false;
|
|
983
|
-
|
|
984
|
-
|
|
983
|
+
else remote5.isActive = true;
|
|
984
|
+
|
|
985
985
|
if (!remote6.button1 && !remote6.button2 && !remote6.button3 && !remote6.button4) remote6.isActive = false;
|
|
986
|
-
|
|
987
|
-
|
|
986
|
+
else remote6.isActive = true;
|
|
987
|
+
|
|
988
988
|
}
|
|
989
989
|
else {
|
|
990
990
|
remote5.isActive = remote6.isActive = false;
|
|
@@ -1066,43 +1066,43 @@ class Controller {
|
|
|
1066
1066
|
}
|
|
1067
1067
|
|
|
1068
1068
|
}
|
|
1069
|
-
public static async decodePumpAsync(pDataArr: any
|
|
1070
|
-
pDataArr.forEach(async (pData, idx)=>{
|
|
1069
|
+
public static async decodePumpAsync(pDataArr: any) {
|
|
1070
|
+
pDataArr.forEach(async (pData, idx) => {
|
|
1071
1071
|
await sys.board.pumps.setPumpAsync(pData, false);
|
|
1072
1072
|
})
|
|
1073
1073
|
}
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
}
|
|
1074
|
+
public static async decodePumpStatusAsync(id: number, slpump: SLPumpStatusData) {
|
|
1075
|
+
/* {
|
|
1076
|
+
pumpCircuits: [
|
|
1077
|
+
{ circuitId: 6,speed: 2000,isRPMs: true, },
|
|
1078
|
+
{ circuitId: 8, speed:2700,isRPMs: true, },
|
|
1079
|
+
{ circuitId: 2,speed: 2710,isRPMs: true, },
|
|
1080
|
+
{ circuitId: 2,speed:1000, isRPMs: true,},
|
|
1081
|
+
{ circuitId: 5,speed:2830, isRPMs: true,},
|
|
1082
|
+
{ circuitId: 0,speed: 30,isRPMs: false,},
|
|
1083
|
+
{ circuitId: 0,speed: 30,isRPMs: false,},
|
|
1084
|
+
{ circuitId: 0,speed: 30,isRPMs: false,},
|
|
1085
|
+
],
|
|
1086
|
+
pumpType: 4,
|
|
1087
|
+
isRunning: false,
|
|
1088
|
+
pumpWatts: 0,
|
|
1089
|
+
pumpRPMs: 0,
|
|
1090
|
+
pumpUnknown1: 0,
|
|
1091
|
+
pumpGPMs: 0,
|
|
1092
|
+
pumpUnknown2: 255,
|
|
1093
|
+
}
|
|
1094
|
+
*/
|
|
1095
|
+
// RKS: 05-07-23 - This process of getting the pump by its id is flawed. We need to pull this information by its address.
|
|
1096
|
+
//let pstate = state.pumps.getItemById(id);
|
|
1097
|
+
let pstate = state.pumps.find(x => x.address === 95 + id);
|
|
1098
|
+
if (typeof pstate !== 'undefined') {
|
|
1099
|
+
pstate.watts = slpump.pumpWatts;
|
|
1100
|
+
pstate.rpm = slpump.pumpRPMs;
|
|
1101
|
+
pstate.flow = slpump.pumpGPMs === 255 ? 0 : slpump.pumpGPMs;
|
|
1102
|
+
pstate.command = (pstate.rpm > 0 || pstate.watts > 0) ? 10 : 0;
|
|
1103
|
+
state.emitEquipmentChanges();
|
|
1105
1104
|
}
|
|
1105
|
+
}
|
|
1106
1106
|
public static async decodeSchedules(slrecurring: SLScheduleData, slrunonce: SLScheduleData) {
|
|
1107
1107
|
/* reccuring schedules: [{"scheduleId":1,"circuitId":6,"startTime":"1800","stopTime":"0700","dayMask":127,"flags":0,"heatCmd":4,"heatSetPoint":70,"days":["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]},
|
|
1108
1108
|
|
|
@@ -1111,18 +1111,17 @@ class Controller {
|
|
|
1111
1111
|
Run once schedules: [{"scheduleId":12,"circuitId":6,"startTime":"0800","stopTime":"1100","dayMask":1,"flags":1,"heatCmd":4,"heatSetPoint":70,"days":["Mon"]},{"scheduleId":13,"circuitId":6,"startTime":"0800","stopTime":"1100","dayMask":1,"flags":1,"heatCmd":4,"heatSetPoint":70,"days":["Mon"]}] */
|
|
1112
1112
|
|
|
1113
1113
|
for (let i = 0; i < slrecurring.data.length; i++) {
|
|
1114
|
-
let slsched = slrecurring[i];
|
|
1115
|
-
let data = {
|
|
1116
|
-
id: slsched.scheduleId,
|
|
1117
|
-
circuit: slsched.circuitId,
|
|
1118
|
-
startTime: Math.floor(slsched.startTime / 100) * 60 + slsched.startTime % 100,
|
|
1119
|
-
endTime: Math.floor(slsched.stopTime / 100) * 60 + slsched.stopTime % 100,
|
|
1120
|
-
scheduleDays: slsched.dayMask,
|
|
1121
|
-
changeHeatSetPoint: slsched.heatCmd > 0,
|
|
1122
|
-
heatSetPoint: slsched.heatSetPoint,
|
|
1123
|
-
schedType: 128 // recurring
|
|
1124
|
-
}
|
|
1114
|
+
let slsched = slrecurring.data[i];
|
|
1125
1115
|
try {
|
|
1116
|
+
let data = {
|
|
1117
|
+
circuit: slsched.circuitId,
|
|
1118
|
+
startTime: Math.floor(parseInt(slsched.startTime, 10) / 100) * 60 + parseInt(slsched.startTime, 10) % 100,
|
|
1119
|
+
endTime: Math.floor(parseInt(slsched.stopTime, 10) / 100) * 60 + parseInt(slsched.stopTime, 10) % 100,
|
|
1120
|
+
scheduleDays: slsched.dayMask,
|
|
1121
|
+
changeHeatSetPoint: slsched.heatCmd > 0,
|
|
1122
|
+
heatSetPoint: slsched.heatSetPoint,
|
|
1123
|
+
schedType: 128 // recurring
|
|
1124
|
+
}
|
|
1126
1125
|
await sys.board.schedules.setScheduleAsync(data, false)
|
|
1127
1126
|
} catch (err) {
|
|
1128
1127
|
logger.error(`Error setting schedule ${slsched.scheduleId}. ${err.message}`);
|
|
@@ -1130,18 +1129,18 @@ class Controller {
|
|
|
1130
1129
|
}
|
|
1131
1130
|
for (let i = 0; i < slrunonce.data.length; i++) {
|
|
1132
1131
|
let slsched = slrunonce.data[i];
|
|
1133
|
-
let data = {
|
|
1134
|
-
id: slsched.scheduleId,
|
|
1135
|
-
circuit: slsched.circuitId,
|
|
1136
|
-
// start and stop come in as military time string
|
|
1137
|
-
startTime: parseInt(slsched.startTime, 10),
|
|
1138
|
-
endTime: parseInt(slsched.stopTime, 10),
|
|
1139
|
-
scheduleDays: slsched.dayMask,
|
|
1140
|
-
changeHeatSetPoint: slsched.heatCmd > 0,
|
|
1141
|
-
heatSetPoint: slsched.heatSetPoint,
|
|
1142
|
-
schedType: 0 // runonce
|
|
1143
|
-
}
|
|
1144
1132
|
try {
|
|
1133
|
+
let data = {
|
|
1134
|
+
id: slsched.scheduleId,
|
|
1135
|
+
circuit: slsched.circuitId,
|
|
1136
|
+
// start and stop come in as military time string
|
|
1137
|
+
startTime: parseInt(slsched.startTime, 10),
|
|
1138
|
+
endTime: parseInt(slsched.stopTime, 10),
|
|
1139
|
+
scheduleDays: slsched.dayMask,
|
|
1140
|
+
changeHeatSetPoint: slsched.heatCmd > 0,
|
|
1141
|
+
heatSetPoint: slsched.heatSetPoint,
|
|
1142
|
+
schedType: 0 // runonce
|
|
1143
|
+
}
|
|
1145
1144
|
await sys.board.schedules.setScheduleAsync(data, false);
|
|
1146
1145
|
sys.board.system.setTZ();
|
|
1147
1146
|
} catch (err) {
|
|
@@ -1607,23 +1606,23 @@ export class SLController extends SLCommands {
|
|
|
1607
1606
|
const spaCommand: Remote = sys.remotes.getItemById(8).get();
|
|
1608
1607
|
let alarm = 0;
|
|
1609
1608
|
|
|
1610
|
-
switch (eq){
|
|
1609
|
+
switch (eq) {
|
|
1611
1610
|
case 'misc': {
|
|
1612
|
-
|
|
1611
|
+
misc = extend({}, true, misc, obj);
|
|
1613
1612
|
break;
|
|
1614
1613
|
}
|
|
1615
1614
|
case 'lightGroup': {
|
|
1616
|
-
|
|
1615
|
+
lightGroup = extend({}, true, lightGroup, obj);
|
|
1617
1616
|
break;
|
|
1618
1617
|
}
|
|
1619
|
-
case 'pump':{
|
|
1620
|
-
let idx = pumps.findIndex(el=>{console.log(el.id);return el.id === obj.id;})
|
|
1618
|
+
case 'pump': {
|
|
1619
|
+
let idx = pumps.findIndex(el => { console.log(el.id); return el.id === obj.id; })
|
|
1621
1620
|
if (idx >= 0) pumps = extend({}, true, pumps[idx], obj);
|
|
1622
1621
|
else return Promise.reject(`Screenlogic: No pump found by that id: ${obj}`);
|
|
1623
1622
|
break;
|
|
1624
1623
|
}
|
|
1625
1624
|
case 'heater': {
|
|
1626
|
-
let idx = heaters.findIndex(el=>{console.log(el.id);return el.id === obj.id;})
|
|
1625
|
+
let idx = heaters.findIndex(el => { console.log(el.id); return el.id === obj.id; })
|
|
1627
1626
|
if (idx >= 0) heaters = extend({}, true, heaters[idx], obj);
|
|
1628
1627
|
else return Promise.reject(`Screenlogic: No pump found by that id: ${obj}`);
|
|
1629
1628
|
break;
|
|
@@ -1646,7 +1645,7 @@ export class SLController extends SLCommands {
|
|
|
1646
1645
|
// await this._unit.equipment.setEquipmentConfigurationAsync(data);
|
|
1647
1646
|
}
|
|
1648
1647
|
|
|
1649
|
-
public async setSystemTime(){
|
|
1648
|
+
public async setSystemTime() {
|
|
1650
1649
|
try {
|
|
1651
1650
|
let sysTime = await this._unit.equipment.setSystemTimeAsync(state.time.toDate(), sys.general.options.adjustDST);
|
|
1652
1651
|
logger.silly(`Screenlogic:set time result: ${sysTime}`);
|
|
@@ -1654,7 +1653,7 @@ export class SLController extends SLCommands {
|
|
|
1654
1653
|
return Promise.reject(new InvalidOperationError('Unable to set system time.', error.message));
|
|
1655
1654
|
}
|
|
1656
1655
|
}
|
|
1657
|
-
public async setCustomName(idx: number, name: string){
|
|
1656
|
+
public async setCustomName(idx: number, name: string) {
|
|
1658
1657
|
try {
|
|
1659
1658
|
let ack = await this._unit.equipment.setCustomNameAsync(idx, name);
|
|
1660
1659
|
logger.silly(`Screenlogic:set custom name result: ${JSON.stringify(ack)}`);
|