-
Notifications
You must be signed in to change notification settings - Fork 513
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
base: main
Are you sure you want to change the base?
Conversation
Invitation URL: |
Minimum allowed coverage is Generated by 🐒 cobertura-action against 199f355 |
SwitchFields.DIMMABLE_LIGHT_ID = 0x0101 | ||
SwitchFields.COLOR_TEMPERATURE_LIGHT_ID = 0x010C | ||
SwitchFields.EXTENDED_COLOR_LIGHT_ID = 0x010D | ||
SwitchFields.ON_OFF_PLUG_IN_UNIT_ID = 0x010A |
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.
can be reverted, but I changed the device type fields to more closely match the spec-defined device types (ON_OFF_PLUG
-> ON_OFF_PLUG_IN_UNIT
) and I cut the DEVICE_TYPE
out of the ones that had it, since it's kinda self-explanatory. If we think it's not, I might move them into their own file with a DeviceType
header or something.
local main_endpoint = switch_utils.find_default_endpoint(device) | ||
local profile_name = nil | ||
|
||
local server_onoff_eps = device:get_endpoints(clusters.OnOff.ID, { cluster_type = "SERVER" }) | ||
if #server_onoff_eps > 0 then | ||
SwitchDeviceConfiguration.create_child_switch_devices(driver, device, server_onoff_eps, main_endpoint) | ||
-- workaround: finds a profile for devices of the Light Switch device type set that break spec and implement OnOff as 'server' instead of 'client'. | ||
-- note: since the Light Switch device set isn't supported, these devices join as a matter-thing. | ||
if switch_utils.detect_matter_thing(device) then | ||
profile_name = SwitchDeviceConfiguration.match_light_switch_device_profile(device, main_endpoint) | ||
end | ||
end |
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 may look like a change in functionality but it is not.
When removing the initialize_buttons_and_switches
helper function, it became clear there was some formatting that no longer made a lot of sense. Aka, the semi-arbitrary profile_found = true
statements and the
if profile_found then
return
end
statement based around those declarations that had been in place since more logic was hidden by the helper function.
So what I did was remove that profile_found logic, and now have match_light_switch_device_profile
use the same try_metadata_update
as everything else (at the bottom of match_profile), only returning the profile name instead of doing an actual update.
I would have done the same for the button logic, but it gets a little messy due to the electrical energy stuff. This will be fixed though in the powerTopology PR, so we can streamline that too. I think having one point of contact with try_metadata_update
is clearer, catches more edge cases by default, and is easier to maintain, which is why I'm moving the logic in that direction.
Description of Change
We store data related to the device software version (saved from the BasicInformation cluster's softwareVersion attribute) on the driver st_store. This leverages that version to attempt a re-profiling if this is ever updated. The same data is what is leveraged by the hub to re-interview a device on a device update as well.
I also took the opportunity to remove the
initialize_switch_and_buttons
helper function inmatch_profile
. This seemed like an extra layer of complexity that was no longer required at this point. Can revert if wanted but it changes no functionality so I see it as a nice change.Summary of Completed Tests