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

feat(ui, zwaveclient): learn/secondary controller mode

Open ArtemKiyashko opened this issue 10 months ago • 14 comments

Add support of "learn mode". Controller can be added to pre-existing network and used as "secondary" controller.

Driver function ref

From Aeotec user manual:

Adding Z-Stick to a Pre-existing Z-Wave network.

This must be done through the host software which takes control of Z-Stick USB adapter while Z-Stick is in SerialAPI-Mode.
Please consult the instruction manual of the host software to add the Z-Stick to a pre- existing Z-Wave network (i.e. “Learn”, “Sync”, “Add as Secondary Controller”, etc.). This function can only be performed via host software.

Screenshots:

Screenshot 2025-01-19 at 13 54 40 image

ArtemKiyashko avatar Jan 19 '25 12:01 ArtemKiyashko

@ArtemKiyashko Thanks for your PR, I was waiting before implementing this as @AlCalzone told me this is not ready for production yet. But I think we could maybe make this clear in the confirm text.

@AlCalzone WDYT?

robertsLando avatar Jan 20 '25 11:01 robertsLando

Also it may have more sense to add this to the nodes manager dialog IMO

robertsLando avatar Jan 20 '25 11:01 robertsLando

Also it may have more sense to add this to the nodes manager dialog IMO

@robertsLando

Not sure if this is node specific functionality, because this is controller level function. E.g. no sense to show this option in Node dialog for controlled devices.

But i can move this option to node dialog if you wish

ArtemKiyashko avatar Jan 20 '25 13:01 ArtemKiyashko

Not sure if this is node specific functionality, because this is controller level function. E.g. no sense to show this option in Node dialog for controlled devices.

Let's see what @AlCalzone opinion about this :) For me it could be ok also as it is now

robertsLando avatar Jan 20 '25 13:01 robertsLando

not sure what is wrong here: https://github.com/zwave-js/zwave-js-ui/actions/runs/12868729333/job/35876826584?pr=4097#step:5:15

:)

ArtemKiyashko avatar Jan 20 '25 13:01 ArtemKiyashko

@zwave-js-bot fix lint

robertsLando avatar Jan 20 '25 13:01 robertsLando

@ArtemKiyashko Lint issues, you should run npm run lint-fix but I asked bot to do it :)

robertsLando avatar Jan 20 '25 13:01 robertsLando

Ok seems bot is having some issues: https://github.com/zwave-js/zwave-js-ui/actions/runs/12869249637/job/35877613209

@ArtemKiyashko could you do that please? Just run that command and it will fix lint

robertsLando avatar Jan 20 '25 13:01 robertsLando

Ok, seems it was "newline" issue. Should be good now

Ok seems bot is having some issues: https://github.com/zwave-js/zwave-js-ui/actions/runs/12869249637/job/35877613209

@ArtemKiyashko could you do that please? Just run that command and it will fix lint

ArtemKiyashko avatar Jan 20 '25 13:01 ArtemKiyashko

Pull Request Test Coverage Report for Build 15493780146

Details

  • 0 of 49 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall first build on feature/learnMode at 20.652%

Changes Missing Coverage Covered Lines Changed/Added Lines %
api/lib/ZwaveClient.ts 0 49 0.0%
<!-- Total: 0 49
Totals Coverage Status
Change from base Build 15416786480: 20.7%
Covered Lines: 3945
Relevant Lines: 20328

💛 - Coveralls

coveralls avatar Jan 20 '25 13:01 coveralls

@ArtemKiyashko As said everything looks good from code side I'm just waiting for @AlCalzone feedback on this :)

robertsLando avatar Jan 21 '25 13:01 robertsLando

Interesting! I'll give this a proper look after the Z-Wave Summit, so roughly in 2 weeks. Too much other stuff to deal with before that.

AlCalzone avatar Jan 27 '25 13:01 AlCalzone

@ArtemKiyashko I can create you a test docker image if you want to use this

