Loopback VirtualParameters - good or evil?
Alexander Münn
muenn at telta.de
Mon Jul 3 05:42:05 EDT 2017
Hello,
One of my provision scripts generates some values that need to be
exported so that they become readable from the GUI. First, I thought
using VirtualParameters in this case is straight forward, but ended up
with try and error. Mostly because the documentation at [1] seems to be
a bit out-dated? It states that "Virtual parameter scripts don't have
the variable args" and further "Virtual parameter scripts have the
variables timestamps and values.".
In contrast the sandbox doesn't provide either 'timestamps' or 'values'
variable. Instead I see the args array containing always(?) four
objects. After some experimenting my interpretation of each element is:
args[0] - reference timestamp on read access; empty on set
args[1] - value object for writes; empty on get
args[2] - some timestamps ?
args[3] - last read value from device parameters
On top of that I'm using following (loopback) VirtualParameter
definition:
const next = args[1];
const last = args[3];
/* default value */
if (!last.value) {
last.value = ["", "xsd:string"];
}
return {writable: true, value: next.value ? next.value : last.value};
I'd like to discuss this "feature". Does anybody already use this or
something similar? Is the calling API to virtual parameter scripts
stable in this way? --Alex
[1] https://github.com/zaidka/genieacs/wiki/Virtual-Parameters
More information about the Users
mailing list