out = rstate1 = 0; // Default variable values. Define as many variables as you need. objec = msg.payload.records; // Retrieved Victron object. // The function to search the Victron object with any keyword. See below how to use it. function dataLayerSearch(data, input) { let found = []; let obj = {}; for (let key in data) { if (typeof data[key] === "object") { found.push(...dataLayerSearch(data[key], input)); } else { if (key === input || data[key] === input) { found.push(obj); found[1] = data.rawValue; obj = {}; } } } return found; } // Below is how you use the function. let bsoc = dataLayerSearch (objec, "State of charge"); // The API parameter description for SOC is "State of charge". let crelay = dataLayerSearch (objec, "Relay 1 state"); // The API parameter description for Venus relay 1 state is "Relay 1 state". //You can define as many variables as contained in the Victron object. //Below define the checks you want to make and what to do with the data //New payload variable is "out". // ---- Ends ---- msg.payload = out;// Modified payload is equivalent to new message in first instance otherwise the default value. return msg;