From a58f397ed0759dbbe1ac4347201f53ae0c64eb94 Mon Sep 17 00:00:00 2001 From: Cooper Towns Date: Wed, 31 Jan 2024 18:14:23 -0600 Subject: [PATCH] Matter Button: specifically check for battery in power source --- drivers/SmartThings/matter-button/src/init.lua | 2 +- .../SmartThings/matter-button/src/test/test_matter_button.lua | 2 +- .../matter-button/src/test/test_matter_button_parent_child.lua | 2 +- .../matter-button/src/test/test_matter_multi_button.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/SmartThings/matter-button/src/init.lua b/drivers/SmartThings/matter-button/src/init.lua index d78812807d..88379c765c 100644 --- a/drivers/SmartThings/matter-button/src/init.lua +++ b/drivers/SmartThings/matter-button/src/init.lua @@ -174,7 +174,7 @@ local function device_added(driver, device) local battery_support = false if device.manufacturer_info.vendor_id ~= HUE_MANUFACTURER_ID and - #device:get_endpoints(clusters.PowerSource.ID) > 0 then + #device:get_endpoints(clusters.PowerSource.ID, {feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY}) > 0 then battery_support = true end diff --git a/drivers/SmartThings/matter-button/src/test/test_matter_button.lua b/drivers/SmartThings/matter-button/src/test/test_matter_button.lua index 2eb5b26489..c18daeab98 100644 --- a/drivers/SmartThings/matter-button/src/test/test_matter_button.lua +++ b/drivers/SmartThings/matter-button/src/test/test_matter_button.lua @@ -19,7 +19,7 @@ local mock_device = test.mock_device.build_test_matter_device( feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH, cluster_type = "SERVER" }, - {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"} + {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY} }, }, }, diff --git a/drivers/SmartThings/matter-button/src/test/test_matter_button_parent_child.lua b/drivers/SmartThings/matter-button/src/test/test_matter_button_parent_child.lua index 31f9ba902f..83a8195090 100644 --- a/drivers/SmartThings/matter-button/src/test/test_matter_button_parent_child.lua +++ b/drivers/SmartThings/matter-button/src/test/test_matter_button_parent_child.lua @@ -22,7 +22,7 @@ local mock_device = test.mock_device.build_test_matter_device( feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH, cluster_type = "SERVER" }, - {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"} + {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY} }, }, { diff --git a/drivers/SmartThings/matter-button/src/test/test_matter_multi_button.lua b/drivers/SmartThings/matter-button/src/test/test_matter_multi_button.lua index 96100108bd..42d97c109d 100644 --- a/drivers/SmartThings/matter-button/src/test/test_matter_multi_button.lua +++ b/drivers/SmartThings/matter-button/src/test/test_matter_multi_button.lua @@ -25,7 +25,7 @@ local mock_device = test.mock_device.build_test_matter_device( feature_map = clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH, cluster_type = "SERVER" }, - {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER"} + {cluster_id = clusters.PowerSource.ID, cluster_type = "SERVER", feature_map = clusters.PowerSource.types.PowerSourceFeature.BATTERY} }, }, {