-
Notifications
You must be signed in to change notification settings - Fork 519
Matter Switch: Simplify component to endpoint mapping logic #2560
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
base: main
Are you sure you want to change the base?
Conversation
|
Invitation URL: |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 574fd58 |
| local formatted_info = {} | ||
| if type(ep_info) == "number" then | ||
| ep_info = { endpoint_id = ep_info } | ||
| formatted_info = { endpoint_id = ep_info } | ||
| elseif type(ep_info) == "table" then | ||
| ep_info = { | ||
| endpoint_id = ep_info.endpoint_id, | ||
| cluster_id = ep_info.cluster_id, | ||
| attribute_id = ep_info.attribute_id | ||
| } | ||
| formatted_info = ep_info |
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.
Effectively, can't this just be
if type(ep_info) == "number" then
ep_info = { endpoint_id = ep_info }
end? There isn't any transform done to the table form, and other types are not transformed.
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.
oh it can. I just thought that might be weird/wrong cause the capability event id is going to get appended later and that's not technically "ep info"
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.
but I suppose it's kinda equally weird to break it apart like I did, so I'll switch it
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.
ended up removing capabilities from the mapping, so this makes even more sense now
| --- to route events to. | ||
| --- | ||
| --- @param device any a Matter device object | ||
| --- @param ep_info number|table endpoint_id or ib (includes endpoint_id, cluster_id, attribute_id) |
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.
Are cluster_id and attribute_id required when in table form? Is capability_id required as well?
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.
again, they are at the time but I suppose don't need to be. changed the wording in the upcoming commit
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.
well, it actually reads endpoint_id or ib, and I note that the ib includes that data. I agree this wording is a little confused
| --- single endpoint. | ||
| --- | ||
| --- @param device any a Matter device object | ||
| --- @param opts number|table either is an ep_id or a table { endpoint_id, capability_id } |
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.
I think this doc should include mention of the required fields of cluster_id and attribute_id when in table form.
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.
updated
| and (not map_info.cluster_id or (map_info.cluster_id == opts.cluster_id | ||
| and utils.tbl_contains(map_info.attribute_ids, opts.attribute_id))) |
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 are using the logic that existence of the cluster_id field implies the existence of a non-nil attribute_id. Is this always the case?
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.
It is at the time (and I can't see when/why it wouldn't be), though I can see how it can seem a little arbitrary. fixed in next commit (cannot push now due to github outage)
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.
updated
| end | ||
| local opts = { endpoint_info = ep_info, capability_id = event.capability.ID } | ||
| local comp_id = utils.endpoint_to_component(device, opts) | ||
| formatted_info.capability_ID = event.capability.ID |
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.
Typo:
| formatted_info.capability_ID = event.capability.ID | |
| formatted_info.capability_id = event.capability.ID |
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.
updated
Description of Change
This cuts down the amount of checks and reformatting handled in the
endpoint_to_componentandemit_event_for_endpointfunctions.This logic was just added by me in the recent Camera PR and it was a bit rushed. This cleans up some unnecessary logic that was introduced.
Summary of Completed Tests
Tested by Unit Test. Expanded functionality is currently only utilized by unreleased Camera subdriver