Skip to content
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

Add new-matter-lock driver #1624

Merged
merged 22 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b6c9c65
Add new-matter-lock driver
HunsupJung Sep 9, 2024
41bc486
Remove logging and fix typo
HunsupJung Sep 10, 2024
46870ab
Add call_with_delay to prevent duplicated event
HunsupJung Sep 19, 2024
a268604
Fix some issues
HunsupJung Sep 19, 2024
8bc9545
Merge branch 'main' into feature/new-matter-lock
HunsupJung Sep 25, 2024
ef622e0
Add DoorLock cluster for a hub using old lua-libs
HunsupJung Sep 26, 2024
45e3606
Remove duplicated guest after driver is changed
HunsupJung Oct 2, 2024
1b19d30
Modify test case
HunsupJung Oct 2, 2024
4ff6766
Update PR with some patch
HunsupJung Oct 8, 2024
9fdde26
Update subscribed_attributes and subscribed_events
HunsupJung Oct 8, 2024
7dc105c
Update process to check the busy state
HunsupJung Oct 8, 2024
6e09690
Add lock profile for a door lock that does not support user and pin
HunsupJung Oct 9, 2024
fcbcc3f
Modify set_cota_credential function
HunsupJung Oct 9, 2024
beb5dc1
Modify test_aqara_matter_lock
HunsupJung Oct 9, 2024
aca90c2
Simplify the operation related to the tables
HunsupJung Oct 10, 2024
65d52f9
Add addUser command and sequence
HunsupJung Oct 10, 2024
17d8148
Modify some code that are not clear
HunsupJung Oct 11, 2024
3035dbc
Add test unit file for new door lock driver
HunsupJung Oct 11, 2024
cf148fe
Merge branch 'main' into feature/new-matter-lock
ctowns Oct 11, 2024
5a79c21
Fix the process for COTA and some issues
HunsupJung Oct 15, 2024
966c64b
Update test unit file for new door lock driver
HunsupJung Oct 15, 2024
37709e8
Fix COTA issue and add test unit for COTA
HunsupJung Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions drivers/SmartThings/matter-lock/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ matterManufacturer:
deviceLabel: Aqara Smart Lock U200
vendorId: 0x115F
productId: 0x2802
deviceProfileName: lock-lockalarm-nobattery
deviceProfileName: lock-user-pin
- id: "4447/10241"
deviceLabel: Aqara Smart Lock U300
vendorId: 0x115F
productId: 0x2801
deviceProfileName: lock-lockalarm-nobattery
deviceProfileName: lock-user-pin
matterGeneric:
- id: "matter/door-lock"
deviceLabel: Matter Door Lock
deviceTypes:
- id: 0x000A # Door Lock
deviceProfileName: base-lock
deviceProfileName: base-lock
HunsupJung marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: lock-user-pin-schedule
components:
- id: main
capabilities:
- id: lock
version: 1
config:
values:
- key: "lock.value"
enabledValues:
- locked
- unlocked
- not fully locked
- id: lockAlarm
version: 1
- id: remoteControlStatus
version: 1
- id: lockUsers
version: 1
- id: lockCredentials
version: 1
- id: lockSchedules
version: 1
- id: refresh
HunsupJung marked this conversation as resolved.
Show resolved Hide resolved
version: 1
categories:
- name: SmartLock
25 changes: 25 additions & 0 deletions drivers/SmartThings/matter-lock/profiles/lock-user-pin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: lock-user-pin
components:
- id: main
capabilities:
- id: lock
version: 1
config:
values:
- key: "lock.value"
enabledValues:
- locked
- unlocked
- not fully locked
- id: lockAlarm
version: 1
- id: remoteControlStatus
version: 1
- id: lockUsers
version: 1
- id: lockCredentials
version: 1
- id: refresh
HunsupJung marked this conversation as resolved.
Show resolved Hide resolved
version: 1
categories:
- name: SmartLock
25 changes: 25 additions & 0 deletions drivers/SmartThings/matter-lock/profiles/lock-user-schedule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: lock-user-schedule
components:
- id: main
capabilities:
- id: lock
version: 1
config:
values:
- key: "lock.value"
enabledValues:
- locked
- unlocked
- not fully locked
- id: lockAlarm
version: 1
- id: remoteControlStatus
version: 1
- id: lockUsers
version: 1
- id: lockSchedules
version: 1
- id: refresh
tpmanley marked this conversation as resolved.
Show resolved Hide resolved
version: 1
categories:
- name: SmartLock
23 changes: 23 additions & 0 deletions drivers/SmartThings/matter-lock/profiles/lock-user.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: lock-user
components:
- id: main
capabilities:
- id: lock
version: 1
config:
values:
- key: "lock.value"
enabledValues:
- locked
- unlocked
- not fully locked
- id: lockAlarm
version: 1
- id: remoteControlStatus
version: 1
- id: lockUsers
version: 1
- id: refresh
tpmanley marked this conversation as resolved.
Show resolved Hide resolved
version: 1
categories:
- name: SmartLock
146 changes: 0 additions & 146 deletions drivers/SmartThings/matter-lock/src/aqara-lock/init.lua
HunsupJung marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

