Finish setting up prettier, fix its complaints

This commit is contained in:
2025-01-04 19:32:07 -06:00
parent f911f42063
commit c7f8d903d3
5 changed files with 36 additions and 34 deletions

1
.prettierignore Normal file
View File

@ -0,0 +1 @@
/.github/

1
.prettierrc Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -22,7 +22,7 @@ Module.register("MMM-IntelliCenter", {
pHTankLevelMax: 6, pHTankLevelMax: 6,
serverAddress: "", serverAddress: "",
serverPort: 0, serverPort: 0,
multicastInterface: "" multicastInterface: "",
}, },
start() { start() {
@ -31,7 +31,7 @@ Module.register("MMM-IntelliCenter", {
(!this.config.controls || this.config.controls.length === 0) (!this.config.controls || this.config.controls.length === 0)
) { ) {
Log.warn( Log.warn(
"Controls are enabled, but no controls are configured. See README for info on setting up controls." "Controls are enabled, but no controls are configured. See README for info on setting up controls.",
); );
this.config.showControls = false; this.config.showControls = false;
} }
@ -84,7 +84,7 @@ Module.register("MMM-IntelliCenter", {
contents.push({ contents.push({
header: "Pool temp", header: "Pool temp",
data: `${poolData.status.currentTemp[0]}°${!isPoolActive(poolData.status) ? " (last)" : ""}`, data: `${poolData.status.currentTemp[0]}°${!isPoolActive(poolData.status) ? " (last)" : ""}`,
class: this.config.contentClass + className class: this.config.contentClass + className,
}); });
} }
if (this.config.showSpaTemp) { if (this.config.showSpaTemp) {
@ -98,14 +98,14 @@ Module.register("MMM-IntelliCenter", {
contents.push({ contents.push({
header: "Spa temp", header: "Spa temp",
data: `${poolData.status.currentTemp[1]}°${!isSpaActive(poolData.status) ? " (last)" : ""}`, data: `${poolData.status.currentTemp[1]}°${!isSpaActive(poolData.status) ? " (last)" : ""}`,
class: this.config.contentClass + className class: this.config.contentClass + className,
}); });
} }
if (this.config.showPH) { if (this.config.showPH) {
let dataStr = poolData.status.pH; let dataStr = poolData.status.pH;
if (this.config.showPHTankLevel) { if (this.config.showPHTankLevel) {
const percent = Math.round( const percent = Math.round(
((poolData.status.pHTank - 1) / this.config.pHTankLevelMax) * 100 ((poolData.status.pHTank - 1) / this.config.pHTankLevelMax) * 100,
); );
let cls = ""; let cls = "";
if (this.config.colored) { if (this.config.colored) {
@ -128,28 +128,28 @@ Module.register("MMM-IntelliCenter", {
contents.push({ contents.push({
header: "pH", header: "pH",
data: dataStr, data: dataStr,
class: this.config.contentClass class: this.config.contentClass,
}); });
} }
if (this.config.showOrp) { if (this.config.showOrp) {
contents.push({ contents.push({
header: "ORP", header: "ORP",
data: poolData.status.orp, data: poolData.status.orp,
class: this.config.contentClass class: this.config.contentClass,
}); });
} }
if (this.config.showSaltLevel) { if (this.config.showSaltLevel) {
contents.push({ contents.push({
header: "Salt PPM", header: "Salt PPM",
data: poolData.status.saltPPM, data: poolData.status.saltPPM,
class: this.config.contentClass class: this.config.contentClass,
}); });
} }
if (this.config.showSaturation) { if (this.config.showSaturation) {
contents.push({ contents.push({
header: "Saturation", header: "Saturation",
data: poolData.status.saturation, data: poolData.status.saturation,
class: this.config.contentClass class: this.config.contentClass,
}); });
} }
if (this.config.showControls) { if (this.config.showControls) {
@ -187,7 +187,7 @@ Module.register("MMM-IntelliCenter", {
}" data-state="${on ? "1" : "0"}"><div class="content">${ }" data-state="${on ? "1" : "0"}"><div class="content">${
name name
}</div></button>`, }</div></button>`,
class: this.config.contentClass class: this.config.contentClass,
}); });
} else if (controlObj.type === "heatpoint") { } else if (controlObj.type === "heatpoint") {
if ( if (
@ -207,7 +207,7 @@ Module.register("MMM-IntelliCenter", {
contents.push({ contents.push({
data: dataHtml, data: dataHtml,
class: this.config.contentClass class: this.config.contentClass,
}); });
} else if (controlObj.type === "heatmode") { } else if (controlObj.type === "heatmode") {
if ( if (
@ -233,7 +233,7 @@ Module.register("MMM-IntelliCenter", {
}" data-state="${on ? "1" : "0"}" data-mode="${mode.toString()}"><div class="content">${ }" data-state="${on ? "1" : "0"}" data-mode="${mode.toString()}"><div class="content">${
controlObj.name controlObj.name
}</div></button>`, }</div></button>`,
class: this.config.contentClass class: this.config.contentClass,
}); });
} else { } else {
Log.warn("circuit with unknown type, unable to display:"); Log.warn("circuit with unknown type, unable to display:");
@ -296,7 +296,7 @@ Module.register("MMM-IntelliCenter", {
} else if (notification === "INTELLICENTER_RECONNECTING") { } else if (notification === "INTELLICENTER_RECONNECTING") {
showReconnectOverlay(true); showReconnectOverlay(true);
} }
} },
}); });
function showReconnectOverlay(show) { function showReconnectOverlay(show) {

View File

@ -3,6 +3,6 @@ import eslint from "@eslint/js";
export default [ export default [
eslint.configs.recommended, eslint.configs.recommended,
{ {
ignores: ["eslint.config.mjs"] ignores: ["eslint.config.mjs"],
} },
]; ];

View File

@ -27,7 +27,7 @@ module.exports = NodeHelper.create({
this.setCircuitState(circuitState, (poolStatus) => { this.setCircuitState(circuitState, (poolStatus) => {
this.sendSocketNotification("INTELLICENTER_CIRCUIT_DONE", { this.sendSocketNotification("INTELLICENTER_CIRCUIT_DONE", {
circuitState, circuitState,
status: poolStatus status: poolStatus,
}); });
}); });
}, },
@ -36,7 +36,7 @@ module.exports = NodeHelper.create({
this.setHeatpointState(heatpoint, (poolStatus) => { this.setHeatpointState(heatpoint, (poolStatus) => {
this.sendSocketNotification("INTELLICENTER_HEATPOINT_DONE", { this.sendSocketNotification("INTELLICENTER_HEATPOINT_DONE", {
heatpoint, heatpoint,
status: poolStatus status: poolStatus,
}); });
}); });
}, },
@ -45,7 +45,7 @@ module.exports = NodeHelper.create({
this.setHeatstateState(heatstate, (poolStatus) => { this.setHeatstateState(heatstate, (poolStatus) => {
this.sendSocketNotification("INTELLICENTER_HEATSTATE_DONE", { this.sendSocketNotification("INTELLICENTER_HEATSTATE_DONE", {
heatstate, heatstate,
status: poolStatus status: poolStatus,
}); });
}); });
}, },
@ -54,7 +54,7 @@ module.exports = NodeHelper.create({
this.setLights(lightCmd, (poolStatus) => { this.setLights(lightCmd, (poolStatus) => {
this.sendSocketNotification("INTELLICENTER_LIGHTCMD_DONE", { this.sendSocketNotification("INTELLICENTER_LIGHTCMD_DONE", {
lightCmd, lightCmd,
status: poolStatus status: poolStatus,
}); });
}); });
}, },
@ -73,7 +73,7 @@ module.exports = NodeHelper.create({
}, },
() => { () => {
this.notifyReconnecting(); this.notifyReconnecting();
} },
); );
} else if (poolData.status) { } else if (poolData.status) {
this.sendSocketNotification("INTELLICENTER_RESULT", poolData); this.sendSocketNotification("INTELLICENTER_RESULT", poolData);
@ -116,7 +116,7 @@ module.exports = NodeHelper.create({
foundUnit foundUnit
.on("error", (e) => { .on("error", (e) => {
Log.error( Log.error(
`[MMM-IntelliCenter] error in unit connection. restarting the connection process in ${reconnectDelayMs / 1000} seconds` `[MMM-IntelliCenter] error in unit connection. restarting the connection process in ${reconnectDelayMs / 1000} seconds`,
); );
Log.error(e); Log.error(e);
@ -128,7 +128,7 @@ module.exports = NodeHelper.create({
}) })
.on("close", () => { .on("close", () => {
Log.error( Log.error(
`[MMM-IntelliCenter] unit connection closed unexpectedly. restarting the connection process in ${reconnectDelayMs / 1000} seconds` `[MMM-IntelliCenter] unit connection closed unexpectedly. restarting the connection process in ${reconnectDelayMs / 1000} seconds`,
); );
reconnectCb(); reconnectCb();
@ -139,7 +139,7 @@ module.exports = NodeHelper.create({
}) })
.once("connected", () => { .once("connected", () => {
Log.info( Log.info(
"[MMM-IntelliCenter] logged into unit. getting basic configuration..." "[MMM-IntelliCenter] logged into unit. getting basic configuration...",
); );
foundUnit.send(new messages.GetSystemInformation()).then(() => { foundUnit.send(new messages.GetSystemInformation()).then(() => {
Log.info("[MMM-IntelliCenter] got it!"); Log.info("[MMM-IntelliCenter] got it!");
@ -147,7 +147,7 @@ module.exports = NodeHelper.create({
}) })
.once("controllerConfig", (config) => { .once("controllerConfig", (config) => {
Log.info( Log.info(
"[MMM-IntelliCenter] configuration received. adding client..." "[MMM-IntelliCenter] configuration received. adding client...",
); );
poolData.controllerConfig = config; poolData.controllerConfig = config;
poolData.degStr = this.config.degC ? "C" : "F"; poolData.degStr = this.config.degC ? "C" : "F";
@ -155,7 +155,7 @@ module.exports = NodeHelper.create({
}) })
.once("addClient", () => { .once("addClient", () => {
Log.info( Log.info(
"[MMM-IntelliCenter] client added successfully and listening for changes" "[MMM-IntelliCenter] client added successfully and listening for changes",
); );
foundUnit.getPoolStatus(); foundUnit.getPoolStatus();
// Connection seems to time out every 10 minutes without some sort of request made // Connection seems to time out every 10 minutes without some sort of request made
@ -163,7 +163,7 @@ module.exports = NodeHelper.create({
() => { () => {
foundUnit.pingServer(); foundUnit.pingServer();
}, },
1 * 60 * 1000 1 * 60 * 1000,
); );
}) })
.on("poolStatus", (status) => { .on("poolStatus", (status) => {
@ -182,7 +182,7 @@ module.exports = NodeHelper.create({
.on("serverFound", (server) => { .on("serverFound", (server) => {
finder.close(); finder.close();
Log.info( Log.info(
`[MMM-IntelliCenter] local unit found at ${server.addressStr}:${server.port}` `[MMM-IntelliCenter] local unit found at ${server.addressStr}:${server.port}`,
); );
foundUnit = new Unit(server.addressStr, server.port); foundUnit = new Unit(server.addressStr, server.port);
@ -193,7 +193,7 @@ module.exports = NodeHelper.create({
}) })
.on("error", (e) => { .on("error", (e) => {
Log.error( Log.error(
`[MMM-IntelliCenter] error trying to find a server. scheduling a retry in ${reconnectDelayMs / 1000} seconds` `[MMM-IntelliCenter] error trying to find a server. scheduling a retry in ${reconnectDelayMs / 1000} seconds`,
); );
Log.error(e); Log.error(e);
this.resetFoundUnit(); this.resetFoundUnit();
@ -205,7 +205,7 @@ module.exports = NodeHelper.create({
finder.search(); finder.search();
unitFinderRetry = setInterval(() => { unitFinderRetry = setInterval(() => {
Log.info( Log.info(
`[MMM-IntelliCenter] didn't find any units within ${unitFinderTimeoutMs / 1000} seconds, trying again...` `[MMM-IntelliCenter] didn't find any units within ${unitFinderTimeoutMs / 1000} seconds, trying again...`,
); );
finder.search(); finder.search();
}, unitFinderTimeoutMs); }, unitFinderTimeoutMs);
@ -219,7 +219,7 @@ module.exports = NodeHelper.create({
this.config.serverPort this.config.serverPort
) { ) {
Log.info( Log.info(
`[MMM-IntelliCenter] connecting directly to configured unit at ${this.config.serverAddress}:${this.config.serverPort}` `[MMM-IntelliCenter] connecting directly to configured unit at ${this.config.serverAddress}:${this.config.serverPort}`,
); );
foundUnit = new Unit(this.config.serverAddress, this.config.serverPort); foundUnit = new Unit(this.config.serverAddress, this.config.serverPort);
} }
@ -238,7 +238,7 @@ module.exports = NodeHelper.create({
} }
Log.info( Log.info(
`[MMM-IntelliCenter] setting circuit ${circuitState.id} to ${circuitState.state}` `[MMM-IntelliCenter] setting circuit ${circuitState.id} to ${circuitState.state}`,
); );
foundUnit.setCircuitState(0, circuitState.id, circuitState.state); foundUnit.setCircuitState(0, circuitState.id, circuitState.state);
foundUnit.getPoolStatus(); foundUnit.getPoolStatus();
@ -251,7 +251,7 @@ module.exports = NodeHelper.create({
} }
Log.info( Log.info(
`[MMM-IntelliCenter] setting heatpoint for body ${heatpoint.body} to ${heatpoint.temperature} deg` `[MMM-IntelliCenter] setting heatpoint for body ${heatpoint.body} to ${heatpoint.temperature} deg`,
); );
foundUnit.setSetPoint(0, heatpoint.body, heatpoint.temperature); foundUnit.setSetPoint(0, heatpoint.body, heatpoint.temperature);
foundUnit.getPoolStatus(); foundUnit.getPoolStatus();
@ -264,7 +264,7 @@ module.exports = NodeHelper.create({
} }
Log.info( Log.info(
`[MMM-IntelliCenter] setting heat state for body ${heatstate.body} to ${heatstate.state}` `[MMM-IntelliCenter] setting heat state for body ${heatstate.body} to ${heatstate.state}`,
); );
foundUnit.setHeatMode(0, heatstate.body, heatstate.state); foundUnit.setHeatMode(0, heatstate.body, heatstate.state);
foundUnit.getPoolStatus(); foundUnit.getPoolStatus();
@ -279,5 +279,5 @@ module.exports = NodeHelper.create({
Log.info(`[MMM-IntelliCenter] sending light command ${lightCmd}`); Log.info(`[MMM-IntelliCenter] sending light command ${lightCmd}`);
foundUnit.sendLightCommand(0, lightCmd); foundUnit.sendLightCommand(0, lightCmd);
foundUnit.getPoolStatus(); foundUnit.getPoolStatus();
} },
}); });