Adding time into variable data

Adding time into variable data

@Arantec Developer

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
.sendData(v_accumulated)
.then(context.log(“Accumulative counter”));

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

Screenshot_20210812_153930