robertsLando avatar Jan 27 '25 14:01 robertsLando

@ArtemKiyashko I can create you a test docker image if you want to use this

No worries, i have a build with that :)

ArtemKiyashko avatar Jan 27 '25 15:01 ArtemKiyashko

@AlCalzone I think we could merge this one as well?

robertsLando avatar Jun 27 '25 06:06 robertsLando

Not sure if it is good form to comment on PRs, but also very much interested in this being completed. I have several ZWave devices I can add via my external primary controller, and then test learn mode to see if I can get them onto the secondary controller I use for ZJU. A few enerwave (new) and homeseer (replacement) devices. It is my understanding we cant still add new node or replace when ZJU is attached to a secondary controller, but with this PR we should be able to add to the primary controller and learn via the secondary controller using ZJU functions.

polskikrol avatar Aug 11 '25 17:08 polskikrol

I am not sure if there is anything i can help with. This PR is open for half a year already

ArtemKiyashko avatar Aug 27 '25 13:08 ArtemKiyashko

Ok, so I updated to the newest release. Did a backup of nodes and NVM. Hard reset. I deleted/unpaired old node of the secondary controller on VeraPlus. Initiated the inclusion of a new node.. the connected Aeotec controller connected via USB within Zwave JS. Started learn mode... it almost immediately says that learn mode has completed. VeraPlus picks up the device and attempts to configure it, but gives an error:

Z-Wave device 7275 ERROR: Failed to setup security. Please exclude this device from your system, and then include again..Z-Wave device 7275 ERROR: Failed to setup security. Please exclude this device from your system, and then include again..ERROR: Unable to get any information on node

Tried this process twice, and the same results. The learn mode does not result in the VeraPlus secondary controller to properly configure the Zwave JS as a secondary node.

Now this is strange, as in Zwave JS, I go and attempt to rebuild routes... receive the following:

Rebuild Routes process IN PROGRESS. Healed 27 nodes

However, even manually doing a soft reset or check updates, doesnt populate those 27 nodes in Zwave JS. Instead, I just continue to see the secondary controller only in Zwave JS with ID 1.

Happy to perform some more testing, or provide logs as requested. Just let me know. I can hold off from reloading from backup for now.

polskikrol avatar Aug 28 '25 02:08 polskikrol

cc @AlCalzone

robertsLando avatar Aug 28 '25 06:08 robertsLando

Here is a sample of some of the logs around the learn event:

2025-08-27 22:40:20.492 INFO Z-WAVE: Calling api startLearnMode with args: [ [length]: 0 ]
2025-08-27 22:40:20.507 INFO Z-WAVE: Success zwave api call startLearnMode 0
2025-08-27 22:40:31.967 INFO Z-WAVE: Calling api startLearnMode with args: [ [length]: 0 ]
2025-08-27 22:40:36.373 INFO Z-WAVE: Success zwave api call startLearnMode 0
2025-08-27 22:40:39.029 INFO Z-WAVE: Calling api stopLearnMode with args: [ [length]: 0 ]
2025-08-27 22:40:39.922 INFO Z-WAVE: Calling api stopLearnMode with args: [ [length]: 0 ]
2025-08-27 22:40:43.391 INFO Z-WAVE: Calling api startLearnMode with args: [ [length]: 0 ]
2025-08-27 22:40:43.392 INFO Z-WAVE: Success zwave api call startLearnMode 1
2025-08-27 22:41:01.018 INFO Z-WAVE: Calling api checkForConfigUpdates with args: [ [length]: 0 ]
2025-08-27 22:41:01.614 INFO Z-WAVE: Success zwave api call checkForConfigUpdates undefined
2025-08-27 22:41:06.400 INFO Z-WAVE: Success zwave api call stopLearnMode true
2025-08-27 22:41:06.411 INFO Z-WAVE: Success zwave api call stopLearnMode true
2025-08-27 22:41:09.827 INFO Z-WAVE: Calling api softReset with args: [ [length]: 0 ]
2025-08-27 22:41:37.402 INFO Z-WAVE: Success zwave api call softReset undefined
2025-08-27 22:42:09.469 ERROR APP: Unhandled Rejection, reason: Error: The database is not open!
Error: The database is not open!
    at JsonlDB.set (/usr/src/app/node_modules/@alcalzone/jsonl-db/src/lib/db.ts:642:10)
    at CacheBackedMap.set (/usr/src/app/node_modules/@zwave-js/core/src/values/CacheBackedMap.ts:59:14)
    at ZWaveNode2.addCC (/usr/src/app/node_modules/zwave-js/src/lib/node/Endpoint.ts:164:36)
    at ZWaveNode2.interviewCCs (/usr/src/app/node_modules/zwave-js/src/lib/node/Node.ts:1512:11)
    at ZWaveNode2.interviewInternal (/usr/src/app/node_modules/zwave-js/src/lib/node/Node.ts:1012:20)
    at Driver.interviewNodeInternal (/usr/src/app/node_modules/zwave-js/src/lib/driver/Driver.ts:2464:10)
