Adding time into variable data

Having a Analysis that reads the last 2 variable values (v_pulse, v_lastAccumulated) and creates a new one (v_accumulated) that is the sum of first both, how do I set the v_lp timestamp into the new one (v_accumulated)?

v_pulse, v_accumulated should appear in the same row when they appear into a dinamic table based on the timestamp, but not!

const device = new Device({ token: device_token});

const c_lastPulse = {
variable: “pulse1”,
query: “last_value”
const [v_pulse] = await device.getData(c_lastPulse);

  context.log('Last Value - '+require("util").inspect(v_pulse));
  context.log('Value to add: ' +v_pulse.value);
  const v_time = new Date(v_pulse.time).toISOString().replace(/T/, ' ').replace(/\..+/, '');
  context.log('Time to set--'+v_time);  
  const c_lastAccumulated = {
      variable: "accumulated",
      query: "last_value"

  const [v_acc] = await device.getData(c_lastAccumulated);

    context.log('Last Accumulated - '+require("util").inspect(v_acc));

    var v_accumulated = {
      variable: "accumulated",
      value: v_acc.value + v_pulse.value,
      time: v_time

await device
.then(context.log(“Accumulative counter”));

It doesn’t work. I tried timestamps as well…


Hi @arantec,

Tables put in same line variables with same series. So in that case, you should set the same serie from “pulse1” to “acumulated”.

Something like:

    var v_accumulated = {
      variable: "accumulated",
      value: v_acc.value + v_pulse.value,
      time: v_time,
      serie: v_acc.serie //NEW LINE

Regarding the data timestamp, you can use either check “Show time column” (which I recommend)



show time property instead of value →


1 Like

Thank you so much Guilherme! Apparently there is a page that explains it… I didn’t find it! Other concepts…

1 Like