From 11bf2635239e4fd1df8886545c4195ed6165cc57 Mon Sep 17 00:00:00 2001 From: Harrison Carter <137556605+hcarter-775@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:37:53 -0500 Subject: [PATCH 1/4] CHAD 13147: Matter Sensor Driver Profiles Cleanup (#1466) * remove matter-motion and fix fingerprint to outdated profile --- drivers/SmartThings/matter-sensor/fingerprints.yml | 2 +- drivers/SmartThings/matter-sensor/profiles/motion.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/SmartThings/matter-sensor/fingerprints.yml b/drivers/SmartThings/matter-sensor/fingerprints.yml index 5dc6c97089..b5f2a501e7 100644 --- a/drivers/SmartThings/matter-sensor/fingerprints.yml +++ b/drivers/SmartThings/matter-sensor/fingerprints.yml @@ -31,7 +31,7 @@ matterManufacturer: deviceLabel: Heiman Motion Sensor vendorId: 0x120B productId: 0x1001 - deviceProfileName: matter-motion-battery-illuminance + deviceProfileName: motion-illuminance-battery - id: "4619/4145" deviceLabel: Heiman Door and Window D1-M vendorId: 0x120B diff --git a/drivers/SmartThings/matter-sensor/profiles/motion.yml b/drivers/SmartThings/matter-sensor/profiles/motion.yml index 533941ced0..150f7e12d1 100644 --- a/drivers/SmartThings/matter-sensor/profiles/motion.yml +++ b/drivers/SmartThings/matter-sensor/profiles/motion.yml @@ -1,4 +1,4 @@ -name: matter-motion +name: motion components: - id: main capabilities: From ec3c3ffd3775a69b7c2bb6ee3e7110d541df7338 Mon Sep 17 00:00:00 2001 From: Harrison Carter <137556605+hcarter-775@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:25:34 -0500 Subject: [PATCH 2/4] Matter Thermostat: clamp percentage values (#1592) * add: clamp on percent handler --- .../matter-thermostat/src/init.lua | 5 ++++- .../src/test/test_matter_air_purifier.lua | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/SmartThings/matter-thermostat/src/init.lua b/drivers/SmartThings/matter-thermostat/src/init.lua index bc08fd2f4d..9e099acbea 100644 --- a/drivers/SmartThings/matter-thermostat/src/init.lua +++ b/drivers/SmartThings/matter-thermostat/src/init.lua @@ -73,6 +73,9 @@ local RAC_DEVICE_TYPE_ID = 0x0072 local AP_DEVICE_TYPE_ID = 0x002D local FAN_DEVICE_TYPE_ID = 0x002B +local MIN_ALLOWED_PERCENT_VALUE = 0 +local MAX_ALLOWED_PERCENT_VALUE = 100 + local MGM3_PPM_CONVERSION_FACTOR = 24.45 local setpoint_limit_device_field = { @@ -868,7 +871,7 @@ end local function fan_speed_percent_attr_handler(driver, device, ib, response) local speed = 0 if ib.data.value ~= nil then - speed = ib.data.value + speed = utils.clamp_value(ib.data.value, MIN_ALLOWED_PERCENT_VALUE, MAX_ALLOWED_PERCENT_VALUE) end device:emit_event_for_endpoint(ib.endpoint_id, capabilities.fanSpeedPercent.percent(speed)) end diff --git a/drivers/SmartThings/matter-thermostat/src/test/test_matter_air_purifier.lua b/drivers/SmartThings/matter-thermostat/src/test/test_matter_air_purifier.lua index 7fb5873214..2e468b5071 100644 --- a/drivers/SmartThings/matter-thermostat/src/test/test_matter_air_purifier.lua +++ b/drivers/SmartThings/matter-thermostat/src/test/test_matter_air_purifier.lua @@ -707,4 +707,23 @@ test.register_message_test( } ) +test.register_message_test( + "Set percent command should clamp invalid percentage values", + { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.FanControl.attributes.PercentCurrent:build_test_report_data(mock_device, 1, 255) + } + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.fanSpeedPercent.percent(100)) + }, + } +) + test.run_registered_tests() From cc00516b8f57642e16867a800b87eb674f1bf74a Mon Sep 17 00:00:00 2001 From: Alissa Dornbos <79465613+lelandblue@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:10:24 -0400 Subject: [PATCH 3/4] New Device (Matter Lock) Aqara U300 (#1557) * new-device-Matter-Lock-Aqara-U300 * Matter Lock: add Aqara U300 to Aqara Lock sub driver * Remove product ID from aqara-lock sub driver, use vendor id only --------- Co-authored-by: Cooper Towns --- drivers/SmartThings/matter-lock/fingerprints.yml | 5 +++++ drivers/SmartThings/matter-lock/src/aqara-lock/init.lua | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/SmartThings/matter-lock/fingerprints.yml b/drivers/SmartThings/matter-lock/fingerprints.yml index d4610498bf..9b6431b0b8 100755 --- a/drivers/SmartThings/matter-lock/fingerprints.yml +++ b/drivers/SmartThings/matter-lock/fingerprints.yml @@ -16,6 +16,11 @@ matterManufacturer: vendorId: 0x115F productId: 0x2802 deviceProfileName: lock-lockalarm-nobattery + - id: "4447/10241" + deviceLabel: Aqara Smart Lock U300 + vendorId: 0x115F + productId: 0x2801 + deviceProfileName: lock-lockalarm-nobattery matterGeneric: - id: "matter/door-lock" deviceLabel: Matter Door Lock diff --git a/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua b/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua index fc83bc9483..2d8d9d02c3 100644 --- a/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua +++ b/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua @@ -18,13 +18,11 @@ local device_lib = require "st.device" local DoorLock = clusters.DoorLock local AQARA_MANUFACTURER_ID = 0x115f -local U200_PRODUCT_ID = 0x2802 local function is_aqara_products(opts, driver, device) if device.network_type == device_lib.NETWORK_TYPE_MATTER and - device.manufacturer_info.vendor_id == AQARA_MANUFACTURER_ID and - device.manufacturer_info.product_id == U200_PRODUCT_ID then - return true + device.manufacturer_info.vendor_id == AQARA_MANUFACTURER_ID then + return true end return false end From 1caa6571925061a3dbee1a3f43972dda193952bb Mon Sep 17 00:00:00 2001 From: Tom Manley Date: Thu, 22 Aug 2024 22:07:37 -0500 Subject: [PATCH 4/4] matter-lock: Expose 'not fully locked' when reported by the lock Previously we were mapping the 'not fully locked' to 'unknown' but now that the lock attribute has the 'not fully locked' variant we can expose that directly. https://smartthings.atlassian.net/browse/CHAD-11259 --- .../matter-lock/src/aqara-lock/init.lua | 5 +- drivers/SmartThings/matter-lock/src/init.lua | 2 +- .../src/test/test_aqara_matter_lock.lua | 42 ++++++++++++- .../matter-lock/src/test/test_matter_lock.lua | 62 ++++++++++++++++++- 4 files changed, 106 insertions(+), 5 deletions(-) diff --git a/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua b/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua index 2d8d9d02c3..835b41de1a 100644 --- a/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua +++ b/drivers/SmartThings/matter-lock/src/aqara-lock/init.lua @@ -57,7 +57,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.unknown(), + [LockState.NOT_FULLY_LOCKED] = attr.not_fully_locked(), [LockState.LOCKED] = attr.locked(), [LockState.UNLOCKED] = attr.unlocked(), } @@ -142,4 +142,5 @@ local aqara_lock_handler = { can_handle = is_aqara_products } -return aqara_lock_handler \ No newline at end of file +return aqara_lock_handler + diff --git a/drivers/SmartThings/matter-lock/src/init.lua b/drivers/SmartThings/matter-lock/src/init.lua index 2d65c5d890..a8eabfea3a 100755 --- a/drivers/SmartThings/matter-lock/src/init.lua +++ b/drivers/SmartThings/matter-lock/src/init.lua @@ -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.unknown(), + [LockState.NOT_FULLY_LOCKED] = attr.not_fully_locked(), [LockState.LOCKED] = attr.locked(), [LockState.UNLOCKED] = attr.unlocked(), [UNLATCHED_STATE] = attr.unlocked(), -- Fully unlocked with latch pulled diff --git a/drivers/SmartThings/matter-lock/src/test/test_aqara_matter_lock.lua b/drivers/SmartThings/matter-lock/src/test/test_aqara_matter_lock.lua index a9ec6dd950..9b2cd282ed 100644 --- a/drivers/SmartThings/matter-lock/src/test/test_aqara_matter_lock.lua +++ b/drivers/SmartThings/matter-lock/src/test/test_aqara_matter_lock.lua @@ -100,7 +100,7 @@ test.register_message_test( ) test.register_message_test( - "Handle received Lock State from Matter device.", { + "Handle received LockState.LOCKED from Matter device.", { { channel = "matter", direction = "receive", @@ -119,6 +119,46 @@ test.register_message_test( } ) +test.register_message_test( + "Handle received LockState.UNLOCKED from Matter device.", { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.DoorLock.attributes.LockState:build_test_report_data( + mock_device, 1, clusters.DoorLock.attributes.LockState.UNLOCKED + ), + }, + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.lock.lock.unlocked()), + }, + } +) + +test.register_message_test( + "Handle received LockState.NOT_FULLY_LOCKED from Matter device.", { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.DoorLock.attributes.LockState:build_test_report_data( + mock_device, 1, clusters.DoorLock.attributes.LockState.NOT_FULLY_LOCKED + ), + }, + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.lock.lock.not_fully_locked()), + }, + } +) + local function refresh_commands(dev) local req = clusters.DoorLock.attributes.LockState:read(dev) return req diff --git a/drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua b/drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua index c9ab170b7d..30e74e9a3c 100644 --- a/drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua +++ b/drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua @@ -96,7 +96,7 @@ test.register_message_test( ) test.register_message_test( - "Handle received Lock State from Matter device.", { + "Handle received LockState.LOCKED from Matter device.", { { channel = "matter", direction = "receive", @@ -115,6 +115,66 @@ test.register_message_test( } ) +test.register_message_test( + "Handle received LockState.UNLOCKED from Matter device.", { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.DoorLock.attributes.LockState:build_test_report_data( + mock_device, 10, clusters.DoorLock.attributes.LockState.UNLOCKED + ), + }, + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.lock.lock.unlocked()), + }, + } +) + +test.register_message_test( + "Handle received LockState.NOT_FULLY_LOCKED from Matter device.", { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.DoorLock.attributes.LockState:build_test_report_data( + mock_device, 10, clusters.DoorLock.attributes.LockState.NOT_FULLY_LOCKED + ), + }, + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.lock.lock.not_fully_locked()), + }, + } +) + +test.register_message_test( + "Handle received LockState.UNLATCHED from Matter device.", { + { + channel = "matter", + direction = "receive", + message = { + mock_device.id, + clusters.DoorLock.attributes.LockState:build_test_report_data( + mock_device, 10, clusters.DoorLock.attributes.LockState.UNLATCHED + ), + }, + }, + { + channel = "capability", + direction = "send", + message = mock_device:generate_test_message("main", capabilities.lock.lock.unlocked()), + }, + } +) + test.register_message_test( "Handle received BatPercentRemaining from device.", { {