Hooked up heat mode/state

Hooked up most of the server-side support for heat setpoint

I decided to continue using the `controls` array and differentiate with a new `type` property. This allows much simpler sorting of controls than trying to figure out a good layout for a mix of circuits, heat modes, and heat points.

Heat point UI is going to require a bit more thinking than the simple toggles of circuit and heat modes, but I wanted to get the current progress committed. I'm also not terribly happy with the terminology I've gone with here, so I expect to iterate on that.
This commit is contained in:
2020-03-30 21:48:12 -05:00
parent 994fc68251
commit b07a1c67b6
3 changed files with 125 additions and 35 deletions

View File

@ -14,11 +14,31 @@ module.exports = NodeHelper.create({
setCircuit: function(circuitState) {
var self = this;
setCircuitState(circuitState, function(done) {
self.sendSocketNotification('SCREENLOGIC_CIRCUIT_DONE', circuitState);
setCircuitState(circuitState, function(poolStatus) {
self.sendSocketNotification('SCREENLOGIC_CIRCUIT_DONE', {circuitState: circuitState, status: poolStatus});
});
},
setHeatpoint: function(heatpoint) {
var self = this;
setHeatpointState(heatpoint, function(poolStatus) {
self.sendSocketNotification('SCREENLOGIC_HEATPOINT_DONE', {heatpoint: heatpoint, status: poolStatus});
});
},
setHeatstate: function(heatstate) {
var self = this;
setHeatstateState(heatstate, function(poolStatus) {
self.sendSocketNotification('SCREENLOGIC_HEATSTATE_DONE', {heatstate: heatstate, status: poolStatus});
});
},
restartTimer: function() {
var interval = this.updateInterval;
this.updateInterval = undefined;
this.setTimer(interval);
},
setTimer: function(updateInterval) {
var update = true;
update = typeof this.updateInterval === 'undefined' || this.updateInterval != updateInterval;
@ -119,8 +139,46 @@ function setCircuitState(circuitState, cb) {
foundUnit.once('loggedIn', function() {
foundUnit.setCircuitState(0, circuitState.id, circuitState.state);
}).once('circuitStateChanged', function() {
foundUnit.getPoolStatus();
}).once('poolStatus', function(status) {
foundUnit.close();
cb(true);
cb(status);
});
foundUnit.connect();
}
function setHeatpointState(heatpoint, cb) {
if (!foundUnit) {
cb();
return;
}
foundUnit.once('loggedIn', function() {
foundUnit.setSetPoint(0, heatpoint.body, heatpoint.temperature);
}).once('setPointChanged', function() {
foundUnit.getPoolStatus();
}).once('poolStatus', function(status) {
foundUnit.close();
cb(status);
});
foundUnit.connect();
}
function setHeatstateState(heatstate, cb) {
if (!foundUnit) {
cb();
return;
}
foundUnit.once('loggedIn', function() {
foundUnit.setHeatMode(0, heatstate.body, heatstate.state);
}).once('heatModeChanged', function() {
foundUnit.getPoolStatus();
}).once('poolStatus', function(status) {
foundUnit.close();
cb(status);
});
foundUnit.connect();