Skip to content

Conversation

ArtemKiyashko
Copy link
Contributor

@ArtemKiyashko ArtemKiyashko commented Jan 19, 2025

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 ArtemKiyashko changed the title Add learn mode support feat:learn/secondary controller mode Jan 19, 2025
@ArtemKiyashko ArtemKiyashko changed the title feat:learn/secondary controller mode feat(ui):learn/secondary controller mode Jan 19, 2025
@ArtemKiyashko ArtemKiyashko changed the title feat(ui):learn/secondary controller mode feat(ui, zwaveclient): learn/secondary controller mode Jan 19, 2025
@robertsLando
Copy link
Member

@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?

Comment on lines +314 to +321
{
name: 'Start',
action: 'startLearnMode',
args: {
confirm:
'Initiate learn mode on primary controller first and then click OK here.',
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add the stop action here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added
image

@robertsLando
Copy link
Member

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

@ArtemKiyashko
Copy link
Contributor Author

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

@robertsLando
Copy link
Member

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
robertsLando previously approved these changes Jan 20, 2025
Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from code side 👍🏼

@ArtemKiyashko
Copy link
Contributor Author

@robertsLando
Copy link
Member

@zwave-js-bot fix lint

@robertsLando
Copy link
Member

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

@robertsLando
Copy link
Member

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
Copy link
Contributor Author

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

@coveralls
Copy link

coveralls commented Jan 20, 2025

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%
Totals Coverage Status
Change from base Build 15416786480: 20.7%
Covered Lines: 3945
Relevant Lines: 20328

💛 - Coveralls

@robertsLando
Copy link
Member

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

@AlCalzone
Copy link
Member

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.

@robertsLando
Copy link
Member

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

@ArtemKiyashko
Copy link
Contributor Author

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

No worries, i have a build with that :)

@robertsLando robertsLando requested a review from AlCalzone April 1, 2025 10:01
@robertsLando
Copy link
Member

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

@polskikrol
Copy link

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.

@ArtemKiyashko
Copy link
Contributor Author

ArtemKiyashko commented Aug 27, 2025

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

@robertsLando robertsLando merged commit c64197f into zwave-js:master Aug 27, 2025
9 of 11 checks passed
@polskikrol
Copy link

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.

@robertsLando
Copy link
Member

cc @AlCalzone

@polskikrol
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants