Skip to content

Commit

Permalink
endpoint in definition.toZigbee can be an array of string (#24525)
Browse files Browse the repository at this point in the history
* `endpoint` in definition.toZigbee can be an array of string
To allow the selection of the proper converter with multi endpoints divice
This change corrects issue #24352
This change is linked to PR Koenkk/zigbee-herdsman-converters#8190

* Simplify Tz.Converter.endpoints type to string[] array only
In zigbee-herdsman-converters\src\lib\types.ts

* Update publish.ts

---------

Co-authored-by: Koen Kanters <[email protected]>
  • Loading branch information
Zitrium31 and Koenkk authored Nov 2, 2024
1 parent f473868 commit 8d9db22
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/extension/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ export default class Publish extends Extension {
if (usedConverters[endpointOrGroupID] === undefined) usedConverters[endpointOrGroupID] = [];
/* istanbul ignore next */
// Match any key if the toZigbee converter defines no key.
const converter = converters.find((c) => (!c.key || c.key.includes(key)) && (!c.endpoints || c.endpoints.includes(endpointName)));
const converter = converters.find(
(c) => (!c.key || c.key.includes(key)) && (!c.endpoints || (endpointName && c.endpoints.includes(endpointName))),
);

if (parsedTopic.type === 'set' && converter && usedConverters[endpointOrGroupID].includes(converter)) {
// Use a converter for set only once
Expand Down

0 comments on commit 8d9db22

Please sign in to comment.