Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improved adapter discovery. #1197

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Nerivec
Copy link
Collaborator

@Nerivec Nerivec commented Sep 22, 2024

TODO:

  • Update Adapter.create (should remove most of the logic)
  • Remove adapter.autoDetectPath, adapter.isValidPath and definitions in all drivers
  • Complete fingerprints. Closes feat: add auto-detection of CC2652P #1071

@Nerivec
Copy link
Collaborator Author

Nerivec commented Sep 23, 2024

@kirovilya Can you provide a fingerprint for the nordic adapter? I'll clean up the matching/tests with it.

import {SerialPort} from 'zigbee-herdsman/dist/adapter/serialPort.js';

const list = await SerialPort.list();

console.log(list);

@kirovilya
Copy link
Contributor

@kirovilya Can you provide a fingerprint for the nordic adapter? I'll clean up the matching/tests with it.

for this? https://github.com/Koenkk/zigbee-herdsman/blob/master/src/adapter/zboss/adapter/zbossAdapter.ts#L24

@Nerivec
Copy link
Collaborator Author

Nerivec commented Sep 23, 2024

Whatever comes out of the bit of code I mentioned above should have it all; mostly the path. This PR improves upon the discovery a bit, more refined using regex matching against the paths.

See the adapterDiscovery.ts file in the PR, in case you can provide more missing fingerprints 😉

@kirovilya
Copy link
Contributor

Whatever comes out of the bit of code I mentioned above should have it all; mostly the path. This PR improves upon the discovery a bit, more refined using regex matching against the paths.

See the adapterDiscovery.ts file in the PR, in case you can provide more missing fingerprints 😉

{
    manufacturer: 'ZEPHYR',
    serialNumber: '54ACCFAFA6DADC49',
    pnpId: 'usb-ZEPHYR_Zigbee_NCP_54ACCFAFA6DADC49-if00',
    locationId: undefined,
    vendorId: '2fe3',
    productId: '0100',
    path: '/dev/ttyACM0'
  },

and in windows


  {
  path: 'COM22',
  manufacturer: 'Корпорация Майкрософт',
  serialNumber: '6&11E6BDCD&1&0000',
  pnpId: 'USB\\VID_2FE3&PID_0100&MI_00\\6&11E6BDCD&1&0000',
  locationId: '0000.0014.0000.009.000.000.000.000.000',
  friendlyName: 'Устройство с последовательным интерфейсом USB (COM22)',
  vendorId: '2FE3',
  productId: '0100'
},

@kirovilya
Copy link
Contributor

there is also a proposal to extract the serial port from the adapters and transfer the ready-made connection inside.
connection and reconnection control can also be performed outside the adapter

@Nerivec
Copy link
Collaborator Author

Nerivec commented Sep 24, 2024

It would require adding more variables to Adapter that can be overridden in subclasses to have the proper settings for serial/socket ports (hw/sw, stop bits, parity, watermark, etc.) since these can vary. Parser/writer would have to stay in adapters too, since these are very different in most cases (or would require an even bigger refactoring).
Probably wouldn't be bad to have just the writer instance and a parser callback function passed to adapters, but at first glance, it's a pretty large refactor.

pathRegex: '.*SLZB-07p7.*',
},
{
// TubesZB ?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tube0013 Can you take a look at the TubesZB fingerprints and confirm the data? If you can also provide the fingerprints for your other devices, that'd be great.

Choose a reason for hiding this comment

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

I'm going to be adopting the generic zeroconf/mdns discovery coming to HA/ZHA: home-assistant/core#126294

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are for USB. You don't have any USB device? I found a couple of fingerprints in zigpy code, but maybe they are no longer relevant?

Copy link

@tube0013 tube0013 Sep 30, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did you set the manufacturer property as well? (that would add an extra bit of info to match against).

Copy link

Choose a reason for hiding this comment

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

I set product string to "TubesZB" and serial is set as 971207DO or 971229NY

At least on the ch340b I'm not aware how to write a manufacturer string.

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