-
Notifications
You must be signed in to change notification settings - Fork 82
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
Enable Multiple Endpoints and Device Types in Device Composition Insertion #1489
Enable Multiple Endpoints and Device Types in Device Composition Insertion #1489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a test for this particular type of composed device type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally ok, but do please clean up some of those syntactic sugar thingies.... We should write modern code.
src-electron/db/query-loader.js
Outdated
// Ensure that deviceType and its necessary properties are defined | ||
if ( | ||
!deviceType || | ||
!deviceType.composition || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you use the ?.
operator here?
Like !(devicetype?.composition?.endpoint)
?
src-electron/db/query-loader.js
Outdated
// Create insert queries for each deviceType in this endpoint and add them to the insertQueries array | ||
for (let j = 0; j < deviceTypes.length; j++) { | ||
const device = deviceTypes[j] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not:
for ( let device of deviceTypes) {
...
}
I don't think you're using the actual index anywhere, and while there is something cozy about the good old fashioned 1960's C-like for loop, it is visually more taxing than modern JS.
Obviously I'm assuming that you tested this well with both Matter and Zigbee, and that you promise you will write unit tests for it! |
1da59a6
to
f71d922
Compare
Pull Request Summary
Title: Enable Multiple Endpoints and Device Types in Device Composition Insertion
Description:
This update enhances the insertDeviceComposition function to support multiple endpoints and multiple device types (deviceType) per endpoint. Previously, the code could only insert data for a single endpoint and device type.
Key Changes:
Multiple Endpoints: The function now processes all endpoints in deviceType.composition.endpoint, inserting data for each.
Multiple Device Types per Endpoint: Supports inserting multiple deviceType values per endpoint.
Dynamic Conformance and Constraint: Uses endpoint-specific conformance and constraint values when available, with fallbacks to default deviceType values.
Improved Error Handling: Ensures required data is present and correctly formatted, preventing errors.
Benefits:
Scalability: Handles more complex device compositions with multiple endpoints and device types.
Flexibility: Supports a wider range of device configurations.
Data Integrity: Ensures correct insertion of data for each endpoint and device type.
This update improves flexibility and scalability for device composition handling.