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

transfer zigbeeCommandOptions into setupAttributes from enumLookup #7336

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib/modernExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function convertReportingConfigTime(time: ReportingConfigTime): number {

export async function setupAttributes(
entity: Zh.Device | Zh.Endpoint, coordinatorEndpoint: Zh.Endpoint, cluster: string | number, config: ReportingConfig[],
configureReporting: boolean=true, read: boolean=true,
configureReporting: boolean=true, read: boolean=true, options?: {manufacturerCode?: number, disableDefaultResponse?: boolean},
) {
const endpoints = isEndpoint(entity) ? [entity] : getEndpointsWithCluster(entity, cluster, 'input');
const ieeeAddr = isEndpoint(entity) ? entity.deviceIeeeAddress : entity.ieeeAddr;
Expand All @@ -81,7 +81,7 @@ export async function setupAttributes(
try {
// Don't fail configuration if reading this attribute fails
// https://github.com/Koenkk/zigbee-herdsman-converters/pull/7074
await endpoint.read(cluster, config.map((a) => isString(a) ? a : (isObject(a.attribute) ? a.attribute.ID : a.attribute)));
await endpoint.read(cluster, config.map((a) => isString(a) ? a : (isObject(a.attribute) ? a.attribute.ID : a.attribute)), options);
} catch (e) {
logger.debug(`Reading attribute failed: ${e}`, 'zhc:setupattribute');
}
Expand All @@ -91,7 +91,7 @@ export async function setupAttributes(

export function setupConfigureForReporting(
cluster: string | number, attribute: ReportingConfigAttribute, config: ReportingConfigWithoutAttribute, access: Access,
endpointNames?: string[],
endpointNames?: string[], options?: {manufacturerCode?: number, disableDefaultResponse?: boolean},
) {
const configureReporting = !!config;
const read = !!(access & ea.GET);
Expand All @@ -105,7 +105,7 @@ export function setupConfigureForReporting(
}

for (const entity of entities) {
await setupAttributes(entity, coordinatorEndpoint, cluster, [reportConfig], configureReporting, read);
await setupAttributes(entity, coordinatorEndpoint, cluster, [reportConfig], configureReporting, read, options);
}
};
return configure;
Expand Down Expand Up @@ -1305,7 +1305,8 @@ export function enumLookup(args: EnumLookupArgs): ModernExtend {
} : undefined,
}];

const configure = setupConfigureForReporting(cluster, attribute, reporting, access);
const configure = setupConfigureForReporting(cluster, attribute, reporting, access,
endpointName ? [endpointName] : undefined, zigbeeCommandOptions);

return {exposes: [expose], fromZigbee, toZigbee, configure, isModernExtend: true};
}
Expand Down
Loading