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

Inconsistent processing of discovery properties #834

Open
pgaufillet opened this issue May 22, 2024 · 1 comment
Open

Inconsistent processing of discovery properties #834

pgaufillet opened this issue May 22, 2024 · 1 comment

Comments

@pgaufillet
Copy link
Contributor

Hi!

I think I have found an inconsistency in the way discovery properties are managed. In ZigBeeNodePropertyDiscoverer.java, l.170 and l.179, the PROPERTY_VENDOR and PROPERTY_MODEL_ID are trimmed out:

properties.put(Thing.PROPERTY_VENDOR, manufacturer.trim());

properties.put(Thing.PROPERTY_MODEL_ID, model.trim());

It removes whitespaces and invisible characters from both ends of the String.
But since 2022, it is possible to specify any unicode characters in discovery.txt. In ZigBeeThingTypeMatcher.java:

newProperties.add(new RequiredProperty(discoveryElement[0].trim(), unescape(discoveryElement[1].trim())));

It is used in particular for Legrand devices:

legrand_dimmer_without_neutral,vendor=\u001f Legrand,modelId=\u001f Dimmer switch w/o neutral

In this case, '\u001f ' never matches. And it is indeed what I observe with OpenHab Zigbee 4.1.2: Legrand Dimmers are not correctly recognized. There are 2 options for solving this issue:

  1. Remove the invisible characters from discovery.txt from the ends of the properties (in this case, unescape() has only a role for characters between visible characters),
  2. Remove the trim() function calls from ZigBeeNodePropertyDiscoverer.java (in this case, the recognition of vendor specific devices shall be revalidated).
@cdjackson
Copy link
Contributor

I think I would probably opt for the first option. IIRC we otherwise had problems in the past with whitespace and it feels more robust to me to remove the unprintable characters.

I'm open to being convinced otherwise though if there's a strong reason...

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

No branches or pull requests

2 participants