@@ -31,9 +31,10 @@ local DeviceConfiguration = {}
3131local SwitchDeviceConfiguration = {}
3232local ButtonDeviceConfiguration = {}
3333
34- function SwitchDeviceConfiguration .assign_profile_for_onoff_ep (device , onoff_ep_id , is_child_device )
35- local ep_info = switch_utils .get_endpoint_info (device , onoff_ep_id )
34+ function SwitchDeviceConfiguration .assign_profile_for_onoff_ep (device , server_onoff_ep_id , is_child_device )
35+ local ep_info = switch_utils .get_endpoint_info (device , server_onoff_ep_id )
3636
37+ -- per spec, the Switch device types support OnOff as CLIENT, though some vendors break spec and support it as SERVER.
3738 local primary_dt_id = switch_utils .find_max_subset_device_type (ep_info , fields .DEVICE_TYPE_ID .LIGHT )
3839 or switch_utils .find_max_subset_device_type (ep_info , fields .DEVICE_TYPE_ID .SWITCH )
3940 or ep_info .device_types [1 ] and ep_info .device_types [1 ].device_type_id
@@ -51,14 +52,14 @@ function SwitchDeviceConfiguration.assign_profile_for_onoff_ep(device, onoff_ep_
5152 for _ , vendor in pairs (fields .child_device_profile_overrides_per_vendor_id ) do
5253 for _ , fingerprint in ipairs (vendor ) do
5354 if device .manufacturer_info .product_id == fingerprint .product_id and
54- ((device .manufacturer_info .vendor_id == fields .AQARA_MANUFACTURER_ID and onoff_ep_id == 1 ) or generic_profile == fingerprint .initial_profile ) then
55+ ((device .manufacturer_info .vendor_id == fields .AQARA_MANUFACTURER_ID and server_onoff_ep_id == 1 ) or generic_profile == fingerprint .initial_profile ) then
5556 return fingerprint .target_profile
5657 end
5758 end
5859 end
5960 end
6061
61- -- if no supported device type is found, return switch-binary as the generic profile
62+ -- if no supported device type is found, return switch-binary as a generic "OnOff EP" profile
6263 return generic_profile or " switch-binary"
6364end
6465
0 commit comments