diff --git a/src/custom_modules/HestiaClasses.js b/src/custom_modules/HestiaClasses.js index 1f22636..cc91ead 100644 --- a/src/custom_modules/HestiaClasses.js +++ b/src/custom_modules/HestiaClasses.js @@ -148,6 +148,8 @@ module.exports = { // this.emit('announcement', 'Message is from the frontend, updating state'); // Update the state state[msgJson.name] = msgJson; + // Log the timstamp if it's there + if (msgJson.timestamp) console.log('Timestamp:', msgJson.timestamp); // Emit the state change this.emit('stateChange', oldState, state); } else if (topic === 'hestia/command/startup') { @@ -193,6 +195,11 @@ module.exports = { // Publish a message to the MQTT Broker send(topic, message) { + // Append a timestamp onto 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) {