Skip to content

Commit c5a2410

Browse files
authored
Merge pull request #2899 from SmartThingsCommunity/add/nil-safety-handling
2 parents c93c379 + a883224 commit c5a2410

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/SmartThings/matter-switch/src/switch_handlers/attribute_handlers.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ function AttributeHandlers.available_endpoints_handler(driver, device, ib, respo
321321
return
322322
end
323323
local set_topology_eps = device:get_field(fields.ELECTRICAL_SENSOR_EPS)
324+
if set_topology_eps == nil then
325+
device.log.warn("Received an AvailableEndpoints response but no Electrical Sensor endpoints have been identified as supporting the Power Topology cluster with SET feature. Ignoring this response.")
326+
return
327+
end
324328
for i, set_ep_info in pairs(set_topology_eps or {}) do
325329
if ib.endpoint_id == set_ep_info.endpoint_id then
326330
-- since EP response is being handled here, remove it from the ELECTRICAL_SENSOR_EPS table
@@ -350,6 +354,10 @@ function AttributeHandlers.parts_list_handler(driver, device, ib, response)
350354
return
351355
end
352356
local tree_topology_eps = device:get_field(fields.ELECTRICAL_SENSOR_EPS)
357+
if tree_topology_eps == nil then
358+
device.log.warn("Received a PartsList response but no Electrical Sensor endpoints have been identified as supporting the Power Topology cluster with TREE feature. Ignoring this response.")
359+
return
360+
end
353361
for i, tree_ep_info in pairs(tree_topology_eps or {}) do
354362
if ib.endpoint_id == tree_ep_info.endpoint_id then
355363
-- since EP response is being handled here, remove it from the ELECTRICAL_SENSOR_EPS table

0 commit comments

Comments
 (0)