value part (3rd parameter) looks like it represents the number of instances you require, so specifiying “{ path: 3}” will make sure I get 3 (three) Bridge instances - if current config contains less than 3, missing will be created, if more than 3 exist, those with highest numbers will be removed.
Still having trouble how to list all present instances, as I cannot be 100% sure, that instance numbers are sequential. For example, first deleting instance #3 and than adding a new one, the sequential number of newly added instance is NOT 3, but 4. And if I keep repeating delete + add (for whatever reason), resulting instance numbers can look like 1,2,15, not 1,2.3.
Yes, factory reset “solves” this “issue”, but… Not a preferred method of “doing business”.
New issue: how do I examine what declare returned? Normal iteration just does nothing. Logging the returned value returns “[object Object]”, but have not find a way to retrieve Object keys/parameters/properties. Should behave as an JS object, but it does not…
I did check debug logs and device does return a range of values, I just don’t seem to find how to read those values in Provisions script.
Am I really the only one with these issues? What am I doing wrong?
When you add instances with the declare, the return object is an iterator. You can iterate over it with “for” (in the example I declare I want 3 bridges … if there is only one on the device it will add 2; if there are 4, it will delete 1 … etc):
let bridges = declare(“Device.Bridging.Bridge.*”, null, { path: 3});
for (let i of bridges) {
console.log(i.path);
}
this will log all 3 existing paths, like so:
Device.Bridging.Bridge.1
Device.Bridging.Bridge.5
Device.Bridging.Bridge.15