diff --git a/src/assets/HestiaClasses.js b/src/assets/HestiaClasses.js index 1c0912a..86520c3 100644 --- a/src/assets/HestiaClasses.js +++ b/src/assets/HestiaClasses.js @@ -86,6 +86,7 @@ export class Communicator { const msgStr = message.toString(); const msgJson = JSON.parse(msgStr); console.log(`Message received on topic ${topic}: ${msgStr}`); + if (msgJson.timestamp) console.log(`Timestamp: ${msgJson.timestamp}`); console.log(msgJson); state[msgJson.name].on = msgJson.on; if (msgJson.feedRate) state[msgJson.name].feedRate = msgJson.feedRate; @@ -95,6 +96,10 @@ export class Communicator { // Publish a message to the MQTT Broker send(topic, message) { + // Append timestamp to the message + const msgJson = JSON.parse(message); + msgJson.timestamp = Date.now(); + message = JSON.stringify(msgJson); // Publish with retain flag set to true this.client.publish(topic, message, { retain: true }, (err) => { if (err) {