zwave-js-ui
zwave-js-ui copied to clipboard
[feat] Duplicate configuration from device to another devices
Is your feature request related to a problem? Please describe. No related problem
Describe the solution you'd like I'm using jeedom and my previous solution (openzwave), i was able to copy selected or all parameters from a device to another (of course same type of device, device such as fibaro motion sensor have a lot of parameters) Into actions / advanced, we could have an icon to duplicate config from a device to another.
Describe alternatives you've considered Manual for the moment but sometimes we can forget to set same parameters everywhere
Do you think it could be possible ?
Thanks
It could be possible, dunno if there is any internal method on zwave-js to easily handle this @AlCalzone
nope, this is outside the driver scope IMO
So a possible implementaion of this could be parsing all actual configuration values and send write requests one by one?
Hello,
Anys news ?
Thanks
No time right now
As mentioned in #2056, a more broad approach could be to export/import configuration values to/from a file. That would make it possible to back up device configs as well as copy configs from one device to another.
What you could do right now is to copy the values of a node from the node debug tab and use them inside a driver function
I'll look into driver functions. Thanks!
@kdknigga @davidwaze try send this, just change the node id of node and clonedNode
const node = this.zwaveClient.getNode(5)
const clonedNode = this.zwaveClient.getNode(10)
const values = node.getDefinedValueIDs()
for(const v of values) {
if(v.commandClass === 112) {
const value = node.getValue(v)
await clonedNode.setValue(v, value)
}
}
@kdknigga Is that working? Did you test it?
Doesn't look like it worked. I tried your example and got this in the logs:
2021-12-15 10:04:19.354 INFO ZWAVE: Calling api driverFunction with args: [
'const node = this.zwaveClient.getNode(50)\n' +
'const clonedNode = this.zwaveClient.getNode(51)\n' +
'\n' +
'const values = node.getDefinedValueIDs()\n' +
'\n' +
'for(const v of values) {\n' +
'\tif(values.commandClass === 112) {\n' +
'\t\tconst value = node.getValue(v)\n' +
'\t\tawait clonedNode.setValue(v, value)\n' +
'\t}\n' +
'}\n',
[length]: 1
]
2021-12-15 10:04:19.387 INFO ZWAVE: Success zwave api call driverFunction undefined
Then, based on the example function provided by the GUI, I tried:
const node = driver.controller.nodes.get(50)
const clonedNode = driver.controller.nodes.get(51)
const values = node.getDefinedValueIDs()
for(const v of values) {
if(values.commandClass === 112) {
const value = node.getValue(v)
await clonedNode.setValue(v, value)
}
}
And got this:
2021-12-15 10:07:05.568 INFO ZWAVE: Calling api driverFunction with args: [
'const node = driver.controller.nodes.get(50)\n' +
'const clonedNode = driver.controller.nodes.get(51)\n' +
'\n' +
'const values = node.getDefinedValueIDs()\n' +
'\n' +
'for(const v of values) {\n' +
'\tif(values.commandClass === 112) {\n' +
'\t\tconst value = node.getValue(v)\n' +
'\t\tawait clonedNode.setValue(v, value)\n' +
'\t}\n' +
'}\n',
[length]: 1
]
2021-12-15 10:07:05.599 INFO ZWAVE: Success zwave api call driverFunction undefined
After both attempts nothing on node 51 had changed.
@AlCalzone Any tips ?
The usual: Look at driver logs :)
@AlCalzone I mean if you have tips about the driver function, it should work like that right?
I thought so, but on 2nd glance there is a typo:
const node = driver.controller.nodes.get(50)
const clonedNode = driver.controller.nodes.get(51)
const values = node.getDefinedValueIDs()
for(const v of values) {
- if(values.commandClass === 112) {
+ if(v.commandClass === 112) {
const value = node.getValue(v)
await clonedNode.setValue(v, value)
}
}
Ok @kdknigga I have fixed my previous function, try it. Thanks @AlCalzone for spotting that :)
Hm, he already did use v
if I'm not mistaken.
const node = driver.controller.nodes.get(50)
const clonedNode = driver.controller.nodes.get(51)
const values = node.getDefinedValueIDs()
for(const v of values) {
if(v.commandClass === 112) {
const value = node.getValue(v)
await clonedNode.setValue(v, value)
}
}
totally worked! Thanks!
@davidwaze , here's the method for cloning a device's config to another.
Snippets has been introduced with #2620 so this could be considered fixed now
I look forward to playing around with this new feature. Thanks!