I registered two Zigbee devices and obtained the device flow card for each, then registered an autocomplete listener. However, the autocomplete listeners for Device 1 and Device 2 are both called with the listener of the last registered Device 2. I am curious about how to register separate autocomplete listeners for each device.
To make sure you are aware of the forum rules, please read the Welcome to the forum! post here.
Please use pre-formatted text in future so that other users can see easily that this is code, a device interview, protocols, etc. So everything that you haven’t typed in yourself, except for quotations.
These pre-formatted texts can also be copied for other users with just a single click, which reduces the workload for other users, especially for the app developers.
Thanks for the heads-up, Dijker. I was having the same issue and came across this thread while searching for a solution. The note about pre-formatted code makes a lot of sense, definitely helps with readability and troubleshooting.
I’m also curious if there’s a known pattern or workaround for assigning unique autocomplete listeners per device instance. It seems like the listener is being overridden globally, even though it’s registered per device. Has anyone managed to separate them successfully?
A device listener should be registered once per driver and the device instance is passed in, so you could use something within the device to determine how you fill in the list.
Note: That’s from memory as I don’t have access to a computer this week, so I could be wrong
In addition: The listener is registered once. If you need it in several drivers, just implement it in your app.js.
The device instance is passed to the handler as parameter. Then call a device merhod to read the data you want to present in the auto complete list.
I’m doning rhe same also for flow actions etc.
One registration in app.js and from there call the device method to do the flow action (awaiting the result).