@@ -77,6 +77,52 @@ local mock_device_no_hue_sat = test.mock_device.build_test_matter_device({
7777 }
7878})
7979
80+ local mock_device_color_temp = test .mock_device .build_test_matter_device ({
81+ profile = t_utils .get_profile_definition (" light-level-colorTemperature.yml" ),
82+ manufacturer_info = {
83+ vendor_id = 0x0000 ,
84+ product_id = 0x0000 ,
85+ },
86+ endpoints = {
87+ {
88+ endpoint_id = 1 ,
89+ clusters = {
90+ {cluster_id = clusters .OnOff .ID , cluster_type = " SERVER" },
91+ {cluster_id = clusters .ColorControl .ID , cluster_type = " BOTH" , feature_map = 30 },
92+ {cluster_id = clusters .LevelControl .ID , cluster_type = " SERVER" }
93+ },
94+ device_types = {
95+ {device_type_id = 0x0100 , device_type_revision = 1 }, -- On/Off Light
96+ {device_type_id = 0x010C , device_type_revision = 1 } -- Color Temperature Light
97+ }
98+ }
99+ }
100+ })
101+
102+ local mock_device_extended_color = test .mock_device .build_test_matter_device ({
103+ profile = t_utils .get_profile_definition (" light-color-level.yml" ),
104+ manufacturer_info = {
105+ vendor_id = 0x0000 ,
106+ product_id = 0x0000 ,
107+ },
108+ endpoints = {
109+ {
110+ endpoint_id = 1 ,
111+ clusters = {
112+ {cluster_id = clusters .OnOff .ID , cluster_type = " SERVER" },
113+ {cluster_id = clusters .ColorControl .ID , cluster_type = " BOTH" , feature_map = 30 },
114+ {cluster_id = clusters .LevelControl .ID , cluster_type = " SERVER" , feature_map = 2 }
115+ },
116+ device_types = {
117+ {device_type_id = 0x0100 , device_type_revision = 1 }, -- On/Off Light
118+ {device_type_id = 0x0101 , device_type_revision = 1 }, -- Dimmable Light
119+ {device_type_id = 0x010C , device_type_revision = 1 }, -- Color Temperature Light
120+ {device_type_id = 0x010D , device_type_revision = 1 }, -- Extended Color Light
121+ }
122+ }
123+ }
124+ })
125+
80126local cluster_subscribe_list = {
81127 clusters .OnOff .attributes .OnOff ,
82128 clusters .LevelControl .attributes .CurrentLevel ,
@@ -146,6 +192,67 @@ local function test_init_no_hue_sat()
146192 set_color_mode (mock_device_no_hue_sat , 1 , clusters .ColorControl .types .ColorMode .CURRENTX_AND_CURRENTY )
147193end
148194
195+
196+ local cluster_subscribe_list_color_temp = {
197+ clusters .OnOff .attributes .OnOff ,
198+ clusters .LevelControl .attributes .CurrentLevel ,
199+ clusters .LevelControl .attributes .MaxLevel ,
200+ clusters .LevelControl .attributes .MinLevel ,
201+ clusters .ColorControl .attributes .ColorTemperatureMireds ,
202+ clusters .ColorControl .attributes .ColorTempPhysicalMaxMireds ,
203+ clusters .ColorControl .attributes .ColorTempPhysicalMinMireds
204+ }
205+
206+ local function test_init_color_temp ()
207+ test .mock_device .add_test_device (mock_device_color_temp )
208+ local subscribe_request = cluster_subscribe_list_color_temp [1 ]:subscribe (mock_device_color_temp )
209+ for i , cluster in ipairs (cluster_subscribe_list_color_temp ) do
210+ if i > 1 then
211+ subscribe_request :merge (cluster :subscribe (mock_device_color_temp ))
212+ end
213+ end
214+ test .socket .matter :__expect_send ({mock_device_color_temp .id , subscribe_request })
215+ test .socket .device_lifecycle :__queue_receive ({ mock_device_color_temp .id , " added" })
216+ test .socket .matter :__expect_send ({mock_device_color_temp .id , subscribe_request })
217+
218+ test .socket .device_lifecycle :__queue_receive ({ mock_device_color_temp .id , " init" })
219+ test .socket .matter :__expect_send ({mock_device_color_temp .id , subscribe_request })
220+
221+ test .socket .device_lifecycle :__queue_receive ({ mock_device_color_temp .id , " doConfigure" })
222+ mock_device_color_temp :expect_metadata_update ({ provisioning_state = " PROVISIONED" })
223+ end
224+
225+ local function test_init_extended_color ()
226+ test .mock_device .add_test_device (mock_device_extended_color )
227+ local subscribe_request = cluster_subscribe_list [1 ]:subscribe (mock_device_extended_color )
228+ for i , cluster in ipairs (cluster_subscribe_list ) do
229+ if i > 1 then
230+ subscribe_request :merge (cluster :subscribe (mock_device_extended_color ))
231+ end
232+ end
233+ test .socket .matter :__expect_send ({mock_device_extended_color .id , subscribe_request })
234+ test .socket .device_lifecycle :__queue_receive ({ mock_device_extended_color .id , " added" })
235+ test .socket .matter :__expect_send ({mock_device_extended_color .id , subscribe_request })
236+
237+ test .socket .device_lifecycle :__queue_receive ({ mock_device_extended_color .id , " init" })
238+ test .socket .matter :__expect_send ({mock_device_extended_color .id , subscribe_request })
239+
240+ test .socket .device_lifecycle :__queue_receive ({ mock_device_extended_color .id , " doConfigure" })
241+ mock_device_extended_color :expect_metadata_update ({ provisioning_state = " PROVISIONED" })
242+ end
243+
244+ test .register_message_test (
245+ " Test that Color Temperature Light device does not switch profiles" ,
246+ {},
247+ { test_init = test_init_color_temp }
248+ )
249+
250+ test .register_message_test (
251+ " Test that Extended Color Light device does not switch profiles" ,
252+ {},
253+ { test_init = test_init_extended_color }
254+ )
255+
149256test .register_message_test (
150257 " On command should send the appropriate commands" ,
151258 {
0 commit comments