Get Timestamp of value in provision

Hi,

I understand that I can refresh values based on the timestamp of that value from the Database.
E.g.

let manufacturer = declare("InternetGatewayDevice.DeviceInfo.Manufacturer", { value: 1 }).value[0];

does not re-read the value from the device if it already exists on the database. However is there any way I can get the timestamp within my provision at the time the value has been gathered from the device / written to the database (i.e. the one which I see in the UI when I mouseover the entry)?

you are giving 1 as the timestamp for the value you want to receive and this means that genieacs will refresh the value from the device only if it is missing from the database. To read the current value from the device you must provide the current timestamp:

const now = Date.now();
let manufacturer = declare("InternetGatewayDevice.DeviceInfo.Manufacturer", { value: now }).value[0];

Hi lavira,

exactly. However my questions here is not how I get the most current value from the device but how to find out what the timestamp of that value is from the time it has been written to the database. Or let’s say the “age” of that value seen from the GenieACS standpoint.

E.g. sometimes I want to grab the most current values Date.now() (obviously the timestamp / age of that is “Date.now()”). Sometimes I like to grab the value every 24h Date.now(24 * 60 * 60 * 1000) or any other longer interval. However I don’t know the age of that value when running the provision more often than my date-function.

Hope that makes it a bit more clear.

Oh, I see … I don’t think you can access this info from inside the provisioning scripts as these run inside a sandbox. If you try to read the data from outside via the API calls, you receive also the database timestamp and if the value is writable …etc. But you don’t really need to find out the timestamp if all you want it to grab data every X hours … you can achieve that by:

  • adding a cron expression to the preset that is running the provision script
  • manipulate the timestamp to reflect the interval that you want, something like:
let now=Date.now();

// every 24h
now=now-now%(24*60*60*1000);

// every 3 hours
now=now-now%(3*60*60*1000);

I currently have the same problem.
I want to know, if a values was read in the current session or not without triggering a reading of that value.
I have tried the way over the api from external, did not work as I intended.