-
Notifications
You must be signed in to change notification settings - Fork 523
Matter Switch: Attempt re-profiling on device software updates #2466
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,16 +60,21 @@ end | |
|
|
||
| function SwitchLifecycleHandlers.info_changed(driver, device, event, args) | ||
| if device.profile.id ~= args.old_st_store.profile.id then | ||
| device:subscribe() | ||
| local button_eps = device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH}) | ||
| if #button_eps > 0 and device.network_type == device_lib.NETWORK_TYPE_MATTER then | ||
| button_cfg.configure_buttons(device) | ||
| if device.network_type == device_lib.NETWORK_TYPE_MATTER then | ||
| device:subscribe() | ||
| button_cfg.configure_buttons(device, | ||
| device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH}) | ||
| ) | ||
| elseif device.network_type == device_lib.NETWORK_TYPE_CHILD then | ||
| switch_utils.update_subscriptions(device:get_parent_device()) -- parent device required to scan through EPs and update subscriptions | ||
nickolas-deboom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| end | ||
|
|
||
| function SwitchLifecycleHandlers.device_removed(driver, device) | ||
| device.log.info("device removed") | ||
| if device.network_type == device_lib.NETWORK_TYPE_MATTER and not switch_utils.detect_bridge(device) then | ||
| if device.matter_version.software ~= args.old_st_store.matter_version.software then | ||
| device_cfg.match_profile(driver, device) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function SwitchLifecycleHandlers.device_init(driver, device) | ||
|
|
@@ -80,26 +85,7 @@ function SwitchLifecycleHandlers.device_init(driver, device) | |
| if device:get_field(fields.IS_PARENT_CHILD_DEVICE) then | ||
| device:set_find_child(switch_utils.find_child) | ||
| end | ||
| local default_endpoint_id = switch_utils.find_default_endpoint(device) | ||
| -- ensure subscription to all endpoint attributes- including those mapped to child devices | ||
| for _, ep in ipairs(device.endpoints) do | ||
| if ep.endpoint_id ~= default_endpoint_id then | ||
| local id = 0 | ||
| for _, dt in ipairs(ep.device_types) do | ||
| id = math.max(id, dt.device_type_id) | ||
| end | ||
| for _, attr in pairs(fields.device_type_attribute_map[id] or {}) do | ||
| if id == fields.DEVICE_TYPE_ID.GENERIC_SWITCH and | ||
| attr ~= clusters.PowerSource.attributes.BatPercentRemaining and | ||
| attr ~= clusters.PowerSource.attributes.BatChargeLevel then | ||
| device:add_subscribed_event(attr) | ||
| else | ||
| device:add_subscribed_attribute(attr) | ||
| end | ||
| end | ||
| end | ||
| end | ||
| device:subscribe() | ||
| switch_utils.update_subscriptions(device) | ||
|
|
||
| -- device energy reporting must be handled cumulatively, periodically, or by both simulatanously. | ||
| -- To ensure a single source of truth, we only handle a device's periodic reporting if cumulative reporting is not supported. | ||
|
|
@@ -110,6 +96,10 @@ function SwitchLifecycleHandlers.device_init(driver, device) | |
| end | ||
| end | ||
|
|
||
| function SwitchLifecycleHandlers.device_removed(driver, device) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just moved this to the bottom of the file. We never touch this and I personally am always getting confused where device_init is when developing with this placed above it. |
||
| device.log.info("device removed") | ||
| end | ||
|
|
||
| local matter_driver_template = { | ||
| lifecycle_handlers = { | ||
| added = SwitchLifecycleHandlers.device_added, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.