-
Notifications
You must be signed in to change notification settings - Fork 494
Implement modular profiles for matter switch #2142
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 0d5023f |
-- Check if the device supports BatPercentRemaining or BatChargeLevel. | ||
-- Prefer BatPercentRemaining if available. | ||
if attr.value == clusters.PowerSource.attributes.BatPercentRemaining.ID then | ||
battery_attr_support = common_utils.battery_support.BATTERY_PERCENTAGE | ||
break |
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 removed this break
because I think that if the attribute list doesn't come in sorted order (and maybe it does so this doesn't matter) then this could lead to battery level being chosen instead of battery percentage if a device supports both
Duplicate profile check: Passed - no duplicate profiles detected. |
@@ -32,16 +33,6 @@ local INITIAL_PRESS_ONLY = "__initial_press_only" -- for devices that support MS | |||
local CUBEACTION_TIMER = "__cubeAction_timer" | |||
local CUBEACTION_TIME = 3 | |||
|
|||
local function is_aqara_cube(opts, driver, device) | |||
if device.network_type == device_lib.NETWORK_TYPE_MATTER 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.
Moving these functions out of subdrivers and into common_utils so that they can be used to determine if they should be used rather than the static profile subdriver.
7508866
to
eaa9b79
Compare
325e7b6
to
2b181a2
Compare
@@ -0,0 +1,464 @@ | |||
-- Copyright 2025 SmartThings |
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.
Note that the only new code introduced by this file is the supports_modular_profile
function and changes to find_default_endpoint
. Everything else was moved from init.lua
(and the is_aqara_cube, is_eve_energy_products, etc functions from the subdrivers) without modification.
end | ||
end | ||
if profile_name ~= "" 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.
Note that this handling was moved to the static profile subdriver's implementation of the PowerSource AttributeList handler.
0776cde
to
f402bc9
Compare
59c5fe0
to
130c39d
Compare
Renaming buttons.lua to button-utils.lua to align with the changes coming in #2142.
With the previous commit, switches and buttons were not being initialized when modular profiles were used
Add new modular profiles to support other device types that require different categories. Add new logic in the driver to support the new profiles.
Support additional, optional plug components in the plug-modular profile. Also, fix the component mapping for button endpoints.
Using a subdriver for modular profile code and also separate some functionality into button-utils and common-utils so that it can be across multiple files.
It might make more sense to put the code for environments that don't support modular profiles into a subdriver so that it doesn't even need to be loaded on setups that do support modular profiles. This way, the main driver contains the most up to date code rather than having to maintain two paths.
Also update other subdrivers so that they are preferred over the static profile subdriver.
Move the else clause of common-utils/find_default_endpoint into static/profiles/init.lua rather than having two paths for static vs modular.
Porting over some code from modular-profiles-utils into common-utils to support a more advanced is_static_profile_device function, allowing us to check the device category and exclude Light devices from using modular profiles, since lighting groups do not currently work with modular profiles.
eb05b0b
to
becfe25
Compare
Swap mandatory capabilities for switch and valve. Also remove check for Aqara W100 from supports_modular_profile as this device would support modular profiles.
becfe25
to
5edce5a
Compare
Type of Change
Checklist
Description of Change
This PR was initially branched off of #2112, but now targets main instead as the other PR was used for testing purposes and so was not optimized. The changes in this PR add support for modular profiles to the matter switch driver. Additionally, a subdriver for static profile code is introduced and also some functionality is separated into
button-utils
andcommon-utils
so that it can be used across multiple modules. This allows the main driver to contain the latest code and not needing to maintain two separate paths depending on whether a given setup supports modular profiles or not. Another benefit is that the static profile subdriver won't need to be loaded for environments supporting modular profiles.There are 5 main device types covered by the matter switch driver: Buttons, On/Off Lights, Smart Plugs, Switches, and Water Valves. These 5 categories are used in the driver to help select a modular profile to use, in order to set the category correctly based on the device type. Therefore there are 5 modular profiles introduced by this PR. Each of them also include 8 optional button components as buttons are commonly included in other devices.
Lights are excluded from modular profile support for now, since modular profiles don't currently support lighting groups on the cloud side.
Please let me know if you have any ideas on improvements, this should be considered a WIP as we continue to hash out ideas.
Summary of Completed Tests
More new test cases will be needed.