-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Add-on suggestion finder for USB devices #3922
Conversation
Signed-off-by: Andrew Fiddian-Green <[email protected]>
This reverts commit 14e3349.
@mherwege this is a first draft of a finder for USB device related bindings. => And comments? |
Obviously |
The knx binding has it as an (optional) dependency, probably transitive because I don’t see it appear in the code directly. Be aware there may be plaform issues. E.g. Linux may need write permissions to the device, Windows would need a device driver. |
@mherwege OK I understand. The serial port stuff is useless because serial ports a) have no data about the source, and b) would need to be configured before they could be discovered. I tried to go the USB route because 1) who does serial by any other means than USB these days?, and 2) the stick can report its product, manufacturer, and serial number data (which could be used to check for matches before the serial is actually set up). |
@andrewfg And your idea may very well work. But it will need a lot of testing. It would be useful to find a list of USB product an manufacurer characteristics to math on so not all sticks for zwave and zigbee that can be used with OH need to be tried individually to find the match criteria. |
AFAICT the usb devices only support very limited properties — namely manufacturer, product id, and serial number; so probably in the first step we would just suggest on the manufacturer name. If we need to filter on more specific data, we could add that later. EDIT: alternatively simply match on ‘Z-‘ resp ‘Zi’ in the product names.. :) ?? @mherwege further to my above post, I realise that the core usbSerial discovery classes do have a strong basis for the discovery part as well as the serial part; so I think I can benefit from that after all. More tomorrow.. |
I had a look at it as well. As far as I can understand, this will only work on linux. Embedding one of the libraries I mentioned could potentially make it work for multiple platforms. Apart from that, I think what is there in the code will also have the same constraints I cited above on linux (device must have write permission). This can be documented, en in openhabian it could be made part of the setup scripts. |
Indeed. So I am going back to plan A ( I found the following post in the community, which may help me to import the java4usb module without causing Karaf issues. It seems that this technique has been used in |
Here is the original PR that introduced the functionality in core: eclipse-archived/smarthome#5315 I wonder if it would make sense to work on the core functionality to improve platform support. I am not sure where the core functionality is currently used. For the dependency: I would make this a feature (like mDNS and UPnP finders) that can be installed/uninstalled. In that case, you should be able to add this dependency to the feature. It would only be installed when the feature is enabled. Wouldn't that be enough? |
Did a search, I can only find the Enocean binding as a consumer of the usb discovery service. |
The issue with most USB sticks is that they all use the same FTDI chips which results in discovery false positives. :-/ |
It would also be better to reuse the existing USB discovery mechanism instead of creating a new one. That way you can also suggest add-ons based on ser2net discovery results (#2519). |
@mherwege today's latest commit is now able to find the USB devices (at least the six devices on my Windows system .. listed below).
As you can see, the issue is that the device data returns vendor id codes and product id codes, rather than strings. The vendor id string is available via online lookup (and in the attached pdf). It seems that only certain usb devices include the strings within the device itself.
Sorry but I don't understand.
I did look into that. .. .. |
@wborn it would be nice to do that. But apparently it only works on Linux? And AFAICT it does not read the USB stick vendor name and product name. So it would not be much use in determining if the stick supports a certain functionality, or not. => But if you think that is not the case, please let me know. |
There can be multiple
Does it really read it from the device or does it have some internal database to return names for certain vendor/product IDs? |
I dunno. Still learning. |
Ok. I think I could mis-use the existing disco mechanism. And add a finder for windows too. However the existing disco is for creating things, so the mis-use would be to not create a thing, but that method could create a suggestion instead. |
@mherwege Aargh!! I really don't understand how Karaf works. The documentation is really rubbish! So I wonder if you can kindly help me to eliminate the current CI build error due to the following two dependencies that this finder requires?
|
I often struggle with this as well. I don't think the problem is with your pom file. The error is in the karaf feature verification:
So it must be somewhere in the feature definition, where it cannot find |
I don't think it has an internal DB. The usb4java (http://usb4java.org/index.html) library uses libusb (https://libusb.info/) underneath. This is a native libary that talks to the USB devices, written in C. Multiple platform versions are packaged with usb4java. Looking at teh API for libusb, it has methods to retrieve that info from the device, and I assume that's also what is being used in usb4java. |
I think trying to detect USB serial devices may be opening a can of worms here. Some agreement needs to be reached on path forward. Here are a few observations: Current USB serial discovery
javax.usb
usb4java
I don't see a perfect solution here at the moment. But before going too far in this, I would like to see opinions and consensus being developed. Otherwise we risk spending a lot of time and not getting anywhere. @andrewfg @wborn @kaikreuzer What are your views on this? |
From the code, I think it does (or at least it tries to find it): Line 247 in 4b92db3
|
@mherwege thanks for your many lengthy posts. Just a few short answers..
|
@andrewfg Your understanding is correct. |
081e86b
to
bd2e8f0
Compare
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@mherwege I cannot complete the rebase and have the CI build succeed, because due to the migration from v4.1 to v4.2 somebody changed the spotless formatter parameters which means that it reformats all 138 pom.xml files, and since nobody has yet reformatted the pom.xml files on github main, that means that committing from this PR now would show include all 150 'changed' files into this PR. So I shall have to wait until someone else sorts that mess out. EDIT it has been fixed via #3953 |
Signed-off-by: Holger Friedrich <[email protected]>
b93513b
to
d5adc9a
Compare
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
Signed-off-by: Andrew Fiddian-Green <[email protected]>
I need to change from having vendorId and productId as separate properties, to having a combined chipId property.. |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
What was the reason for this? After all, you could do that already by providing both in the discovery parameters. |
A correct match is an AND of the combination of vendorId and productId. If you look at the following Zigbee example you can see for your self how difficult it would be to code match properties for OR of multiple stick types each having an AND.. |
Signed-off-by: Andrew Fiddian-Green <[email protected]>
...very.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java
Outdated
Show resolved
Hide resolved
...very.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java
Outdated
Show resolved
Hide resolved
...very.addon.usb/src/main/java/org/openhab/core/config/discovery/addon/usb/UsbAddonFinder.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Andrew Fiddian-Green <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the nice enhancement!
This is a small update to align the documentation with last minute changes made in openhab/openhab-core#3922 Signed-off-by: Andrew Fiddian-Green <[email protected]>
This is a small update to align the documentation with last minute changes made in openhab/openhab-core#3922 Signed-off-by: Andrew Fiddian-Green <[email protected]>
This is a small update to align the documentation with last minute changes made in openhab/openhab-core#3922 Signed-off-by: Andrew Fiddian-Green <[email protected]>
This is a service to suggest USB device related add-ons.
For example Z-Wave, Zigbee, or EnOcean sticks.
Signed-off-by: Andrew Fiddian-Green [email protected]
Note: after merging this PR we also need to add the discovery methods to the respective bindings'
addon.xml
files. For example as follows..