- 
                Notifications
    You must be signed in to change notification settings 
- Fork 516
Matter Lock: Use Door Lock Device type in Lock Modular logic #2494
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -24,6 +24,10 @@ if version.api < 10 then | |
| clusters.DoorLock = require "DoorLock" | ||
| end | ||
|  | ||
| local DEVICE_TYPE_ID = { | ||
| DOOR_LOCK = 0x000A | ||
| } | ||
|  | ||
| local DoorLock = clusters.DoorLock | ||
| local PowerSource = clusters.PowerSource | ||
|  | ||
|  | @@ -209,35 +213,40 @@ local function match_profile_modular(driver, device) | |
| local enabled_optional_component_capability_pairs = {} | ||
| local main_component_capabilities = {} | ||
| local modular_profile_name = "lock-modular" | ||
| for _, device_ep in pairs(device.endpoints) do | ||
| for _, ep_cluster in pairs(device_ep.clusters) do | ||
| if ep_cluster.cluster_id == DoorLock.ID then | ||
| local clus_has_feature = function(feature_bitmap) | ||
| return DoorLock.are_features_supported(feature_bitmap, ep_cluster.feature_map) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.USER) then | ||
| table.insert(main_component_capabilities, capabilities.lockUsers.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.PIN_CREDENTIAL) then | ||
| table.insert(main_component_capabilities, capabilities.lockCredentials.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.WEEK_DAY_ACCESS_SCHEDULES) or | ||
| clus_has_feature(DoorLock.types.Feature.YEAR_DAY_ACCESS_SCHEDULES) then | ||
| table.insert(main_component_capabilities, capabilities.lockSchedules.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.UNBOLT) then | ||
| device:emit_event(capabilities.lock.supportedLockValues({"locked", "unlocked", "unlatched", "not fully locked"}, {visibility = {displayed = false}})) | ||
| device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock", "unlatch"}, {visibility = {displayed = false}})) | ||
| modular_profile_name = "lock-modular-embedded-unlatch" -- use the embedded config specified in this profile for devices supporting "unlatch" | ||
| else | ||
| device:emit_event(capabilities.lock.supportedLockValues({"locked", "unlocked", "not fully locked"}, {visibility = {displayed = false}})) | ||
| device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock"}, {visibility = {displayed = false}})) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.ALIRO_PROVISIONING) then | ||
| table.insert(main_component_capabilities, capabilities.lockAliro.ID) | ||
| end | ||
| break | ||
| local door_lock_ep_data | ||
| for _, ep_data in ipairs(device.endpoints) do | ||
| if ep_data.device_types[1].device_type_id == DEVICE_TYPE_ID.DOOR_LOCK then | ||
| 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. Could the endpoint have multiple device types? 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. per spec, application device types cannot have >1 device type on an endpoint 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. Also, application device types cannot be supported on another endpoint as a secondary. 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. Discussed offline. Here's the spec wording: 
 where the complement of simple endpoints are dynamic endpoints, which aren't used by us (now? ever?). | ||
| door_lock_ep_data = ep_data | ||
| break | ||
| end | ||
| end | ||
| for _, cluster in pairs(door_lock_ep_data.clusters) do | ||
| if cluster.cluster_id == DoorLock.ID then | ||
| local clus_has_feature = function(feature_bitmap) | ||
| return DoorLock.are_features_supported(feature_bitmap, cluster.feature_map) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.USER) then | ||
| table.insert(main_component_capabilities, capabilities.lockUsers.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.PIN_CREDENTIAL) then | ||
| table.insert(main_component_capabilities, capabilities.lockCredentials.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.WEEK_DAY_ACCESS_SCHEDULES) or | ||
| clus_has_feature(DoorLock.types.Feature.YEAR_DAY_ACCESS_SCHEDULES) then | ||
| table.insert(main_component_capabilities, capabilities.lockSchedules.ID) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.UNBOLT) then | ||
| device:emit_event(capabilities.lock.supportedLockValues({"locked", "unlocked", "unlatched", "not fully locked"}, {visibility = {displayed = false}})) | ||
| device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock", "unlatch"}, {visibility = {displayed = false}})) | ||
| modular_profile_name = "lock-modular-embedded-unlatch" -- use the embedded config specified in this profile for devices supporting "unlatch" | ||
| else | ||
| device:emit_event(capabilities.lock.supportedLockValues({"locked", "unlocked", "not fully locked"}, {visibility = {displayed = false}})) | ||
| device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock"}, {visibility = {displayed = false}})) | ||
| end | ||
| if clus_has_feature(DoorLock.types.Feature.ALIRO_PROVISIONING) then | ||
| table.insert(main_component_capabilities, capabilities.lockAliro.ID) | ||
| end | ||
| break | ||
| end | ||
| end | ||
|  | ||
|  | ||
Uh oh!
There was an error while loading. Please reload this page.