2025-08-27 22:42:10.467 INFO Z-WAVE: Calling api startLearnMode with args: [ [length]: 0 ]
2025-08-27 22:42:10.648 ERROR APP: Unhandled Rejection, reason: Error: The database is not open!
Error: The database is not open!
    at JsonlDB.set (/usr/src/app/node_modules/@alcalzone/jsonl-db/src/lib/db.ts:642:10)
    at CacheBackedMap.set (/usr/src/app/node_modules/@zwave-js/core/src/values/CacheBackedMap.ts:59:14)
    at ZWaveNode2.addCC (/usr/src/app/node_modules/zwave-js/src/lib/node/Endpoint.ts:164:36)
    at ZWaveNode2.interviewCCs (/usr/src/app/node_modules/zwave-js/src/lib/node/Node.ts:1512:11)
    at ZWaveNode2.interviewInternal (/usr/src/app/node_modules/zwave-js/src/lib/node/Node.ts:1012:20)
    at Driver.interviewNodeInternal (/usr/src/app/node_modules/zwave-js/src/lib/driver/Driver.ts:2464:10)
2025-08-27 22:42:10.659 INFO Z-WAVE: Success zwave api call startLearnMode 0
2025-08-27 22:42:40.923 ERROR APP: Unhandled Rejection, reason: Error: The database is not open!
Error: The database is not open!

Interestingly enough, does look like the secondary controller is picking up the nodes correctly from the networks following learn mode:

2025-08-27 22:15:18.418 CNTRLR   querying controller IDs...
2025-08-27 22:15:18.431 CNTRLR   received controller IDs:
                                   home ID:     0xdfeaaacd
                                   own node ID: 52
2025-08-27 22:15:18.434 CNTRLR   querying controller capabilities...
2025-08-27 22:15:18.446 CNTRLR   received controller capabilities:
                                   controller role:      Secondary
                                   is the SUC:           false
                                   started this network: false
                                   SIS is present:       false
                                   was real primary:     false
2025-08-27 22:15:18.448 CNTRLR   querying additional controller information...
2025-08-27 22:15:18.483 CNTRLR   received additional controller information:
                                   Z-Wave API version:         1 (official)
                                   Z-Wave chip type:           EFR32ZG14 / ZGM130S
                                   node type                   Controller
                                   controller role:            secondary
                                   controller is the SIS:      false
                                   controller supports timers: false
                                   Z-Wave Classic nodes:       1, 2, 3, 4, 5, 6, 7, 9, 12, 13, 16, 18, 19, 22, 
                                 23, 24, 26, 27, 28, 29, 30, 32, 37, 38, 40, 44, 46, 50, 51, 52

z-ui_2025-08-27.log.gz

zwavejs_2025-08-27.log.gz

Attaching logs for both UI and JS.

polskikrol avatar Aug 28 '25 12:08 polskikrol