From e2d8f58d557da7c6c33c922dc19591413a331625 Mon Sep 17 00:00:00 2001 From: Hunsup Jung Date: Tue, 26 Nov 2024 14:05:10 +0900 Subject: [PATCH] Add embedded device configure to matter-lock driver for unlatch Signed-off-by: Hunsup Jung --- .../matter-lock/profiles/lock-unlatch.yml | 82 ++++++++++++++++++- .../lock-user-pin-schedule-unlatch.yml | 82 ++++++++++++++++++- .../profiles/lock-user-pin-unlatch.yml | 82 ++++++++++++++++++- .../profiles/lock-user-schedule-unlatch.yml | 65 ++++++++++++++- .../profiles/lock-user-unlatch.yml | 82 ++++++++++++++++++- .../matter-lock/src/new-matter-lock/init.lua | 10 ++- 6 files changed, 397 insertions(+), 6 deletions(-) diff --git a/drivers/SmartThings/matter-lock/profiles/lock-unlatch.yml b/drivers/SmartThings/matter-lock/profiles/lock-unlatch.yml index 8b2fc0f95a..c234c66bf3 100644 --- a/drivers/SmartThings/matter-lock/profiles/lock-unlatch.yml +++ b/drivers/SmartThings/matter-lock/profiles/lock-unlatch.yml @@ -1,6 +1,7 @@ name: lock-unlatch components: -- id: main +- label: Main + id: main capabilities: - id: lock version: 1 @@ -10,6 +11,7 @@ components: enabledValues: - locked - unlocked + - unlatched - not fully locked - id: lockAlarm version: 1 @@ -21,3 +23,81 @@ components: version: 1 categories: - name: SmartLock +deviceConfig: + dashboard: + states: + - component: main + capability: lock + version: 1 + actions: + - component: main + capability: lock + version: 1 + detailView: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + patch: + - op: add + path: /1 + value: + capability: lock + version: 1 + component: main + label: '{{i18n.commands.unlatch.label}}' + displayType: pushButton + pushButton: + command: unlatch + automation: + conditions: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + actions: + - component: main + capability: lock + version: 1 + values: + - key: '{{enumCommands}}' + alternatives: + - key: lock + type: inactive + value: '{{i18n.commands.lock.label}}' + - key: unlock + value: '{{i18n.commands.unlock.label}}' + - key: unlatch + value: '{{i18n.commands.unlatch.label}}' \ No newline at end of file diff --git a/drivers/SmartThings/matter-lock/profiles/lock-user-pin-schedule-unlatch.yml b/drivers/SmartThings/matter-lock/profiles/lock-user-pin-schedule-unlatch.yml index b269eed705..e6f328dff8 100644 --- a/drivers/SmartThings/matter-lock/profiles/lock-user-pin-schedule-unlatch.yml +++ b/drivers/SmartThings/matter-lock/profiles/lock-user-pin-schedule-unlatch.yml @@ -1,6 +1,7 @@ name: lock-user-pin-schedule-unlatch components: -- id: main +- label: Main + id: main capabilities: - id: lock version: 1 @@ -10,6 +11,7 @@ components: enabledValues: - locked - unlocked + - unlatched - not fully locked - id: lockAlarm version: 1 @@ -27,3 +29,81 @@ components: version: 1 categories: - name: SmartLock +deviceConfig: + dashboard: + states: + - component: main + capability: lock + version: 1 + actions: + - component: main + capability: lock + version: 1 + detailView: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + patch: + - op: add + path: /1 + value: + capability: lock + version: 1 + component: main + label: '{{i18n.commands.unlatch.label}}' + displayType: pushButton + pushButton: + command: unlatch + automation: + conditions: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + actions: + - component: main + capability: lock + version: 1 + values: + - key: '{{enumCommands}}' + alternatives: + - key: lock + type: inactive + value: '{{i18n.commands.lock.label}}' + - key: unlock + value: '{{i18n.commands.unlock.label}}' + - key: unlatch + value: '{{i18n.commands.unlatch.label}}' \ No newline at end of file diff --git a/drivers/SmartThings/matter-lock/profiles/lock-user-pin-unlatch.yml b/drivers/SmartThings/matter-lock/profiles/lock-user-pin-unlatch.yml index 132a4b2339..53cefe16b9 100644 --- a/drivers/SmartThings/matter-lock/profiles/lock-user-pin-unlatch.yml +++ b/drivers/SmartThings/matter-lock/profiles/lock-user-pin-unlatch.yml @@ -1,6 +1,7 @@ name: lock-user-pin-unlatch components: -- id: main +- label: Main + id: main capabilities: - id: lock version: 1 @@ -10,6 +11,7 @@ components: enabledValues: - locked - unlocked + - unlatched - not fully locked - id: lockAlarm version: 1 @@ -25,3 +27,81 @@ components: version: 1 categories: - name: SmartLock +deviceConfig: + dashboard: + states: + - component: main + capability: lock + version: 1 + actions: + - component: main + capability: lock + version: 1 + detailView: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + patch: + - op: add + path: /1 + value: + capability: lock + version: 1 + component: main + label: '{{i18n.commands.unlatch.label}}' + displayType: pushButton + pushButton: + command: unlatch + automation: + conditions: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + actions: + - component: main + capability: lock + version: 1 + values: + - key: '{{enumCommands}}' + alternatives: + - key: lock + type: inactive + value: '{{i18n.commands.lock.label}}' + - key: unlock + value: '{{i18n.commands.unlock.label}}' + - key: unlatch + value: '{{i18n.commands.unlatch.label}}' \ No newline at end of file diff --git a/drivers/SmartThings/matter-lock/profiles/lock-user-schedule-unlatch.yml b/drivers/SmartThings/matter-lock/profiles/lock-user-schedule-unlatch.yml index 557c586961..c31062f882 100644 --- a/drivers/SmartThings/matter-lock/profiles/lock-user-schedule-unlatch.yml +++ b/drivers/SmartThings/matter-lock/profiles/lock-user-schedule-unlatch.yml @@ -1,6 +1,7 @@ name: lock-user-schedule-unlatch components: -- id: main +- label: Main + id: main capabilities: - id: lock version: 1 @@ -10,6 +11,7 @@ components: enabledValues: - locked - unlocked + - unlatched - not fully locked - id: lockAlarm version: 1 @@ -25,3 +27,64 @@ components: version: 1 categories: - name: SmartLock +deviceConfig: + dashboard: + states: + - component: main + capability: lock + version: 1 + actions: + - component: main + capability: lock + version: 1 + detailView: + - component: main + capability: lock + version: 1 + patch: + - op: add + path: /1 + value: + capability: lock + version: 1 + component: main + label: '{{i18n.commands.unlatch.label}}' + displayType: pushButton + pushButton: + command: unlatch + automation: + conditions: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + actions: + - component: main + capability: lock + version: 1 + values: + - key: '{{enumCommands}}' + alternatives: + - key: lock + type: inactive + value: '{{i18n.commands.lock.label}}' + - key: unlock + value: '{{i18n.commands.unlock.label}}' + - key: unlatch + value: '{{i18n.commands.unlatch.label}}' \ No newline at end of file diff --git a/drivers/SmartThings/matter-lock/profiles/lock-user-unlatch.yml b/drivers/SmartThings/matter-lock/profiles/lock-user-unlatch.yml index 8207a94326..da98ca905c 100644 --- a/drivers/SmartThings/matter-lock/profiles/lock-user-unlatch.yml +++ b/drivers/SmartThings/matter-lock/profiles/lock-user-unlatch.yml @@ -1,6 +1,7 @@ name: lock-user-unlatch components: -- id: main +- label: Main + id: main capabilities: - id: lock version: 1 @@ -10,6 +11,7 @@ components: enabledValues: - locked - unlocked + - unlatched - not fully locked - id: lockAlarm version: 1 @@ -23,3 +25,81 @@ components: version: 1 categories: - name: SmartLock +deviceConfig: + dashboard: + states: + - component: main + capability: lock + version: 1 + actions: + - component: main + capability: lock + version: 1 + detailView: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + patch: + - op: add + path: /1 + value: + capability: lock + version: 1 + component: main + label: '{{i18n.commands.unlatch.label}}' + displayType: pushButton + pushButton: + command: unlatch + automation: + conditions: + - component: main + capability: lock + version: 1 + values: + - key: lock.value + alternatives: + - key: locked + type: inactive + value: '{{i18n.attributes.lock.i18n.value.locked.label}}' + - key: unlocked + value: '{{i18n.attributes.lock.i18n.value.unlocked.label}}' + - key: unlatched + value: '{{i18n.attributes.lock.i18n.value.unlatched.label}}' + - key: unknown + type: inactive + value: '{{i18n.attributes.lock.i18n.value.unknown.label}}' + - key: unlocked with timeout + value: '{{i18n.attributes.lock.i18n.value.unlocked with timeout.label}}' + - key: not fully locked + value: '{{i18n.attributes.lock.i18n.value.not fully locked.label}}' + actions: + - component: main + capability: lock + version: 1 + values: + - key: '{{enumCommands}}' + alternatives: + - key: lock + type: inactive + value: '{{i18n.commands.lock.label}}' + - key: unlock + value: '{{i18n.commands.unlock.label}}' + - key: unlatch + value: '{{i18n.commands.unlatch.label}}' \ No newline at end of file diff --git a/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua b/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua index 30e198514f..a0ac95d22e 100644 --- a/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua +++ b/drivers/SmartThings/matter-lock/src/new-matter-lock/init.lua @@ -140,6 +140,9 @@ local function do_configure(driver, device) end if #unbolt_eps > 0 then profile_name = profile_name .. "-unlatch" + device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock", "unlatch"}, {visibility = {displayed = false}})) + else + device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock"}, {visibility = {displayed = false}})) end device.log.info(string.format("Updating device profile to %s.", profile_name)) device:try_update_metadata({profile = profile_name}) @@ -218,9 +221,14 @@ local function operating_modes_handler(driver, device, ib, response) [op_type.PASSAGE] = false, } local result = opMode_map[ib.data.value] + local unbolt_eps = device:get_endpoints(DoorLock.ID, {feature_bitmap = DoorLock.types.Feature.UNBOLT}) if result == true then device:emit_event(status("true", {visibility = {displayed = true}})) - device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock"}, {visibility = {displayed = false}})) + if #unbolt_eps > 0 then + device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock", "unlatch"}, {visibility = {displayed = false}})) + else + device:emit_event(capabilities.lock.supportedLockCommands({"lock", "unlock"}, {visibility = {displayed = false}})) + end elseif result == false then device:emit_event(status("false", {visibility = {displayed = true}})) device:emit_event(capabilities.lock.supportedLockCommands({}, {visibility = {displayed = false}}))