Skip to content

Commit a961e67

Browse files
Support Light with Motion Sensor (#2279)
This change adds a generic fingerprint and supporting profile for a light with a motion sensor.
1 parent 570fe54 commit a961e67

File tree

3 files changed

+96
-3
lines changed

3 files changed

+96
-3
lines changed

drivers/SmartThings/matter-switch/fingerprints.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,6 +2847,12 @@ matterGeneric:
28472847
- id: 0x010D # Extended Color Light
28482848
- id: 0x002B # Fan
28492849
deviceProfileName: light-color-level-fan
2850+
- id: "matter/dimmable/light/motion"
2851+
deviceLabel: Matter Dimmable Light Occupancy Sensor
2852+
deviceTypes:
2853+
- id: 0x0101 # Dimmable Light
2854+
- id: 0x0107 # Occupancy Sensor
2855+
deviceProfileName: light-level-motion
28502856

28512857
matterThing:
28522858
- id: SmartThings/MatterThing
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: light-level-motion
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: switch
6+
version: 1
7+
- id: switchLevel
8+
version: 1
9+
config:
10+
values:
11+
- key: "level.value"
12+
range: [1, 100]
13+
- id: motionSensor
14+
version: 1
15+
- id: firmwareUpdate
16+
version: 1
17+
- id: refresh
18+
version: 1
19+
categories:
20+
- name: Light

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

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,49 @@ local mock_device_parent_child_unsupported_device_type = test.mock_device.build_
362362
}
363363
})
364364

365+
local mock_device_light_level_motion = test.mock_device.build_test_matter_device({
366+
profile = t_utils.get_profile_definition("light-level-motion.yml"),
367+
manufacturer_info = {
368+
vendor_id = 0x0000,
369+
product_id = 0x0000,
370+
},
371+
endpoints = {
372+
{
373+
endpoint_id = 0,
374+
clusters = {
375+
{cluster_id = clusters.Basic.ID, cluster_type = "SERVER"},
376+
},
377+
device_types = {
378+
{device_type_id = 0x0016, device_type_revision = 1} -- RootNode
379+
}
380+
},
381+
{
382+
endpoint_id = 1,
383+
clusters = {
384+
{
385+
cluster_id = clusters.OnOff.ID,
386+
cluster_type = "SERVER",
387+
cluster_revision = 1,
388+
feature_map = 0, --u32 bitmap
389+
},
390+
{cluster_id = clusters.LevelControl.ID, cluster_type = "SERVER"}
391+
},
392+
device_types = {
393+
{device_type_id = 0x0101, device_type_revision = 1} -- Dimmable Light
394+
}
395+
},
396+
{
397+
endpoint_id = 2,
398+
clusters = {
399+
{cluster_id = clusters.OccupancySensing.ID, cluster_type = "SERVER"},
400+
},
401+
device_types = {
402+
{device_type_id = 0x0107, device_type_revision = 1} -- Occupancy Sensor
403+
}
404+
}
405+
}
406+
})
407+
365408
local function test_init_parent_child_switch_types()
366409
local subscribe_request = clusters.OnOff.attributes.OnOff:subscribe(mock_device_parent_child_switch_types)
367410
test.socket.matter:__expect_send({mock_device_parent_child_switch_types.id, subscribe_request})
@@ -505,6 +548,23 @@ local function test_init_parent_child_unsupported_device_type()
505548
})
506549
end
507550

551+
local function test_init_light_level_motion()
552+
local cluster_subscribe_list = {
553+
clusters.OnOff.attributes.OnOff,
554+
clusters.LevelControl.attributes.CurrentLevel,
555+
clusters.LevelControl.attributes.MaxLevel,
556+
clusters.LevelControl.attributes.MinLevel,
557+
clusters.OccupancySensing.attributes.Occupancy
558+
}
559+
local subscribe_request = cluster_subscribe_list[1]:subscribe(mock_device_light_level_motion)
560+
for i, cluster in ipairs(cluster_subscribe_list) do
561+
if i > 1 then
562+
subscribe_request:merge(cluster:subscribe(mock_device_light_level_motion))
563+
end
564+
end
565+
test.socket.matter:__expect_send({mock_device_light_level_motion.id, subscribe_request})
566+
test.mock_device.add_test_device(mock_device_light_level_motion)
567+
end
508568

509569
test.register_coroutine_test(
510570
"Test profile change on init for onoff parent cluster as server",
@@ -528,21 +588,21 @@ test.register_coroutine_test(
528588
)
529589

530590
test.register_coroutine_test(
531-
"Test profile change on init for onoff parent cluster as client",
591+
"Test init for onoff parent cluster as client",
532592
function()
533593
end,
534594
{ test_init = test_init_onoff_client }
535595
)
536596

537597
test.register_coroutine_test(
538-
"Test profile change on init for mounted onoff control parent cluster as server",
598+
"Test init for mounted onoff control parent cluster as server",
539599
function()
540600
end,
541601
{ test_init = test_init_mounted_on_off_control }
542602
)
543603

544604
test.register_coroutine_test(
545-
"Test profile change on init for mounted dimmable load control parent cluster as server",
605+
"Test init for mounted dimmable load control parent cluster as server",
546606
function()
547607
end,
548608
{ test_init = test_init_mounted_dimmable_load_control }
@@ -583,4 +643,11 @@ test.register_coroutine_test(
583643
{ test_init = test_init_parent_child_unsupported_device_type }
584644
)
585645

646+
test.register_coroutine_test(
647+
"Test init for light with motion sensor",
648+
function()
649+
end,
650+
{ test_init = test_init_light_level_motion }
651+
)
652+
586653
test.run_registered_tests()

0 commit comments

Comments
 (0)