timestamp in notification message added
authorebelcrom <ebelcrom@gmail.com>
Fri, 6 Mar 2020 17:43:32 +0000 (18:43 +0100)
committerebelcrom <ebelcrom@gmail.com>
Fri, 6 Mar 2020 17:43:32 +0000 (18:43 +0100)
lib/notify.js

index 0a28a87e20d0a960370864bd661d42662bb038f0..9015e8afc7dae1b6022521e122da84c4ff79c305 100644 (file)
@@ -4,6 +4,7 @@ const gpio = require('./gpio');
 const settings = require('./../init/settings.json');
 const fs = require('fs');
 const webpush = require('web-push');
+const dateformat = require('dateformat');
 
 var data = {
   area: null,
@@ -67,8 +68,10 @@ function executeNotification(notification) {
 
   const icon = 'data:image/png;base64,' +
     fs.readFileSync(__dirname + '/../public/images/icon.png', 'base64');
+  const now = new Date();
+  const timestamp = dateformat(now, 'ddd mmm dd yyyy HH:MM:ss Z');
   const payload = {
-    message: 'The garage door is open!',
+    message: 'The garage door is open!\n' + timestamp,
     icon: icon
   };
   log.debug('Paylod length:', JSON.stringify(payload).length);