Skip to content

Commit

Permalink
Merge pull request #18 from sacconazzo:develop
Browse files Browse the repository at this point in the history
light data on mqtt and socket
  • Loading branch information
sacconazzo authored Sep 15, 2024
2 parents 202a6b5 + ba0ce07 commit 5cad581
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,15 @@ const share = async () => {
},
});

io.emit("data", app._data);
app._dataFlat = {
system,
dayWeek: dayWeek[dayWeek.length - 1],
realtime: realtime[realtime.length - 1],
};

io.emit("data", app._dataFlat);

mqttClient.publish("data", JSON.stringify(app._data), {
mqttClient.publish("data", JSON.stringify(app._dataFlat), {
qos: 1,
retain: true,
});
Expand All @@ -118,7 +124,7 @@ const share = async () => {
cron.schedule(shareInterval, share);
share();

app.get("/data", async (req, res) => res.json(await db.realTime()));
app.get("/data", (req, res) => res.json(app._dataFlat));

// BUTTONS
if (process.env.ENABLE_BUTTONS === "true") {
Expand Down

0 comments on commit 5cad581

Please sign in to comment.