Skip to content

Conversation

@cjswedes
Copy link
Contributor

@cjswedes cjswedes commented Oct 15, 2025

We are considering adding a new way to lazy load subdrivers in 0.59.x, and this is what we would want to do to our zigbee switch driver to have it work with that functionality. The improvement is that we avoid requiring the base subdriver entirely to get access to the can handle and any nested subdrivers. So to convert our drivers subdrivers will all need to have a can_handle.lua file and any base driver or subdriver that has subdrivers will need a sub_drivers.lua file.

  • Undo name update from testing

@github-actions
Copy link

github-actions bot commented Oct 15, 2025

Channel deleted.

@github-actions
Copy link

github-actions bot commented Oct 15, 2025

Test Results

   71 files  ±0    464 suites  ±0   0s ⏱️ ±0s
2 411 tests ±0  2 411 ✅ ±0  0 💤 ±0  0 ❌ ±0 
4 094 runs  ±0  4 094 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit d42421a. ± Comparison against base commit 0724305.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 15, 2025

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/ge-link-bulb/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/lazy_load_subdriver.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/preferences.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm32-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/jasco/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/configurations/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/wallhero/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/laisiao/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/tuya-multi/can_handle.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/lifecycle_handlers/device_added.lua 66%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient/init.lua 94%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against d42421a

Copy link
Contributor

Choose a reason for hiding this comment

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

Where's this guy getting used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ope, this is something sitting in my repo that I used with a different test. It isnt being used, but I will remove it.

@greens
Copy link
Contributor

greens commented Oct 15, 2025

Also you'll need to add the copyright disclaimer to all the new lua files.

Base automatically changed from chore/zb-switch-mem-improvements to main October 16, 2025 15:29
@cjswedes
Copy link
Contributor Author

Also you'll need to add the copyright disclaimer to all the new lua files.

Is this something that is definitely required for every single file for our license to apply, or is it just a practice that we have been following. I ask because adding these comments at the top of every file negatively affects memory of our driver processes. When a lua file is run it is loaded into memory and parsed into bytecode which is why comments affect the memory of a lua program. That load step brings in the comment data, which even though is not included in bytecode, it does affect the processes peak memory. We are already stripping out the comments from the lua libs we ship on target (and leaving newlines to preserve line numbers) to mitigate this somewhat for drivers.

If we do need something in every file can we use a condensed version that is only one or 2 lines?

@cjswedes
Copy link
Contributor Author

can we use a condensed version that is only one or 2 lines?

Maybe something like:

-- Copyright 2025 SmartThings. Licensed under the Apache License, Version 2.0:
-- http://www.apache.org/licenses/LICENSE-2.0

@greens
Copy link
Contributor

greens commented Oct 23, 2025

Good questions.

In the meantime luacheck has beef with you.

@cjswedes cjswedes force-pushed the test/zb-switch-memory-reduction branch from 59833ff to df26b2e Compare November 3, 2025 21:35
This is a new feature in api v16 that allows for more memory savings by
more efficiently lazily loading the subdriver. Subdrivers must have
their can_handle function and their own subdrivers split out into
separate modules to work with the new lazy loading api.
This is done to maintain consitency across the whole driver and set an
example for other drivers to follow. The reduced source file comment
should also help with memory savings since comments do affect memory of
a driver when the driver code is being loaded into the Lua runtime.
@cjswedes cjswedes force-pushed the test/zb-switch-memory-reduction branch from 170d8ab to d42421a Compare November 3, 2025 21:55
@cjswedes cjswedes requested a review from greens November 3, 2025 21:56
@cjswedes cjswedes assigned tpmanley and varzac and unassigned tpmanley and varzac Nov 3, 2025
@cjswedes
Copy link
Contributor Author

cjswedes commented Nov 3, 2025

This is ready for a review now. Testing has been done on my home hub (uses about 2 subdrivers), and then unit test coverage provides good coverage; it was relied on heavily during development.

I also updated all the copyright comments in source files to match what we should be doing now as well as added it to the plethora of new files.

@cjswedes cjswedes merged commit cc879b5 into main Nov 6, 2025
11 checks passed
@cjswedes cjswedes deleted the test/zb-switch-memory-reduction branch November 6, 2025 19:05
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.

7 participants