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

Fix Darwin helpers to allow working with device types. #1452

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ function makeAvailabilityPath(clusterName, options) {
return ['global attributes', options.hash.globalAttribute];
}

if (options.hash.deviceType) {
return ['device types', options.hash.deviceType];
}

return ['clusters', clusterName];
}

Expand Down Expand Up @@ -626,6 +630,7 @@ function findPathToContainer(availabilityPath) {
case 'apis':
case 'global attributes':
case 'clusters':
case 'device types':
return undefined;

default:
Expand Down Expand Up @@ -1254,6 +1259,25 @@ async function async_not(value) {
return !toBeNegated;
}

function isLessThan(value1, value2) {
return value1 < value2;
}

function stripPrefix(value, prefix) {
if (value.startsWith(prefix)) {
return value.substring(prefix.length);
}

return value;
}

function cleanDeviceName(deviceName) {
deviceName = stripPrefix.call(this, deviceName, 'Matter ');
return appHelper.asUpperCamelCase.call(this, deviceName, {
hash: { preserveAcronyms: true }
});
}

//
// Module exports
//
Expand Down Expand Up @@ -1288,6 +1312,9 @@ exports.async_not = async_not;
exports.oldName = oldName;
exports.hasOldName = hasOldName;
exports.hasRenamedFields = hasRenamedFields;
exports.isLessThan = isLessThan;
exports.stripPrefix = stripPrefix;
exports.cleanDeviceName = cleanDeviceName;

exports.meta = {
category: dbEnum.helperCategory.matter,
Expand Down
Loading