-
Notifications
You must be signed in to change notification settings - Fork 516
Add driver support for Matter cameras #2503
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
|
Duplicate profile check: Passed - no duplicate profiles detected. |
|
Invitation URL: |
Test Results 71 files 465 suites 0s ⏱️ For more details on these errors, see this check. Results for commit 5662469. ♻️ This comment has been updated with latest results. |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 5662469 |
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.
Just an initial review but I figured I'd get these thoughts out there
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
| if child_profile then | ||
| num_floodlight_eps = num_floodlight_eps + 1 | ||
| local name = string.format("%s %d", "Floodlight", num_floodlight_eps) | ||
| driver:try_create_device( |
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 don't think we should be trying to create new children every init
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's gated by CAMERA_INITIALIZED
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 do we have this in init at all is my question then? Why not have it in do_configure if it's meant to be a one-time call
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 definitely move it to configure. It was placed here during testing because it was easier to just delete the inventory db to clear CAMERA_INITIALIZED and get a new profile update rather than having to re-onboard.
|
|
||
| local function info_changed(driver, device, event, args) | ||
| -- resubscribe and initialize relevant camera capabilities if a modular update has occurred | ||
| if not compare_components(device.profile.components, args.old_st_store.profile.components) then |
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.
not compare_components is kinda odd wording... maybe are_profiles_equal or something like that? And then we could just pass in device.profile if we wanted to be clearer with the now.
Also, this is a useful function, I might suggest moving it to switch_utils.
| supported_capabilities = fields.supported_capabilities, | ||
| sub_drivers = { | ||
| require("sub_drivers.aqara_cube"), | ||
| require("sub_drivers.camera"), |
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 a large bit of code... would we be able to leverage @cjswedes's improvements to subdriver loading to avoid loading it?
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
| end | ||
|
|
||
| local function status_light_enabled_attr_handler(driver, device, ib, response) | ||
| local component = device.profile.components[component_map.statusLed] |
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.
to add to this comment, I think it could be good to get a clearer mapping between endpoints and these components so that we can endpoint_to_component in the emit_event_for_endpoint function. This may help cut out edge cases and bugs by putting all this mapping logic together into one place.
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 agree, I will add proper component mapping and switch away from using emit_component_event
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.
Thinking about this more, there isn't any assurance that the clusters will be implemented on separate endpoints, so I'm not sure what the best way to handle this would be. Since this subdriver only applies to one profile, we know which capabilities belong in each component and so therefore always know where to route them with emit_component_event. So there might not be much benefit in further endpoint/component mapping. What do you think?
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua
Outdated
Show resolved
Hide resolved
To avoid breaking routines, add in any capabilities from the current profile before updating the profile with the new list of component capabilities.
Compare the newly generated component capabilities list against the current device profile rather than saving this information in a persisted field.
66f0b0a to
31c2294
Compare
| }, | ||
| supported_capabilities = fields.supported_capabilities, | ||
| sub_drivers = { | ||
| require("sub_drivers.aqara_cube"), |
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.
lazy loading for other subdrivers is implemented in #2525
31c2294 to
5662469
Compare
Check all that apply
Type of Change
Checklist
Description of Change
Summary of Completed Tests