mirror of
https://github.com/parnic/MMM-IntelliCenter.git
synced 2025-06-16 13:20:12 -05:00
Minor cleanup, fix errors
This commit is contained in:
@ -174,7 +174,7 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getPHDom() {
|
getPHDom() {
|
||||||
let dataStr = this.poolData.lastPHVal;
|
let dataStr = this.poolData.lastPHVal.toString();
|
||||||
if (this.config.showPHTankLevel) {
|
if (this.config.showPHTankLevel) {
|
||||||
const percent = Math.round(
|
const percent = Math.round(
|
||||||
((this.poolData.phTank - 1) / this.config.pHTankLevelMax) * 100,
|
((this.poolData.phTank - 1) / this.config.pHTankLevelMax) * 100,
|
||||||
@ -246,8 +246,10 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
controls.push(circuit);
|
controls.push(circuit);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.warn("circuit with unknown type, unable to display:");
|
Log.warn(
|
||||||
Log.warn(controlObj);
|
"circuit with unknown type, unable to display. supported types: circuit, heatpoint, heatmode. object:",
|
||||||
|
controlObj,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,29 +291,34 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getHeatpointDom(controlObj) {
|
getHeatpointDom(controlObj) {
|
||||||
// todo: if "body" isn't defined in the user's config correctly, this will error out
|
const body =
|
||||||
const body = controlObj.body.toLowerCase();
|
typeof controlObj.body === "string" ? controlObj.body.toLowerCase() : "";
|
||||||
if (body !== "pool" && body !== "spa") {
|
if (body !== "pool" && body !== "spa") {
|
||||||
Log.warn("Invalid body specified for heatpoint. Valid bodies: pool, spa");
|
Log.warn(
|
||||||
|
"Invalid body specified for heatpoint. Valid bodies: pool, spa",
|
||||||
|
controlObj,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!controlObj.name) {
|
||||||
|
Log.warn("Invalid name specified for heatpoint.", controlObj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const temperature =
|
const temperature =
|
||||||
body === "pool"
|
body === "pool" ? this.poolData.poolSetPoint : this.poolData.spaSetPoint;
|
||||||
? this.poolData.poolSetPoint.toString()
|
|
||||||
: this.poolData.spaSetPoint.toString();
|
|
||||||
|
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.classList.add("temperature-container");
|
div.classList.add("temperature-container");
|
||||||
|
|
||||||
const buttonUp = document.createElement("button");
|
const buttonUp = document.createElement("button");
|
||||||
buttonUp.id = `sl-temp-up-${controlObj.body}`;
|
buttonUp.id = `sl-temp-up-${body}`;
|
||||||
buttonUp.classList.add("control-off", "temperature");
|
buttonUp.classList.add("control-off", "temperature");
|
||||||
buttonUp.onclick = (e) => {
|
buttonUp.onclick = (e) => {
|
||||||
this.setHeatpoint(e.currentTarget, 1);
|
this.setHeatpoint(e.currentTarget, 1);
|
||||||
};
|
};
|
||||||
buttonUp.dataset.body = controlObj.body;
|
buttonUp.dataset.body = body;
|
||||||
buttonUp.dataset.temperature = temperature;
|
buttonUp.dataset.temperature = temperature.toString();
|
||||||
|
|
||||||
const contentUp = document.createElement("div");
|
const contentUp = document.createElement("div");
|
||||||
contentUp.classList.add("content");
|
contentUp.classList.add("content");
|
||||||
@ -326,12 +333,12 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
div.appendChild(label);
|
div.appendChild(label);
|
||||||
|
|
||||||
const buttonDown = document.createElement("button");
|
const buttonDown = document.createElement("button");
|
||||||
buttonDown.id = `sl-temp-down-${controlObj.body}`;
|
buttonDown.id = `sl-temp-down-${body}`;
|
||||||
buttonDown.classList.add("control-off", "temperature");
|
buttonDown.classList.add("control-off", "temperature");
|
||||||
buttonDown.onclick = (e) => {
|
buttonDown.onclick = (e) => {
|
||||||
this.setHeatpoint(e.currentTarget, -1);
|
this.setHeatpoint(e.currentTarget, -1);
|
||||||
};
|
};
|
||||||
buttonDown.dataset.body = controlObj.body;
|
buttonDown.dataset.body = body;
|
||||||
buttonDown.dataset.temperature = temperature;
|
buttonDown.dataset.temperature = temperature;
|
||||||
|
|
||||||
const contentDown = document.createElement("div");
|
const contentDown = document.createElement("div");
|
||||||
@ -348,10 +355,17 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getHeatmodeDom(controlObj) {
|
getHeatmodeDom(controlObj) {
|
||||||
// todo: if "body" isn't defined in the user's config correctly, this will error out
|
const body =
|
||||||
const body = controlObj.body.toLowerCase();
|
typeof controlObj.body === "string" ? controlObj.body.toLowerCase() : "";
|
||||||
if (body !== "pool" && body !== "spa") {
|
if (body !== "pool" && body !== "spa") {
|
||||||
Log.warn("Invalid body specified for heatmode. Valid bodies: pool, spa");
|
Log.warn(
|
||||||
|
"Invalid body specified for heatmode. Valid bodies: pool, spa",
|
||||||
|
controlObj,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!controlObj.name) {
|
||||||
|
Log.warn("Invalid name specified for heatmode.", controlObj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,13 +380,13 @@ Module.register("MMM-IntelliCenter", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const button = document.createElement("button");
|
const button = document.createElement("button");
|
||||||
button.id = `sl-heat-${controlObj.body}`;
|
button.id = `sl-heat-${body}`;
|
||||||
button.classList.add("control", cls);
|
button.classList.add("control", cls);
|
||||||
button.onclick = (e) => {
|
button.onclick = (e) => {
|
||||||
this.setHeatmode(e.currentTarget);
|
this.setHeatmode(e.currentTarget);
|
||||||
};
|
};
|
||||||
button.dataset.body = controlObj.body;
|
button.dataset.body = body;
|
||||||
button.dataset.state = on ? 1 : 0;
|
button.dataset.state = on ? "1" : "0";
|
||||||
|
|
||||||
const content = document.createElement("div");
|
const content = document.createElement("div");
|
||||||
content.classList.add("content");
|
content.classList.add("content");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global module require clearInterval clearTimeout setTimeout setInterval config */
|
/* global module require clearInterval clearTimeout setTimeout setInterval */
|
||||||
|
|
||||||
var NodeHelper = require("node_helper");
|
var NodeHelper = require("node_helper");
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ module.exports = NodeHelper.create({
|
|||||||
}
|
}
|
||||||
} else if (Object.keys(poolData.circuits).includes(obj.objnam)) {
|
} else if (Object.keys(poolData.circuits).includes(obj.objnam)) {
|
||||||
Log.info(
|
Log.info(
|
||||||
`[MMM-IntelliCenter] received update for circuit ${obj.objnam}`,
|
`[MMM-IntelliCenter] received update for circuit ${obj.objnam} (${poolData.circuits[obj.objnam].name})`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (obj.params.STATUS) {
|
if (obj.params.STATUS) {
|
||||||
@ -431,7 +431,7 @@ module.exports = NodeHelper.create({
|
|||||||
connect(cb, reconnectCb) {
|
connect(cb, reconnectCb) {
|
||||||
if (
|
if (
|
||||||
!foundUnit &&
|
!foundUnit &&
|
||||||
typeof config !== "undefined" &&
|
typeof this.config !== "undefined" &&
|
||||||
this.config.serverAddress &&
|
this.config.serverAddress &&
|
||||||
this.config.serverPort
|
this.config.serverPort
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user