Skip to content

Commit 419a3ec

Browse files
authored
re-add switch vendor override check, add vendor override test (#2603)
1 parent 14aa95e commit 419a3ec

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ function DeviceConfiguration.match_profile(driver, device)
194194
updated_profile = "light-color-level-fan"
195195
elseif generic_profile("light-level") and #device:get_endpoints(clusters.OccupancySensing.ID) > 0 then
196196
updated_profile = "light-level-motion"
197+
elseif generic_profile("plug-binary") or generic_profile("plug-level") then
198+
if switch_utils.check_switch_category_vendor_overrides(device) then
199+
updated_profile = string.gsub(updated_profile, "plug", "switch")
200+
end
197201
elseif generic_profile("light-level-colorTemperature") or generic_profile("light-color-level") then
198202
-- ignore attempts to dynamically profile light-level-colorTemperature and light-color-level devices for now, since
199203
-- these may lose fingerprinted Kelvin ranges when dynamically profiled.

drivers/SmartThings/matter-switch/src/test/test_matter_switch_device_types.lua

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,35 @@ local mock_device_dimmer = test.mock_device.build_test_matter_device({
9292
}
9393
})
9494

95+
local mock_device_switch_vendor_override = test.mock_device.build_test_matter_device({
96+
profile = t_utils.get_profile_definition("switch-binary.yml"),
97+
manufacturer_info = {
98+
vendor_id = 0x109B,
99+
product_id = 0x1001,
100+
},
101+
endpoints = {
102+
{
103+
endpoint_id = 0,
104+
clusters = {
105+
{cluster_id = clusters.Basic.ID, cluster_type = "SERVER"},
106+
},
107+
device_types = {
108+
{device_type_id = 0x0016, device_type_revision = 1} -- RootNode
109+
}
110+
},
111+
{
112+
endpoint_id = 1,
113+
clusters = {
114+
{cluster_id = clusters.OnOff.ID, cluster_type = "SERVER", cluster_revision = 1, feature_map = 0},
115+
},
116+
device_types = {
117+
{device_type_id = 0x010A, device_type_revision = 1} -- OnOff PlugIn Unit
118+
}
119+
}
120+
}
121+
})
122+
123+
95124
local mock_device_color_dimmer = test.mock_device.build_test_matter_device({
96125
profile = t_utils.get_profile_definition("matter-thing.yml"),
97126
manufacturer_info = {
@@ -485,6 +514,18 @@ local function test_init_color_dimmer()
485514
mock_device_color_dimmer:expect_metadata_update({ provisioning_state = "PROVISIONED" })
486515
end
487516

517+
local function test_init_switch_vendor_override()
518+
test.mock_device.add_test_device(mock_device_switch_vendor_override)
519+
local subscribe_request = clusters.OnOff.attributes.OnOff:subscribe(mock_device_switch_vendor_override)
520+
test.socket.device_lifecycle:__queue_receive({ mock_device_switch_vendor_override.id, "added" })
521+
test.socket.matter:__expect_send({mock_device_switch_vendor_override.id, subscribe_request})
522+
test.socket.device_lifecycle:__queue_receive({ mock_device_switch_vendor_override.id, "init" })
523+
test.socket.matter:__expect_send({mock_device_switch_vendor_override.id, subscribe_request})
524+
test.socket.device_lifecycle:__queue_receive({ mock_device_switch_vendor_override.id, "doConfigure" })
525+
mock_device_switch_vendor_override:expect_metadata_update({ profile = "switch-binary" })
526+
mock_device_switch_vendor_override:expect_metadata_update({ provisioning_state = "PROVISIONED" })
527+
end
528+
488529
local function test_init_mounted_on_off_control()
489530
test.mock_device.add_test_device(mock_device_mounted_on_off_control)
490531
local cluster_subscribe_list = {
@@ -677,6 +718,13 @@ test.register_coroutine_test(
677718
{ test_init = test_init_onoff_client }
678719
)
679720

721+
test.register_coroutine_test(
722+
"Test init for device with requiring the switch category as a vendor override",
723+
function()
724+
end,
725+
{ test_init = test_init_switch_vendor_override }
726+
)
727+
680728
test.register_coroutine_test(
681729
"Test init for mounted onoff control parent cluster as server",
682730
function()

0 commit comments

Comments
 (0)