Skip to content

Conversation

@hcarter-775
Copy link
Contributor

@hcarter-775 hcarter-775 commented Nov 17, 2025

Description of Change

This cuts down the amount of checks and reformatting handled in the endpoint_to_component and emit_event_for_endpoint functions.

This logic was just added by me in the recent Camera PR and it was a bit rushed. This cleans up some unnecessary logic that was introduced.

Summary of Completed Tests

Tested by Unit Test. Expanded functionality is currently only utilized by unreleased Camera subdriver

@github-actions
Copy link

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

Test Results

   71 files  ±0    469 suites  +1   0s ⏱️ ±0s
2 457 tests +2  2 457 ✅ +2  0 💤 ±0  0 ❌ ±0 
4 177 runs  +9  4 177 ✅ +9  0 💤 ±0  0 ❌ ±0 

Results for commit 574fd58. ± Comparison against base commit 9fa6434.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Nov 17, 2025

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/attribute_handlers.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/capability_handlers.lua 78%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/embedded_cluster_utils.lua 38%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/utils.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/fields.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/utils.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/capability_handlers.lua 88%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/attribute_handlers.lua 83%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/event_handlers.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/eve_energy/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_mk1/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/aqara_cube/init.lua 96%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 574fd58

Comment on lines 205 to 209
local formatted_info = {}
if type(ep_info) == "number" then
ep_info = { endpoint_id = ep_info }
formatted_info = { endpoint_id = ep_info }
elseif type(ep_info) == "table" then
ep_info = {
endpoint_id = ep_info.endpoint_id,
cluster_id = ep_info.cluster_id,
attribute_id = ep_info.attribute_id
}
formatted_info = ep_info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively, can't this just be

  if type(ep_info) == "number" then
    ep_info = { endpoint_id = ep_info }
  end

? There isn't any transform done to the table form, and other types are not transformed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it can. I just thought that might be weird/wrong cause the capability event id is going to get appended later and that's not technically "ep info"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I suppose it's kinda equally weird to break it apart like I did, so I'll switch it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ended up removing capabilities from the mapping, so this makes even more sense now

--- to route events to.
---
--- @param device any a Matter device object
--- @param ep_info number|table endpoint_id or ib (includes endpoint_id, cluster_id, attribute_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are cluster_id and attribute_id required when in table form? Is capability_id required as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, they are at the time but I suppose don't need to be. changed the wording in the upcoming commit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it actually reads endpoint_id or ib, and I note that the ib includes that data. I agree this wording is a little confused

--- single endpoint.
---
--- @param device any a Matter device object
--- @param opts number|table either is an ep_id or a table { endpoint_id, capability_id }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doc should include mention of the required fields of cluster_id and attribute_id when in table form.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 186 to 187
and (not map_info.cluster_id or (map_info.cluster_id == opts.cluster_id
and utils.tbl_contains(map_info.attribute_ids, opts.attribute_id)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the logic that existence of the cluster_id field implies the existence of a non-nil attribute_id. Is this always the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is at the time (and I can't see when/why it wouldn't be), though I can see how it can seem a little arbitrary. fixed in next commit (cannot push now due to github outage)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

end
local opts = { endpoint_info = ep_info, capability_id = event.capability.ID }
local comp_id = utils.endpoint_to_component(device, opts)
formatted_info.capability_ID = event.capability.ID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
formatted_info.capability_ID = event.capability.ID
formatted_info.capability_id = event.capability.ID

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants