Refactor code and update websocket connection
This commit is contained in:
10
web/main.js
10
web/main.js
@@ -56,7 +56,7 @@ function handleIncomingData(data) {
|
||||
|
||||
function processNodeData(nodeNumber, temperature, humidity, CO2, TVOC) {
|
||||
// Initialize the array for this node if it doesn't exist yet
|
||||
if (!sensorData[nodeNumber]) {
|
||||
if (!nodeNumber[nodeNumber]) {
|
||||
sensorData[nodeNumber] = [];
|
||||
}
|
||||
|
||||
@@ -191,14 +191,16 @@ function updateNodeData(node, temperature, humidity, eCO2, TVOC) {
|
||||
document.getElementById("TVOCStatus").textContent = "Connected";
|
||||
|
||||
// Update the graph
|
||||
liveGraphs[node - 1].updateData(temperature, humidity, eCO2, TVOC);
|
||||
liveGraphs[node - 1].updateGraph();
|
||||
liveGraphs[0].updateData(temperature, humidity, eCO2, TVOC);
|
||||
liveGraphs[0].updateGraph();
|
||||
}
|
||||
|
||||
createNodeData("34:85:18:B5:CF:20");
|
||||
liveGraphs.push(new liveGraph("34:85:18:B5:CF:20"));
|
||||
// Call the function to create the HTML structure
|
||||
for (let i = 1; i <= amountOfNodes; i++) {
|
||||
createNodeData(i);
|
||||
liveGraphs.push(new liveGraph(i));
|
||||
|
||||
}
|
||||
|
||||
// make the graphs
|
||||
|
Reference in New Issue
Block a user