@@ -56,17 +56,13 @@ local battery_support = {
5656
5757local profiling_data = {
5858 BATTERY_SUPPORT = " __BATTERY_SUPPORT" ,
59- ENABLE_DOOR_STATE = " __ENABLE_DOOR_STATE"
6059}
6160
6261local DoorLockFeatureMapAttr = {ID = 0xFFFC , cluster = DoorLock .ID }
6362local subscribed_attributes = {
6463 [capabilities .lock .ID ] = {
6564 DoorLock .attributes .LockState
6665 },
67- [capabilities .doorState .ID ] = {
68- DoorLock .attributes .DoorState
69- },
7066 [capabilities .remoteControlStatus .ID ] = {
7167 DoorLock .attributes .OperatingMode
7268 },
133129
134130local function device_init (driver , device )
135131 device :set_component_to_endpoint_fn (component_to_endpoint )
136- if # device :get_endpoints (clusters .DoorLock .ID , {feature_bitmap = clusters .DoorLock .types .Feature .DOOR_POSITION_SENSOR }) == 0 then
137- device :set_field (profiling_data .ENABLE_DOOR_STATE , false , {persist = true })
138- else
139- device :add_subscribed_attribute (clusters .DoorLock .attributes .DoorState )
140- end
141132 if # device :get_endpoints (clusters .PowerSource .ID , {feature_bitmap = clusters .PowerSource .types .PowerSourceFeature .BATTERY }) == 0 then
142133 device :set_field (profiling_data .BATTERY_SUPPORT , battery_support .NO_BATTERY , {persist = true })
143134 elseif device :get_field (profiling_data .BATTERY_SUPPORT ) == nil then
@@ -267,10 +258,6 @@ local function match_profile_modular(driver, device)
267258 table.insert (main_component_capabilities , capabilities .battery .ID )
268259 end
269260
270- if device :get_field (profiling_data .ENABLE_DOOR_STATE ) then
271- table.insert (main_component_capabilities , capabilities .doorState .ID )
272- end
273-
274261 table.insert (enabled_optional_component_capability_pairs , {" main" , main_component_capabilities })
275262 if lock_utils .optional_capabilities_list_changed (enabled_optional_component_capability_pairs , device .profile .components ) then
276263 device :try_update_metadata ({profile = modular_profile_name , optional_component_capabilities = enabled_optional_component_capability_pairs })
@@ -378,10 +365,7 @@ local function info_changed(driver, device, event, args)
378365 if device :supports_capability_by_id (capabilities .lockAliro .ID ) then
379366 set_reader_config (device )
380367 end
381- if device :supports_capability (capabilities .doorState ) and device :get_latest_state (" main" , capabilities .doorState .ID , capabilities .doorState .supportedDoorStates .NAME ) == nil then
382- device :emit_event (capabilities .doorState .supportedDoorStates ({" open" , " closed" }, {visibility = {displayed = false }})) -- open and closed are mandatory
383- end
384- if device :supports_capability (capabilities .lockAlarm ) and device :get_latest_state (" main" , capabilities .lockAlarm .ID , capabilities .lockAlarm .supportedAlarmValues .NAME ) == nil then
368+ if device :get_latest_state (" main" , capabilities .lockAlarm .ID , capabilities .lockAlarm .supportedAlarmValues .NAME ) == nil then
385369 device :emit_event (capabilities .lockAlarm .alarm .clear ({state_change = true }))
386370 device :emit_event (capabilities .lockAlarm .supportedAlarmValues ({" unableToLockTheDoor" }, {visibility = {displayed = false }})) -- lockJammed is mandatory
387371 end
@@ -443,45 +427,6 @@ local function lock_state_handler(driver, device, ib, response)
443427 end )
444428end
445429
446- local function door_state_handler (driver , device , ib , response )
447- if ib .data .value == nil then
448- -- early return on nil data. Also, if ENABLE_DOOR_STATE is unset, set it to false and attempt profile matching.
449- if device :get_field (profiling_data .ENABLE_DOOR_STATE ) == nil then
450- device :set_field (profiling_data .ENABLE_DOOR_STATE , false , {persist = true })
451- match_profile (driver , device )
452- end
453- return
454- elseif device :supports_capability (capabilities .doorState ) == false then
455- -- if a non-nil report comes in and the doorState capability is unsupported, set ENABLE_DOOR_STATE to true and attempt profile matching.
456- device :set_field (profiling_data .ENABLE_DOOR_STATE , true , {persist = true })
457- match_profile (driver , device )
458- return
459- end
460-
461- local DoorStateEnum = DoorLock .types .DoorStateEnum
462- local doorState = capabilities .doorState .doorState
463- local DOOR_STATE_MAP = {
464- [DoorStateEnum .DOOR_OPEN ] = doorState .open ,
465- [DoorStateEnum .DOOR_CLOSED ] = doorState .closed ,
466- [DoorStateEnum .DOOR_JAMMED ] = doorState .jammed ,
467- [DoorStateEnum .DOOR_FORCED_OPEN ] = doorState .forcedOpen ,
468- [DoorStateEnum .DOOR_UNSPECIFIED_ERROR ] = doorState .unspecifiedError ,
469- [DoorStateEnum .DOOR_AJAR ] = doorState .ajar
470- }
471- local door_state = DOOR_STATE_MAP [ib .data .value ] or doorState .unspecifiedError -- fallback to unspecifiedError if we receive a value we don't recognize
472- device :emit_event (door_state ())
473-
474- -- add new door states to supportedDoorStates list if not already present.
475- local supported_door_states = utils .deep_copy (device :get_latest_state (" main" , capabilities .doorState .ID , capabilities .doorState .supportedDoorStates .NAME ) or {})
476- for _ , state in pairs (supported_door_states ) do
477- if state == door_state .NAME then
478- return
479- end
480- end
481- table.insert (supported_door_states , door_state .NAME )
482- device :emit_event (capabilities .doorState .supportedDoorStates (supported_door_states , {visibility = {displayed = false }}))
483- end
484-
485430---- -----------------
486431-- Operating Modes --
487432---- -----------------
@@ -730,12 +675,6 @@ local function door_lock_feature_map_handler(driver, device, ib, response)
730675 local feature_map = lock_utils .get_field_for_endpoint (device , lock_utils .LATEST_DOOR_LOCK_FEATURE_MAP , ib .endpoint_id ) or nil
731676 if feature_map ~= ib .data .value then
732677 lock_utils .set_field_for_endpoint (device , lock_utils .LATEST_DOOR_LOCK_FEATURE_MAP , ib .endpoint_id , ib .data .value , { persist = true })
733- -- If the DPS feature is changed, check the DoorState value and call the match_profile.
734- if ib .data .value & clusters .DoorLock .types .Feature .DOOR_POSITION_SENSOR == 0 then
735- device :set_field (profiling_data .ENABLE_DOOR_STATE , false , {persist = true })
736- else
737- device :set_field (profiling_data .ENABLE_DOOR_STATE , true , {persist = true })
738- end
739678 match_profile (driver , device , true )
740679 end
741680end
@@ -2992,7 +2931,6 @@ local new_matter_lock_handler = {
29922931 attr = {
29932932 [DoorLock .ID ] = {
29942933 [DoorLock .attributes .LockState .ID ] = lock_state_handler ,
2995- [DoorLock .attributes .DoorState .ID ] = door_state_handler ,
29962934 [DoorLock .attributes .OperatingMode .ID ] = operating_modes_handler ,
29972935 [DoorLock .attributes .NumberOfTotalUsersSupported .ID ] = total_users_supported_handler ,
29982936 [DoorLock .attributes .NumberOfPINUsersSupported .ID ] = pin_users_supported_handler ,
0 commit comments