Good afternoon, tell me how to get only the “_value” variable from here [
{“_id”:“E0BB0C-WICATAXR-E0%3ABB%3A0C%3A00%3A25%3A6C”,“VirtualParameters”:{“mac”:{“_object”:false,“_timestamp”:“2024-02-27T14: 54:05.233Z”,“_type”:“xsd:string”,“_value”:“E0:BB:0C:00:25:6C”,“_writable”:false}}}
]
I tried to adjust the template a little
“use strict”;
const http = require(“http”);
let cache = null;
let cacheExpire = 0;
function getMAC(args, callback) {
if (Date.now() < cacheExpire) return callback(null, cache);
http
.get(“http://192.168.70.250:7557/devices?query={“_tags”%3A"NEW"}&projection=VirtualParameters.mac”, (res) => {
if (res.statusCode !== 200)
return callback(
new Error(Request failed (status code: ${res.statusCode})
)
);
let rawData = “”;
res.on(“data”, (chunk) => (rawData += chunk));
res.on(“end”, () => {
let MACAddress = JSON.parse(rawData)[“mac”];
cache = [MACAddress[“_value”]];
cacheExpire = Date.now() + 10000;
callback(null, cache);
});
})
.on(“error”, (err) => {
callback(err);
});
}
exports.getMAC = getMAC
const mac = ext(“test”, “getMAC”);
return {writable: false, value: [mac, “xsd:string”]};
But when I try to declare a value in VirtualParameters I get the error Invalid virtual parameter value attribute