@@ -79,7 +79,6 @@ local device_type_profile_map = {
79
79
[ON_OFF_SWITCH_ID ] = " switch-binary" ,
80
80
[ON_OFF_DIMMER_SWITCH_ID ] = " switch-level" ,
81
81
[ON_OFF_COLOR_DIMMER_SWITCH_ID ] = " switch-color-level" ,
82
- [GENERIC_SWITCH_ID ] = " button"
83
82
}
84
83
85
84
local device_type_attribute_map = {
@@ -160,10 +159,10 @@ local device_type_attribute_map = {
160
159
}
161
160
162
161
local child_device_profile_overrides = {
163
- { vendor_id = 0x1321 , product_id = 0x000C , child_profile = " switch-binary" },
164
- { vendor_id = 0x1321 , product_id = 0x000D , child_profile = " switch-binary" },
165
- { vendor_id = 0x115F , product_id = 0x1008 , child_profile = " light-power-energy-powerConsumption" }, -- 2 switch
166
- { vendor_id = 0x115F , product_id = 0x1009 , child_profile = " light-power-energy-powerConsumption" }, -- 4 switch
162
+ { vendor_id = 0x1321 , product_id = 0x000C , target_profile = " switch-binary " , initial_profile = " plug -binary" },
163
+ { vendor_id = 0x1321 , product_id = 0x000D , target_profile = " switch-binary " , initial_profile = " plug -binary" },
164
+ { vendor_id = 0x115F , product_id = 0x1008 , target_profile = " light-power-energy-powerConsumption" }, -- 2 switch
165
+ { vendor_id = 0x115F , product_id = 0x1009 , target_profile = " light-power-energy-powerConsumption" }, -- 4 switch
167
166
}
168
167
169
168
local detect_matter_thing
436
435
local function assign_child_profile (device , child_ep )
437
436
local profile
438
437
439
- -- check if device has an overridden child profile that differs from the profile
440
- -- that would match the child's device type
441
- for _ , fingerprint in ipairs (child_device_profile_overrides ) do
442
- if device .manufacturer_info .vendor_id == fingerprint .vendor_id and
443
- device .manufacturer_info .product_id == fingerprint .product_id then
444
- if device .manufacturer_info .vendor_id == AQARA_MANUFACTURER_ID then
445
- if child_ep ~= 1 then
446
- -- To add Electrical Sensor only to the first EDGE_CHILD(light-power-energy-powerConsumption)
447
- -- The profile of the second EDGE_CHILD is determined in the "for" loop below (e.g., light-binary)
448
- break
449
- end
450
- end
451
- return fingerprint .child_profile
452
- end
453
- end
454
-
455
438
for _ , ep in ipairs (device .endpoints ) do
456
439
if ep .endpoint_id == child_ep then
457
440
-- Some devices report multiple device types which are a subset of
@@ -464,8 +447,26 @@ local function assign_child_profile(device, child_ep)
464
447
id = math.max (id , dt .device_type_id )
465
448
end
466
449
profile = device_type_profile_map [id ]
450
+ break
451
+ end
452
+ end
453
+
454
+ -- Check if device has an overridden child profile that differs from the profile that would match
455
+ -- the child's device type for the following two cases:
456
+ -- 1. To add Electrical Sensor only to the first EDGE_CHILD (light-power-energy-powerConsumption)
457
+ -- for the Aqara Light Switch H2. The profile of the second EDGE_CHILD for this device is
458
+ -- determined in the "for" loop above (e.g., light-binary)
459
+ -- 2. The selected profile for the child device matches the initial profile defined in
460
+ -- child_device_profile_overrides
461
+ for _ , fingerprint in ipairs (child_device_profile_overrides ) do
462
+ if device .manufacturer_info .vendor_id == fingerprint .vendor_id and
463
+ device .manufacturer_info .product_id == fingerprint .product_id and
464
+ ((device .manufacturer_info .vendor_id == AQARA_MANUFACTURER_ID and child_ep == 1 ) or profile == fingerprint .initial_profile ) then
465
+ profile = fingerprint .target_profile
466
+ break
467
467
end
468
468
end
469
+
469
470
-- default to "switch-binary" if no profile is found
470
471
return profile or " switch-binary"
471
472
end
0 commit comments