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

Rolling up main into beta #1600

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions drivers/SmartThings/matter-lock/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions drivers/SmartThings/matter-lock/src/aqara-lock/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,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 @@ -144,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()
Loading