Skip to content

Commit 427c644

Browse files
ptvoinfoptvoinfo
and
ptvoinfo
authored
fix: Fixes in ptvo.switch converter (#7993)
* Fixes in ptvo.switch converter * Formatting fixes --------- Co-authored-by: ptvoinfo <[email protected]>
1 parent 305d492 commit 427c644

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/devices/custom_devices_diy.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ const definitions: DefinitionWithExtend[] = [
359359
let epConfig;
360360
for (let i = 0; i < deviceConfigArray.length; i++) {
361361
epConfig = deviceConfigArray[i];
362-
const epId = parseInt(epConfig.substr(0, 1), 16);
363-
if (epId <= 0) {
362+
const matches = epConfig.match(/^([0-9A-F]+)/);
363+
if (!matches || matches.length == 0) {
364364
continue;
365365
}
366-
if (epId < 10) {
367-
epConfig = '0' + epConfig;
368-
}
366+
const epId = parseInt(matches[0], 16);
367+
const epId2 = epId < 10 ? '0' + epId : epId;
368+
epConfig = epConfig.replace(/^[0-9A-F]+/, epId2);
369369
allEndpoints[epId] = '1';
370370
allEndpointsSorted.push(epConfig);
371371
}

0 commit comments

Comments
 (0)