-
Notifications
You must be signed in to change notification settings - Fork 522
Matter Switch: update subscribe logic #2667
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: |
Test Results 71 files 480 suites 0s ⏱️ Results for commit 3de35fd. ♻️ This comment has been updated with latest results. |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 3de35fd |
cjswedes
left a comment
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.
Some of the test changes need a bit of explanation, but otherwise LGTM.
| -- @param matter_elements_seen table a list of attribute and event ids that have been added already | ||
| --- @param subscribed_attributes table key-value pairs mapping capability ids to subscribed attributes | ||
| --- @param subscribed_events table key-value pairs mapping capability ids to subscribed events | ||
| function utils.populate_subscribe_request_for_device(checked_device, subscribe_request, capabilities_seen, attributes_seen, events_seen, subscribed_attributes, subscribed_events) |
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.
Nice impl!
drivers/SmartThings/matter-switch/src/test/test_matter_multi_button_switch_mcd.lua
Outdated
Show resolved
Hide resolved
| test.socket.device_lifecycle:__queue_receive(unsup_mock_device:generate_info_changed({ profile = updated_device_profile })) | ||
|
|
||
| local cluster_subscribe_list = { | ||
| -- clusters.OnOff.attributes.OnOff, |
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 is this no longer expected?
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.
This is no longer expected because now, the subscription is based on the capability->attribute/event maps for devices that currently exist.
Before, we were doing a device type check on all endpoints, which was catching that this device would need to subscribe to onOff eventually, when its child device was created. Now that logic has been pushed to when the child device is actually created (which is not now). Thus the attribute is no longer subscribed to at this point
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.
Also, I reworked this file a bit to get the structure tested more thoroughly by only initializing the mock_child in the tests where it's directly needed. This way, I showed that before the device is created, only some of the subscriptions are handled, but after the device is initialized, the more complete subscribe table is used.
drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/utils.lua
Show resolved
Hide resolved
ddaf944 to
1972787
Compare
8f71143 to
79cea27
Compare
79cea27 to
3de35fd
Compare
| }, | ||
| } | ||
| function() | ||
| test.mock_device.add_test_device(mock_child) |
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'm a little confused on how these tests work. This test for instance looks like it initially subscribed to CLUSTER_SUBSCRIBE_LIST_NO_CHILD, and then wait to add the child device until right here. When do the additional attributes from CLUSTER_SUBSCRIBE_LIST_WITH_CHILD get subscribed to?
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.
for ease, the main test path doesn't actually test the child subscription logic. That path is tested in the particular test that uses CLUSTER_SUBSCRIBE_LIST_WITH_CHILD
| end | ||
| end | ||
| end | ||
| local im = require "st.matter.interaction_model" |
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.
Could we replace the block below with a call to the subscribe function implemented in switch_utils?
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.
the issue there is how do we add the subscription to clusters.CameraAvStreamManagement.attributes.AttributeList.ID if we do it like that? I couldn't really find a way around that at this time, so I left it like this
Description of Change
Override generic matter switch handling of device:subscribe() to more properly and generically handle child devices.
Summary of Completed Tests
Tested multiple parent/child devices where the children had unique subscriptions from the parent device.