From 9d97d8f89bc570b1232c0dd8450f489b39023e18 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sat, 31 Oct 2015 14:28:11 +0100 Subject: core/web: o Adding last_timestamp o Showing last_value and last_timestamp for each property. --- src/Diller.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Diller.js') diff --git a/src/Diller.js b/src/Diller.js index edb501d..46dc8e2 100644 --- a/src/Diller.js +++ b/src/Diller.js @@ -3,14 +3,14 @@ var _ = require('lodash'); function Diller(config, pg, dao) { var log = config.log(); - function newValue(dao, device, property, value) { + function newValue(dao, device, property, timestamp, value) { log.info('new value for device ' + device.key + '/' + property.key + ' = ' + value, { deviceId: device.id, propertyId: property.id, value: value }); - return dao.insertValue(property.id, value) + return dao.insertValue(property.id, timestamp, value) .then(function (res) { // ignore the result updateAggregates(property.id, res.timestamp); @@ -18,13 +18,13 @@ function Diller(config, pg, dao) { }); } - function newName(dao, device, property, name) { + function newName(dao, device, property, timestamp, name) { log.info('New name for property ', device.key + '/' + property.key + '.name = ' + name); return dao.updatePropertyName(property.id, name); } - function newDescription(dao, device, property, description) { + function newDescription(dao, device, property, timestamp, description) { log.info('New description for property ', device.key + '/' + property.key + '.description = ' + description); return dao.updatePropertyDescription(property.id, description); @@ -56,6 +56,8 @@ function Diller(config, pg, dao) { //noinspection JSUnusedLocalSymbols function onMessage(topic, message, payload) { + var timestamp = new Date(); + var parts = topic.split(/\//); log.info('Processing message to ' + topic); @@ -108,7 +110,7 @@ function Diller(config, pg, dao) { }) .then(function (data) { // log.info('data.device', data.device, 'data.property', data.property); - return f(dao, data.device, data.property, message.toString()); + return f(dao, data.device, data.property, timestamp, message.toString()); }) .then(function (res) { log.warn('success', res); -- cgit v1.2.3