We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 305d492 commit 427c644Copy full SHA for 427c644
src/devices/custom_devices_diy.ts
@@ -359,13 +359,13 @@ const definitions: DefinitionWithExtend[] = [
359
let epConfig;
360
for (let i = 0; i < deviceConfigArray.length; i++) {
361
epConfig = deviceConfigArray[i];
362
- const epId = parseInt(epConfig.substr(0, 1), 16);
363
- if (epId <= 0) {
+ const matches = epConfig.match(/^([0-9A-F]+)/);
+ if (!matches || matches.length == 0) {
364
continue;
365
}
366
- if (epId < 10) {
367
- epConfig = '0' + epConfig;
368
- }
+ const epId = parseInt(matches[0], 16);
+ const epId2 = epId < 10 ? '0' + epId : epId;
+ epConfig = epConfig.replace(/^[0-9A-F]+/, epId2);
369
allEndpoints[epId] = '1';
370
allEndpointsSorted.push(epConfig);
371
0 commit comments