@@ -54,6 +54,44 @@ local mock_device = test.mock_device.build_test_matter_device({
5454 }
5555})
5656
57+ local mock_device_switch = test .mock_device .build_test_matter_device ({
58+ label = " Matter Switch" ,
59+ profile = t_utils .get_profile_definition (" switch-fan.yml" ),
60+ manufacturer_info = {
61+ vendor_id = 0x0000 ,
62+ product_id = 0x0000 ,
63+ },
64+ endpoints = {
65+ {
66+ endpoint_id = 0 ,
67+ clusters = {
68+ {cluster_id = clusters .Basic .ID , cluster_type = " SERVER" },
69+ },
70+ device_types = {
71+ {device_type_id = 0x0016 , device_type_revision = 1 } -- RootNode
72+ }
73+ },
74+ {
75+ endpoint_id = mock_device_ep1 ,
76+ clusters = {
77+ {cluster_id = clusters .OnOff .ID , cluster_type = " SERVER" },
78+ },
79+ device_types = {
80+ {device_type_id = 0x010A , device_type_revision = 2 } -- On Off Plugin Unit
81+ }
82+ },
83+ {
84+ endpoint_id = mock_device_ep2 ,
85+ clusters = {
86+ {cluster_id = clusters .FanControl .ID , cluster_type = " SERVER" , feature_map = 15 },
87+ },
88+ device_types = {
89+ {device_type_id = 0x002B , device_type_revision = 1 ,} -- Fan
90+ }
91+ }
92+ }
93+ })
94+
5795local CLUSTER_SUBSCRIBE_LIST = {
5896 clusters .OnOff .attributes .OnOff ,
5997 clusters .LevelControl .attributes .CurrentLevel ,
@@ -72,6 +110,13 @@ local CLUSTER_SUBSCRIBE_LIST ={
72110 clusters .FanControl .attributes .PercentCurrent ,
73111}
74112
113+ local SWITCH_CLUSTER_SUBSCRIBE_LIST = {
114+ clusters .OnOff .attributes .OnOff ,
115+ clusters .FanControl .attributes .FanModeSequence ,
116+ clusters .FanControl .attributes .FanMode ,
117+ clusters .FanControl .attributes .PercentCurrent ,
118+ }
119+
75120local function test_init ()
76121 test .disable_startup_messages ()
77122 test .mock_device .add_test_device (mock_device )
95140
96141test .set_test_init_function (test_init )
97142
143+ local function test_init_switch ()
144+ test .disable_startup_messages ()
145+ test .mock_device .add_test_device (mock_device_switch )
146+ local subscribe_request = SWITCH_CLUSTER_SUBSCRIBE_LIST [1 ]:subscribe (mock_device_switch )
147+ for i , clus in ipairs (SWITCH_CLUSTER_SUBSCRIBE_LIST ) do
148+ if i > 1 then subscribe_request :merge (clus :subscribe (mock_device_switch )) end
149+ end
150+
151+ test .socket .device_lifecycle :__queue_receive ({ mock_device_switch .id , " added" })
152+ test .socket .matter :__expect_send ({mock_device_switch .id , subscribe_request })
153+
154+ test .socket .device_lifecycle :__queue_receive ({ mock_device_switch .id , " init" })
155+ test .socket .matter :__expect_send ({mock_device_switch .id , subscribe_request })
156+
157+ test .socket .device_lifecycle :__queue_receive ({ mock_device_switch .id , " doConfigure" })
158+ mock_device_switch :expect_metadata_update ({ profile = " switch-fan" })
159+ mock_device_switch :expect_metadata_update ({ provisioning_state = " PROVISIONED" })
160+ end
161+
162+ test .register_message_test (
163+ " On Off Plug In Unit + Fan should profile as switch-fan" ,
164+ {},
165+ { test_init = test_init_switch }
166+ )
167+
98168test .register_coroutine_test (
99169 " Switch capability should send the appropriate commands" , function ()
100170 test .socket .capability :__queue_receive (
0 commit comments