poolData = {}; Module.register("MMM-ScreenLogic",{ defaults: { showPoolTemp: true, showSpaTemp: true, showPH: true, showOrp: true, showSaltLevel: true, showSaturation: true, showFreezeMode: true, colored: true, coldTemp: 84, hotTemp: 90, columns: 3, contentClass: "light" }, start: function() { this.sendSocketNotification('SCREENLOGIC_CONFIG', this.config); this.sendSocketNotification('SCREENLOGIC_UPDATE'); }, getStyles: function() { return ["screenlogic.css"]; }, getDom: function() { if (!poolData.status) { var wrapper = document.createElement("div"); wrapper.innerHTML = 'Loading...'; wrapper.className += "dimmed light small"; return wrapper; } else { var table = document.createElement('table'); table.className = "small"; if (this.config.colored) { table.className += " colored"; } var contents = []; if (this.config.showPoolTemp) { var className = ""; if (poolData.status.currentTemp[0] <= this.config.coldTemp) { className += " cold-temp"; } else if (poolData.status.currentTemp[0] >= this.config.hotTemp) { className += " hot-temp"; } contents.push({ header: "Pool temp", data: poolData.status.currentTemp[0] + "°" + (!isPoolActive(poolData.status) ? " (last)" : ""), class: this.config.contentClass + className }); } if (this.config.showSpaTemp) { var className = ""; if (poolData.status.currentTemp[1] <= this.config.coldTemp) { className = " cold-temp"; } else if (poolData.status.currentTemp[1] >= this.config.hotTemp) { className = " hot-temp"; } contents.push({ header: "Spa temp", data: poolData.status.currentTemp[1] + "°" + (!isSpaActive(poolData.status) ? " (last)" : ""), class: this.config.contentClass + className }); } if (this.config.showPH) { contents.push({ header: "pH", data: poolData.status.pH, class: this.config.contentClass }); } if (this.config.showOrp) { contents.push({ header: "ORP", data: poolData.status.orp, class: this.config.contentClass }); } if (this.config.showSaltLevel) { contents.push({ header: "Salt PPM", data: poolData.status.saltPPM, class: this.config.contentClass }); } if (this.config.showSaturation) { contents.push({ header: "Saturation", data: poolData.status.saturation, class: this.config.contentClass }); } var headerRow = null; var contentRow = null; if (this.config.showFreezeMode && poolData.status.freezeMode !== 0) { var row = document.createElement('tr'); table.appendChild(row); row.className = 'cold-temp'; var cell = document.createElement('th'); row.appendChild(cell); cell.colSpan = this.config.columns; cell.innerHTML = '