-
Notifications
You must be signed in to change notification settings - Fork 308
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
chore: remove manuSpecificNodOnPilotWire that was moved to zigbee-herdsman-converters #1274
Conversation
This looks like a very specific case of custom cluster ID clashing? |
Actually... @Koenkk can't we move these two (and others that may conflict) to custom clusters directly and remove the problem entirely? |
On a Raspberry PI 4, the function takes 0.003ms for an empty list and 0.015ms to loop over the 132 clusters, measured on the average of 20 executions. I removed the break to make sure to loop over the complete list. If perf is an issue, it might be better to preprocess the list on start to group if by id, as it is less error prone than relying on the cluster order in the source code. Code usedfunction findClusterNameByID(id, manufacturerCode, clusters) {
console.log(Object.keys(clusters).length);
let time = process.hrtime();
let matchingManufacturer;
let noManufacturer;
let anyManufacturer;
for (const clusterName in clusters) {
const cluster = clusters[clusterName];
if (cluster.ID === id) {
// When a manufacturerCode is requested, match the first cluster with matching manufacturerCode,
if (manufacturerCode && cluster.manufacturerCode === manufacturerCode) {
matchingManufacturer = clusterName;
// Otherwise, match the first cluster with no manufacturerCode,
}
else if (!noManufacturer && !cluster.manufacturerCode) {
noManufacturer = clusterName;
// Finally, match the first cluster with a matching ID.
}
else if (!anyManufacturer) {
anyManufacturer = clusterName;
}
}
}
const exactMatch = (manufacturerCode && matchingManufacturer) || (!manufacturerCode && noManufacturer);
const clusterName = matchingManufacturer || noManufacturer || anyManufacturer;
time = process.hrtime(time);
console.log('benchmark took %d seconds and %d nanoseconds', time[0], time[1]);
return [clusterName, !exactMatch];
} |
Yes it would be better to completely remove the clusters here (at least one of them) and move them into zhc. Example on how to do that: https://github.com/Koenkk/zigbee-herdsman-converters/blob/20c0958f6e99343040b334898de494fb97f18aa8/src/devices/sonoff.ts#L1105 |
84a3e25
to
ad29ab1
Compare
I moved the cluster definition in Koenkk/zigbee-herdsman-converters#8535 |
Thanks! |
Previous logic stopped on the first cluster with no manufacturerCode.
Fixes Koenkk/zigbee2mqtt#25333