Skip to content

Commit

Permalink
Added an alternate mqtt binding. This is more hierarchical to match t…
Browse files Browse the repository at this point in the history
…he state structure.
  • Loading branch information
rstrouse authored and tagyoureit committed Feb 11, 2021
1 parent 64fbd24 commit 594386f
Show file tree
Hide file tree
Showing 6 changed files with 728 additions and 58 deletions.
10 changes: 5 additions & 5 deletions controller/boards/IntelliCenterBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,13 @@ export class IntelliCenterBoard extends SystemBoard {
}
}
public async stopAsync() { this._configQueue.close(); return super.stopAsync();}
public initExpansionModules(ocp0A: number, ocp0B: number, ocp1A: number, ocp1B: number, ocp2A: number, ocp2B: number, ocp3A: number, ocp3B: number) {
public initExpansionModules(ocp0A: number, ocp0B: number, xcp1A: number, xcp1B: number, xcp2A: number, xcp2B: number, xcp3A: number, xcp3B: number) {
let inv = { bodies: 0, circuits: 0, valves: 0, shared: false, dual: false, covers: 0, chlorinators: 0, chemControllers: 0 };
this.processMasterModules(sys.equipment.modules, ocp0A, ocp0B, inv);
// Here we need to set the start id should we have a single body system.
if (!inv.shared && !inv.dual) { sys.board.equipmentIds.circuits.start = 2; } // We are a single body system.
this.processExpansionModules(sys.equipment.expansions.getItemById(1, true), ocp1A, ocp1B, inv);
this.processExpansionModules(sys.equipment.expansions.getItemById(2, true), ocp2A, ocp2B, inv);
this.processExpansionModules(sys.equipment.expansions.getItemById(1, true), xcp1A, xcp1B, inv);
this.processExpansionModules(sys.equipment.expansions.getItemById(2, true), xcp2A, xcp2B, inv);
// We are still unsure how the 3rd power center is encoded. For now we are simply un-installing it.
this.processExpansionModules(sys.equipment.expansions.getItemById(3, true), 0, 0, inv);
if (inv.bodies !== sys.equipment.maxBodies ||
Expand All @@ -279,8 +279,8 @@ export class IntelliCenterBoard extends SystemBoard {
inv.valves !== sys.equipment.maxValves) {
sys.resetData();
this.processMasterModules(sys.equipment.modules, ocp0A, ocp0B);
this.processExpansionModules(sys.equipment.expansions.getItemById(1, true), ocp1A, ocp1B);
this.processExpansionModules(sys.equipment.expansions.getItemById(2, true), ocp2A, ocp2B);
this.processExpansionModules(sys.equipment.expansions.getItemById(1, true), xcp1A, xcp1B);
this.processExpansionModules(sys.equipment.expansions.getItemById(2, true), xcp2A, xcp2B);
this.processExpansionModules(sys.equipment.expansions.getItemById(3, true), 0, 0);
}
sys.equipment.maxBodies = inv.bodies;
Expand Down
7 changes: 4 additions & 3 deletions controller/comms/messages/status/EquipmentStateMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,11 @@ export class EquipmentStateMessage {
// Master = 13-14
// EXP1 = 15-16
// EXP2 = 17-18
let pc = msg.extractPayloadByte(40);
board.initExpansionModules(msg.extractPayloadByte(13), msg.extractPayloadByte(14),
msg.extractPayloadByte(15), msg.extractPayloadByte(16),
msg.extractPayloadByte(17), msg.extractPayloadByte(18),
msg.extractPayloadByte(19), msg.extractPayloadByte(20));
pc & 0x01 ? msg.extractPayloadByte(15) : 0x00, pc & 0x01 ? msg.extractPayloadByte(16) : 0x00,
pc & 0x02 ? msg.extractPayloadByte(17) : 0x00, pc & 0x02 ? msg.extractPayloadByte(18) : 0x00,
pc & 0x04 ? msg.extractPayloadByte(19) : 0x00, pc & 0x04 ? msg.extractPayloadByte(20) : 0x00);
sys.equipment.setEquipmentIds();
}
else return;
Expand Down
22 changes: 21 additions & 1 deletion defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,29 @@
"password": "",
"rootTopic": "@bind=(state.equipment.model).replace(' ','-').replace('/','').toLowerCase();",
"retain": true,
"qos": 0
"qos": 0,
"changesOnly": true
}
},
"mqttAlt": {
"name": "MQTTAlt",
"type": "mqtt",
"enabled": false,
"fileName": "mqttAlt.json",
"globals": {},
"options": {
"protocol": "mqtt://",
"host": "192.168.0.1",
"port": 1883,
"username": "",
"password": "",
"rootTopic": "@bind=(state.equipment.model).replace(' ','-').replace('/','').toLowerCase();Alt",
"retain": true,
"qos": 0,
"changesOnly": true
}
},

