Skip to content

Commit

Permalink
fix: more generic snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Sep 2, 2022
1 parent bd09413 commit 40fd4c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
- [Managing Nodes](usage/nodes-management.md)
- [Accessing From Behind a Proxy](usage/reverse-proxy.md)
- [Driver function](usage/driver_function.md)


- Device Support
- [Supported and "Unknown" Devices](device-support/supported-unknown-devices.md)
Expand Down
21 changes: 13 additions & 8 deletions snippets/clone-config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
const node = driver.controller.nodes.get(50)
const clonedNode = driver.controller.nodes.get(51)
// replace `undefined` with the id of the node you want to clone
const node = driver.controller.nodes.get(undefined);

// list here all the nodes ids you want to copy configuration to
const clonedNodes = [].map(n => driver.controller.nodes.get(n));

const values = node.getDefinedValueIDs()

for(const v of values) {
// clone only configuration CC values
if(v.commandClass === 112) {
const value = node.getValue(v)
await clonedNode.setValue(v, value)
}
for (const clonedNode of clonedNodes) {
for(const v of values) {
if(v.commandClass === 112) {
await clonedNode.setValue(v,
node.getValue(v)
)
}
}
}

0 comments on commit 40fd4c5

Please sign in to comment.