@@ -170,14 +170,20 @@ local device_type_attribute_map = {
170
170
}
171
171
}
172
172
173
- local child_device_profile_overrides = {
174
- { vendor_id = 0x1321 , product_id = 0x000C , target_profile = " switch-binary" , initial_profile = " plug-binary" },
175
- { vendor_id = 0x1321 , product_id = 0x000D , target_profile = " switch-binary" , initial_profile = " plug-binary" },
176
- { vendor_id = 0x115F , product_id = 0x1003 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons, 1 Channel
177
- { vendor_id = 0x115F , product_id = 0x1004 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons, 2 Channels
178
- { vendor_id = 0x115F , product_id = 0x1005 , target_profile = " light-power-energy-powerConsumption" }, -- 4 Buttons, 3 Channels
179
- { vendor_id = 0x115F , product_id = 0x1008 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons, 1 Channel
180
- { vendor_id = 0x115F , product_id = 0x1009 , target_profile = " light-power-energy-powerConsumption" }, -- 4 Buttons, 2 Channels
173
+ local child_device_profile_overrides_per_vendor_id = {
174
+ [0x1321 ] = {
175
+ { product_id = 0x000C , target_profile = " switch-binary" , initial_profile = " plug-binary" },
176
+ { product_id = 0x000D , target_profile = " switch-binary" , initial_profile = " plug-binary" },
177
+ },
178
+ [0x115F ] = {
179
+ { product_id = 0x1003 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 1 Channel(On/Off Light)
180
+ { product_id = 0x1004 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 2 Channels(On/Off Light)
181
+ { product_id = 0x1005 , target_profile = " light-power-energy-powerConsumption" }, -- 4 Buttons(Generic Switch), 3 Channels(On/Off Light)
182
+ { product_id = 0x1006 , target_profile = " light-level-power-energy-powerConsumption" }, -- 3 Buttons(Generic Switch), 1 Channels(Dimmable Light)
183
+ { product_id = 0x1008 , target_profile = " light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 1 Channel(On/Off Light)
184
+ { product_id = 0x1009 , target_profile = " light-power-energy-powerConsumption" }, -- 4 Buttons(Generic Switch), 2 Channels(On/Off Light)
185
+ { product_id = 0x100A , target_profile = " light-level-power-energy-powerConsumption" }, -- 1 Buttons(Generic Switch), 1 Channels(Dimmable Light)
186
+ }
181
187
}
182
188
183
189
local detect_matter_thing
@@ -383,6 +389,11 @@ local function device_type_supports_button_switch_combination(device, endpoint_i
383
389
if ep .endpoint_id == endpoint_id then
384
390
for _ , dt in ipairs (ep .device_types ) do
385
391
if dt .device_type_id == DIMMABLE_LIGHT_DEVICE_TYPE_ID then
392
+ for _ , fingerprint in ipairs (child_device_profile_overrides_per_vendor_id [0x115F ]) do
393
+ if device .manufacturer_info .product_id == fingerprint .product_id then
394
+ return false -- For Aqara Dimmer Switch with Button.
395
+ end
396
+ end
386
397
return true
387
398
end
388
399
end
@@ -467,12 +478,12 @@ local function assign_child_profile(device, child_ep)
467
478
-- determined in the "for" loop above (e.g., light-binary)
468
479
-- 2. The selected profile for the child device matches the initial profile defined in
469
480
-- child_device_profile_overrides
470
- for _ , fingerprint in ipairs ( child_device_profile_overrides ) do
471
- if device . manufacturer_info . vendor_id == fingerprint . vendor_id and
472
- device .manufacturer_info .product_id == fingerprint .product_id and
473
- ((device .manufacturer_info .vendor_id == AQARA_MANUFACTURER_ID and child_ep == 1 ) or profile == fingerprint .initial_profile ) then
474
- profile = fingerprint .target_profile
475
- break
481
+ for id , vendor in pairs ( child_device_profile_overrides_per_vendor_id ) do
482
+ for _ , fingerprint in ipairs ( vendor ) do
483
+ if device .manufacturer_info .product_id == fingerprint .product_id and
484
+ ((device .manufacturer_info .vendor_id == AQARA_MANUFACTURER_ID and child_ep == 1 ) or profile == fingerprint .initial_profile ) then
485
+ return fingerprint .target_profile
486
+ end
476
487
end
477
488
end
478
489
@@ -603,7 +614,7 @@ local function try_build_child_switch_profiles(driver, device, switch_eps, main_
603
614
}
604
615
)
605
616
parent_child_device = true
606
- if _ == 1 and child_profile == " light-power- energy-powerConsumption " then
617
+ if _ == 1 and string.find ( child_profile , " energy" ) then
607
618
-- when energy management is defined in the root endpoint(0), replace it with the first switch endpoint and process it.
608
619
device :set_field (ENERGY_MANAGEMENT_ENDPOINT , ep , {persist = true })
609
620
end
0 commit comments