"rem": {
"name": "Relay Equipment Manager",
"type": "rem",
Expand Down
148 changes: 109 additions & 39 deletions web/bindings/mqtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"description": "Remove / and replace with __"
}
],
"qos": 2,
"options": { "qos": 2 },
"enabled": false
},
{
Expand Down Expand Up @@ -314,116 +314,186 @@
"description": "Populate the chemControllers topic",
"topics": [
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/acidTankLevel",
"message": "{\"acidTankLevel\":@bind=data.acidTankLevel;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/ph/tankLevel",
"message": "@bind=data.ph.tank.level;",
"enabled": true
},
{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/alkalinity",
"message": "{\"alkalinity\":@bind=data.alkalinity;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/ph/setpoint",
"message": "@bind=data.ph.setpoint;",
"enabled": true
},
{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/calciumHardness",
"message": "{\"calciumHardness\":@bind=data.calciumHardness;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/ph/level",
"message": "@bind=data.ph.level;",
"enabled": true
},
{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/cyanuricAcid",
"message": "{\"cyanuricAcid\":@bind=data.cyanuricAcid;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/ph/doseTime",
"message": "@bind=data.ph.doseTime;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpDosingTime",
"message": "{\"orpDosingTime\":@bind=data.orpDosingTime;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/ph/doseVolume",
"message": "@bind=data.ph.doseVolume;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpLevel",
"message": "{\"orpLevel\":@bind=data.orpLevel;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/tankLevel",
"message": "@bind=data.orp.tank.level;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpSetpoint",
"message": "{\"orpSetpoint\":@bind=data.orpSetpoint;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/setpoint",
"message": "@bind=data.orp.setpoint;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/level",
"message": "@bind=data.orp.level;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/doseTime",
"message": "@bind=data.orp.doseTime;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/doseVolume",
"message": "@bind=data.orp.doseVolume;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orp/saltLevel",
"message": "@bind=data.orp.saltLevel;",
"enabled": true
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/acidTankLevel",
"message": "{\"acidTankLevel\":@bind=data.ph.tank.level;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpTankLevel",
"message": "{\"orpTankLevel\":@bind=data.orpTankLevel;}"
"message": "{\"orpTankLevel\":@bind=data.orp.tank.level;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpDosingTime",
"message": "{\"orpDosingTime\":@bind=data.orp.doseTime;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/pHDosingTime",
"message": "{\"pHDosingTime\":@bind=data.pHDosingTime;}"
"message": "{\"pHDosingTime\":@bind=data.ph.doseTime;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/pHLevel",
"message": "{\"pHLevel\":@bind=data.pHLevel;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/pHDosingVolume",
"message": "{\"orpDosingVolume\":@bind=data.ph.doseVolume;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpDosingVolume",
"message": "{\"pHDosingVolume\":@bind=data.orp.doseVolume;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpSetpoint",
"message": "{\"orpSetpoint\":@bind=data.orp.setpoint;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/pHSetpoint",
"message": "{\"pHSetpoint\":@bind=data.pHSetpoint;}"
"message": "{\"pHSetpoint\":@bind=data.ph.setpoint;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/orpLevel",
"message": "{\"orpLevel\":@bind=data.orp.level;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/pHLevel",
"message": "{\"pHLevel\":@bind=data.ph.level;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/saltLevel",
"message": "{\"saltLevel\":@bind=data.saltLevel;}"
"message": "{\"saltLevel\":@bind=data.orp.probe.saltLevel;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/saturationIndex",
"message": "{\"saturationIndex\":@bind=data.saturationIndex;}"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/status",
"message": "{\"status\":@bind=data.status;}"
"message": "@bind=data.status;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/type",
"message": "{\"type\":@bind=data.type;}"
"message": "@bind=data.type;"
},

{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/alkalinity",
"message": "{\"alkalinity\":@bind=data.alkalinity;}"
},
{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/calciumHardness",
"message": "@bind=data.calciumHardness;"
},
{
"topic": "config/chemControllers/@bind=data.id;/@bind=data.name;/cyanuricAcid",
"message": "@bind=data.cyanuricAcid;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/virtualControllerStatus",
"message": "{\"virtualControllerStatus\":@bind=data.virtualControllerStatus;}"
"message": "@bind=data.virtualControllerStatus;"
},

{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/flow",
"message": "{\"flow\":@bind=data.flow;}"
"message": "@bind=data.alarms.flow;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/ph",
"message": "{\"ph\":@bind=data.ph;}"
"message": "@bind=data.alarms.pH;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/orp",
"message": "{\"orp\":@bind=data.orp;}"
"message": "@bind=data.alarms.orp;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/phTank",
"message": "{\"phTank\":@bind=data.phTank;}"
"message": "@bind=data.alarms.pHTank;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/orpTank",
"message": "{\"orpTank\":@bind=data.orpTank;}"
"message": "@bind=data.alarms.orpTank;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/probeFault",
"message": "{\"probeFault\":@bind=data.probeFault;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/orpProbeFault",
"message": "@bind=data.alarms.orpProbeFault;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/alarms/pHProbeFault",
"message": "@bind=data.alarms.pHProbeFault;"
},

{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/waterChemistry",
"message": "{\"waterChemistry\":@bind=data.waterChemistry;}"
"message": "@bind=data.warnings.waterChemistry;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/phLockout",
"message": "{\"phLockout\":@bind=data.phLockout;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/pHLockout",
"message": "@bind=data.warnings.pHLockout;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/phDailLimitReached",
"message": "{\"phDailLimitReached\":@bind=data.phDailLimitReached;}"
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/pHDailyLimitReached",
"message": "@bind=data.warnings.pHDailyLimitReached;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/orpDailyLimitReached",
"message": "{\"orpDailyLimitReached\":@bind=data.orpDailyLimitReached;}"
"message": "@bind=data.warnings.orpDailyLimitReached;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/invalidSetup",
"message": "{\"invalidSetup\":@bind=data.invalidSetup;}"
"message": "@bind=data.warnings.invalidSetup;"
},
{
"topic": "state/chemControllers/@bind=data.id;/@bind=data.name;/warnings/chlorinatorCommError",
"message": "{\"chlorinatorCommError\":@bind=data.chlorinatorCommError;}"
"message": "@bind=data.warnings.chlorinatorCommError;"
}
]
},
Expand Down
Loading

0 comments on commit 594386f

Please sign in to comment.