17 changes: 2 additions & 15 deletions drivers/SmartThings/matter-lock/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ local function lock_state_handler(driver, device, ib, response)
local LockState = DoorLock.attributes.LockState
local attr = capabilities.lock.lock
local LOCK_STATE = {
[LockState.NOT_FULLY_LOCKED] = attr.not_fully_locked(),
[LockState.NOT_FULLY_LOCKED] = attr.unknown(),
[LockState.LOCKED] = attr.locked(),
[LockState.UNLOCKED] = attr.unlocked(),
[UNLATCHED_STATE] = attr.unlocked(), -- Fully unlocked with latch pulled
Expand All @@ -97,16 +97,6 @@ local function handle_battery_percent_remaining(driver, device, ib, response)
end
end

local function handle_battery_charge_level(driver, device, ib, response)
if ib.data.value == clusters.PowerSource.types.BatChargeLevelEnum.OK then
device:emit_event(capabilities.batteryLevel.battery.normal())
elseif ib.data.value == clusters.PowerSource.types.BatChargeLevelEnum.WARNING then
device:emit_event(capabilities.batteryLevel.battery.warning())
elseif ib.data.value == clusters.PowerSource.types.BatChargeLevelEnum.CRITICAL then
device:emit_event(capabilities.batteryLevel.battery.critical())
end
end

local function max_pin_code_len_handler(driver, device, ib, response)
device:emit_event(capabilities.lockCodes.maxCodeLength(ib.data.value, {visibility = {displayed = false}}))
end
Expand Down Expand Up @@ -583,7 +573,6 @@ local matter_lock_driver = {
},
[PowerSource.ID] = {
[PowerSource.attributes.BatPercentRemaining.ID] = handle_battery_percent_remaining,
[PowerSource.attributes.BatChargeLevel.ID] = handle_battery_charge_level,
},
},
event = {
Expand All @@ -604,7 +593,6 @@ local matter_lock_driver = {
subscribed_attributes = {
[capabilities.lock.ID] = {DoorLock.attributes.LockState},
[capabilities.battery.ID] = {PowerSource.attributes.BatPercentRemaining},
[capabilities.batteryLevel.ID] = {PowerSource.attributes.BatChargeLevel},
},
subscribed_events = {
[capabilities.tamperAlert.ID] = {DoorLock.events.DoorLockAlarm, DoorLock.events.LockOperation},
Expand All @@ -630,10 +618,9 @@ local matter_lock_driver = {
capabilities.lockCodes,
capabilities.tamperAlert,
capabilities.battery,
capabilities.batteryLevel,
},
sub_drivers = {
require("aqara-lock"),
require("new-matter-lock"),
},
lifecycle_handlers = {init = device_init, added = device_added},
}
Expand Down
8 changes: 7 additions & 1 deletion drivers/SmartThings/matter-lock/src/lock_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ local lock_utils = {
COTA_CODE_NAME = "ST Remote Operation Code",
COTA_CRED_INDEX = "cotaCredIndex",
NONFUNCTIONAL = "nonFunctional",
COTA_READ_INITIALIZED = "cotaReadInitialized"
COTA_READ_INITIALIZED = "cotaReadInitialized",
BUSY_STATE = "busyState",
COMMAND_NAME = "commandName",
USER_INDEX = "userIndex",
USER_TYPE = "userType",
CRED_INDEX = "credentialIndex",
CRED_DATA = "credentialData"
}
local capabilities = require "st.capabilities"
local json = require "st.json"
Expand Down
Loading
Loading