@@ -520,9 +520,6 @@ local function assign_child_profile(device, child_ep)
520
520
end
521
521
522
522
local function configure_buttons (device )
523
- if device .network_type == device_lib .NETWORK_TYPE_CHILD then
524
- return
525
- end
526
523
local ms_eps = device :get_endpoints (clusters .Switch .ID , {feature_bitmap = clusters .Switch .types .SwitchFeature .MOMENTARY_SWITCH })
527
524
local msr_eps = device :get_endpoints (clusters .Switch .ID , {feature_bitmap = clusters .Switch .types .SwitchFeature .MOMENTARY_SWITCH_RELEASE })
528
525
local msl_eps = device :get_endpoints (clusters .Switch .ID , {feature_bitmap = clusters .Switch .types .SwitchFeature .MOMENTARY_SWITCH_LONG_PRESS })
@@ -689,35 +686,34 @@ local function detect_bridge(device)
689
686
end
690
687
691
688
local function device_init (driver , device )
692
- if device .network_type ~= device_lib .NETWORK_TYPE_MATTER then
693
- return
694
- end
695
- check_field_name_updates (device )
696
- device :set_component_to_endpoint_fn (component_to_endpoint )
697
- device :set_endpoint_to_component_fn (endpoint_to_component )
698
- if device :get_field (IS_PARENT_CHILD_DEVICE ) then
699
- device :set_find_child (find_child )
700
- end
701
- local main_endpoint = find_default_endpoint (device )
702
- -- ensure subscription to all endpoint attributes- including those mapped to child devices
703
- for _ , ep in ipairs (device .endpoints ) do
704
- if ep .endpoint_id ~= main_endpoint then
705
- local id = 0
706
- for _ , dt in ipairs (ep .device_types ) do
707
- id = math.max (id , dt .device_type_id )
708
- end
709
- for _ , attr in pairs (device_type_attribute_map [id ] or {}) do
710
- if id == GENERIC_SWITCH_ID and
711
- attr ~= clusters .PowerSource .attributes .BatPercentRemaining and
712
- attr ~= clusters .PowerSource .attributes .BatChargeLevel then
713
- device :add_subscribed_event (attr )
714
- else
715
- device :add_subscribed_attribute (attr )
689
+ if device .network_type == device_lib .NETWORK_TYPE_MATTER then
690
+ check_field_name_updates (device )
691
+ device :set_component_to_endpoint_fn (component_to_endpoint )
692
+ device :set_endpoint_to_component_fn (endpoint_to_component )
693
+ if device :get_field (IS_PARENT_CHILD_DEVICE ) then
694
+ device :set_find_child (find_child )
695
+ end
696
+ local main_endpoint = find_default_endpoint (device )
697
+ -- ensure subscription to all endpoint attributes- including those mapped to child devices
698
+ for _ , ep in ipairs (device .endpoints ) do
699
+ if ep .endpoint_id ~= main_endpoint then
700
+ local id = 0
701
+ for _ , dt in ipairs (ep .device_types ) do
702
+ id = math.max (id , dt .device_type_id )
703
+ end
704
+ for _ , attr in pairs (device_type_attribute_map [id ] or {}) do
705
+ if id == GENERIC_SWITCH_ID and
706
+ attr ~= clusters .PowerSource .attributes .BatPercentRemaining and
707
+ attr ~= clusters .PowerSource .attributes .BatChargeLevel then
708
+ device :add_subscribed_event (attr )
709
+ else
710
+ device :add_subscribed_attribute (attr )
711
+ end
716
712
end
717
713
end
718
714
end
715
+ device :subscribe ()
719
716
end
720
- device :subscribe ()
721
717
end
722
718
723
719
local function match_profile (driver , device )
@@ -1308,7 +1304,7 @@ local function info_changed(driver, device, event, args)
1308
1304
if device .profile .id ~= args .old_st_store .profile .id then
1309
1305
device :subscribe ()
1310
1306
local button_eps = device :get_endpoints (clusters .Switch .ID , {feature_bitmap = clusters .Switch .types .SwitchFeature .MOMENTARY_SWITCH })
1311
- if # button_eps > 0 and device .network_type ~= device_lib .NETWORK_TYPE_CHILD then
1307
+ if # button_eps > 0 and device .network_type == device_lib .NETWORK_TYPE_MATTER then
1312
1308
configure_buttons (device )
1313
1309
end
1314
1310
end
0 commit comments