zwave-js-ui icon indicating copy to clipboard operation
zwave-js-ui copied to clipboard

[feat] Duplicate configuration from device to another devices

Open davidwaze opened this issue 2 years ago • 18 comments

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

davidwaze avatar Nov 02 '21 12:11 davidwaze

It could be possible, dunno if there is any internal method on zwave-js to easily handle this @AlCalzone

robertsLando avatar Nov 03 '21 14:11 robertsLando

nope, this is outside the driver scope IMO

AlCalzone avatar Nov 03 '21 16:11 AlCalzone

So a possible implementaion of this could be parsing all actual configuration values and send write requests one by one?

robertsLando avatar Nov 03 '21 16:11 robertsLando

Hello,

Anys news ?

Thanks

davidwaze avatar Dec 01 '21 09:12 davidwaze

No time right now

robertsLando avatar Dec 02 '21 13:12 robertsLando

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.

kdknigga avatar Dec 14 '21 16:12 kdknigga

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

robertsLando avatar Dec 14 '21 16:12 robertsLando

I'll look into driver functions. Thanks!

kdknigga avatar Dec 14 '21 16:12 kdknigga

@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)
	}
}


robertsLando avatar Dec 14 '21 16:12 robertsLando

@kdknigga Is that working? Did you test it?

robertsLando avatar Dec 15 '21 09:12 robertsLando

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.

kdknigga avatar Dec 15 '21 16:12 kdknigga

@AlCalzone Any tips ?

robertsLando avatar Dec 15 '21 16:12 robertsLando

The usual: Look at driver logs :)

AlCalzone avatar Dec 15 '21 16:12 AlCalzone

@AlCalzone I mean if you have tips about the driver function, it should work like that right?

robertsLando avatar Dec 15 '21 17:12 robertsLando

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)
	}
}

AlCalzone avatar Dec 15 '21 17:12 AlCalzone

Ok @kdknigga I have fixed my previous function, try it. Thanks @AlCalzone for spotting that :)

robertsLando avatar Dec 15 '21 17:12 robertsLando

Hm, he already did use v if I'm not mistaken.

AlCalzone avatar Dec 15 '21 17:12 AlCalzone

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.

kdknigga avatar Dec 15 '21 21:12 kdknigga

Snippets has been introduced with #2620 so this could be considered fixed now

robertsLando avatar Sep 02 '22 12:09 robertsLando

I look forward to playing around with this new feature. Thanks!

kdknigga avatar Sep 02 '22 15:09 kdknigga