Skip to content

Commit

Permalink
Merge pull request #1600 from SmartThingsCommunity/main
Browse files Browse the repository at this point in the history
Rolling up main into beta
  • Loading branch information
cbaumler authored Aug 26, 2024
2 parents 3a72f33 + 5bd9bbd commit a4529e9
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 8 deletions.
5 changes: 3 additions & 2 deletions drivers/SmartThings/matter-lock/src/aqara-lock/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -142,4 +142,5 @@ local aqara_lock_handler = {
can_handle = is_aqara_products
}

return aqara_lock_handler
return aqara_lock_handler

2 changes: 1 addition & 1 deletion 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.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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
62 changes: 61 additions & 1 deletion drivers/SmartThings/matter-lock/src/test/test_matter_lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.", {
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/matter-sensor/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/SmartThings/matter-sensor/profiles/motion.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: matter-motion
name: motion
components:
- id: main
capabilities:
Expand Down
5 changes: 4 additions & 1 deletion drivers/SmartThings/matter-thermostat/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit a4529e9

Please sign in to comment.