I’m trying to use an edge action to update a single component of a virtual resource. For example, my virtual resource looks like this:
And I want to update/change the value of virtual/alarmVals/value/3538303131051215
So in my edge action write the following:
var returnPath = ""
var result = {}
returnPath = "vr://alarmVals/value/3538303131051215"
result[returnPath] = [{
"alarms": {stuff},
"setPoints": {stuff}
"uuid": "something"
}]
return result
But instead of updating the existing value, it adds a new “value” component to the json structure and slaps my new content there. Whatever I try for the path it always seems to add a new “value” key. Is this because I’m inserting an array? I haven’t been able to successfully update a VR not as an array…
Thanks for the help
Hello Lachlan,
Try something like this:
var telemetry = {
“alarms”: {stuff},
“setPoints”: {stuff}
“uuid”: “something”
}
return {
“vr://alarmVals/value/3538303131051215”: [telemetry] // or
“dh://virtual/alarmVals/value/3538303131051215”: [telemetry]
}
}
Hey David,
The first option gives me the same result and the second option doesn’t update the virtual resource at all.
Its as if it automatically adds a “/value” to the end of the path and adds the data there.
If I leave the path as “vr://alarmVals/value/3538303131051215”, it puts it at:
“vr://alarmVals/value/3538303131051215/value”.
If I then update the path to “vr://alarmVals/value/3538303131051215/value”, it puts it at:
“vr://alarmVals/value/3538303131051215/value/value”.
I already have a structure that doesn’t end with “/value”, so it seems like I cant update it without the system adding a new level. Is there a way to make it not do this? Is this the intentional behavior?
Hi lachlan,
To write to a Virtual Resource please use the following syntax:
return {
"vr://myNewResource": ["Hi there!"]
}
You have syntax examples in the Edge Action editor page, at the bottom right select DOCUMENTATION and then “Create/update a virtual resource”.
vr://
automatically appends /value
on purpose to ease the write.
Nested paths like /alarmVals/value/3538303131051215
are not supported.
HTH,
Nicolas