@@ -552,7 +552,7 @@ local function find_child(parent, ep_id)
552
552
return parent :get_child_by_parent_assigned_key (string.format (" %d" , ep_id ))
553
553
end
554
554
555
- local function build_component_map (device , main_endpoint , button_eps , fan_eps )
555
+ local function build_component_map (device , main_endpoint , button_eps , light_eps )
556
556
local eps
557
557
local component_name
558
558
local component_field
@@ -561,9 +561,9 @@ local function build_component_map(device, main_endpoint, button_eps, fan_eps)
561
561
eps = button_eps
562
562
component_name = " button"
563
563
component_field = COMPONENT_TO_ENDPOINT_MAP_BUTTON
564
- elseif fan_eps ~= nil then
565
- eps = fan_eps
566
- component_name = " fan "
564
+ elseif light_eps ~= nil then
565
+ eps = light_eps
566
+ component_name = " light "
567
567
component_field = COMPONENT_TO_ENDPOINT_MAP_FAN
568
568
end
569
569
if eps == nil then return end
@@ -572,7 +572,10 @@ local function build_component_map(device, main_endpoint, button_eps, fan_eps)
572
572
component_map [" main" ] = main_endpoint
573
573
for component_num , ep in ipairs (eps ) do
574
574
if ep ~= main_endpoint then
575
- local component = component_name .. component_num
575
+ local component = component_name
576
+ if # eps > 2 then
577
+ component = component .. component_num
578
+ end
576
579
component_map [component ] = ep
577
580
end
578
581
end
@@ -691,13 +694,15 @@ local function initialize_buttons_and_switches(driver, device, main_endpoint)
691
694
end
692
695
end
693
696
694
- -- Any button or fan endpoints found will be added as additional components in the profile containing the
695
- -- main endpoint. The resulting endpoint to component map is saved in the COMPONENT_TO_ENDPOINT_MAP_BUTTON field
697
+ -- Any button endpoints found will be added as additional components in the profile containing the
698
+ -- main endpoint. An fan endpoint will be considered the main endpoint and other additional switch
699
+ -- endpoints will be added as additional components. The resulting endpoint to component map is
700
+ -- saved in the corresponding component to endpoint map field.
696
701
if # button_eps > 0 then
697
702
build_component_map (device , main_endpoint , button_eps )
698
703
build_button_profile (device , main_endpoint , # button_eps )
699
704
elseif # fan_eps > 0 then
700
- build_component_map (device , main_endpoint , fan_eps )
705
+ build_component_map (device , main_endpoint , switch_eps )
701
706
build_fan_profile (device , main_endpoint , # fan_eps )
702
707
end
703
708
0 commit comments