I mostly use a small part of the id. Like 4 or 6 characters. Similar what git/GitHub also does. Either from the beginning or end of the string. Sometimes ids have the same pattern at the begin and then using the first part of a string would result in the same id.
It is fairly good question since it can occur anywhere. For most of situations bindings use random identifiers which are assigned by framework. In case if your binding supports discovery you can always use representationProperty to overcome issue with different thing ids having same serial number.
if your identifier are long then think of people who will try to use your binding with textual configuration - do you really want them to type this serial number everywhere or let them assign their own “alias”.
From options you have - you can use thing properties or configuration properties to store serial number. By this way thing id becomes less relevant and only one who cares about it is framework itself.
@glhopital - Thanks. The module ext ID is actually logged upon thing discovery and linked to the internal ID, so it would still be easy to debug. Adding that the module ID is used also by end users when configuring Items via config file, maybe another reason to try to keep it short and ease their life.
@splatch - Thanks. Reading here, it seems representationProperty to be more related to device type than to the thing UID - which is what I’m looking for.
@hilbrand - So did I. Unfortunately cannot easily guess the real changing part of the external id as there’s no documentation on how it is generated.
Could it be an acceptable solution to apply some algorithm, like CRC32 for example, to the module ext ID, in order to generate a shorter internal module ID ?
It should not add too much overhead, as the ID hashing would be executed only once during autodiscovery.
This way, modules that are on the same location and whose ext ID is quite similar would still get an unique ID inside the location - which is my scenario.
I wouldn’t make it more complicated than necessary. Using a small part of the serial id should work. If you don’t see any direct pattern between different ids (sometimes the first part is the same) you can probably take any part of the id. My guess is the last part is the safest (similar what git does).