Skip to content

add firstled-io_M4S4BAC#2971

Open
thinkaName wants to merge 1 commit into
SmartThingsCommunity:mainfrom
thinkaName:firstled-io_M4S4BAC
Open

add firstled-io_M4S4BAC#2971
thinkaName wants to merge 1 commit into
SmartThingsCommunity:mainfrom
thinkaName:firstled-io_M4S4BAC

Conversation

@thinkaName
Copy link
Copy Markdown
Contributor

@thinkaName thinkaName commented May 14, 2026

Check all that apply

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Summary of Completed Tests

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Test Results

   73 files    513 suites   0s ⏱️
2 947 tests 2 947 ✅ 0 💤 0 ❌
4 819 runs  4 819 ✅ 0 💤 0 ❌

Results for commit 90c7984.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

File Coverage
All files 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/configurations/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/vzm30-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/color_temp_range_handlers/init.lua 71%
/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/preferences.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/init.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient/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/frient-IO/unbind_request.lua 71%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient-IO/init.lua 88%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/laisiao/init.lua 96%
/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/firstled-io/init.lua 88%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 90c7984

@thinkaName thinkaName force-pushed the firstled-io_M4S4BAC branch 2 times, most recently from d0d3e68 to 09fa419 Compare May 18, 2026 05:48
Copy link
Copy Markdown
Contributor

@cjswedes cjswedes left a comment

Choose a reason for hiding this comment

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

Test failures will need to be resolved prior to merging.

Comment thread drivers/SmartThings/zigbee-switch/src/test/test_firstled_switch.lua Outdated
Comment thread drivers/SmartThings/zigbee-switch/src/firstled-io/init.lua
Comment thread drivers/SmartThings/zigbee-switch/src/firstled-io/init.lua Outdated
{ visibility = { displayed = false } }))

device:send(cluster_base.write_manufacturer_specific_attribute(device,
PRIVATE_CLUSTER_ID, PRIVATE_ATTRIBUTE_ID, MFG_CODE, data_types.Uint8, 0x01)) -- private
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont really know what this attribute write does, but is it something that should be done in device init? The difference being it would be written anytime the hub restarts or the driver is updated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this was moved to infoChanged to handle preference changes. It seems like it might still be needed in the added handler so that the initial preference default value is written.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When the device is entering the pairing process, it will restore the data to the default values, and both ends will have the same default values.

@thinkaName thinkaName force-pushed the firstled-io_M4S4BAC branch 2 times, most recently from 2b92e15 to 29ea878 Compare May 19, 2026 08:58
@nand-nor
Copy link
Copy Markdown
Contributor

Can code coverage be improved in firstled-io/init.lua? Device init tests, preference changes, scenes cluster handling, profile switching, that kind of thing

Comment thread drivers/SmartThings/zigbee-switch/src/firstled-io/init.lua Outdated
@thinkaName thinkaName force-pushed the firstled-io_M4S4BAC branch 5 times, most recently from 541f830 to 59e191b Compare May 21, 2026 09:56
@thinkaName
Copy link
Copy Markdown
Contributor Author

Can code coverage be improved in firstled-io/init.lua? Device init tests, preference changes, scenes cluster handling, profile switching, that kind of thing

The maximum improvement can only reach 88%. What suggestions do you have?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this test file modified? It seems like this device is unrelated to the changes.

@cjswedes
Copy link
Copy Markdown
Contributor

The maximum improvement can only reach 88%. What suggestions do you have?

You can run coverage locally and get the report yourself. When I do it I see that none of the child button behavior is tested.

To run it locally first run your test file with coveraged enabled (note you need luacov installed)

## run test with coverage enabled from zigbee-switch/src
lua -lluacov test/test_firstled_switch.lua
## create the report from the stats output
luacov -c ./luacov.stats.out --config ~/SmartThingsEdgeDrivers/tools/config.luacov

This will create a luacov.report.out with counts next to each line in each file that was required during the lua script. Here is what I was seeing relating to the firstled-io/init.lua file:

       local function get_child_profile_name(device)
*****0   for _, fingerprint in ipairs(FINGERPRINTS) do
*****0     if device:get_model() == fingerprint.model then
*****0       return fingerprint.child_profile
           end
         end
       end

       local function find_child(parent, ep_id)
    23   return parent:get_child_by_parent_assigned_key(string.format("%02X", ep_id))
       end

       local function device_added(driver, device)
         -- Only create children for the actual Zigbee device and not the children
     8   if device.network_type == device_lib.NETWORK_TYPE_ZIGBEE then
     1     local children_amount = get_children_amount(device)
     1     if children_amount >= 2 then
     4       for i = 2, children_amount, 1 do
     3         if find_child(device, i) == nil then
*****0           local name = string.format("%s%d", string.sub(device.label, 0, -2), i)
*****0           local child_profile = get_child_profile_name(device)
*****0           local metadata = {
                   type = "EDGE_CHILD",
                   label = name,
                   profile = child_profile,
                   parent_device_id = device.id,
                   parent_assigned_child_key = string.format("%02X", i),
*****0             vendor_provided_label = name
                 }
*****0           driver:try_create_device(metadata)
               end
             end
           end

         -- Create Button if necessary
     1     local button_amount = get_button_amount(device)
     1     if button_amount >= 1 then
     5       for i = children_amount + 1, children_amount + button_amount, 1 do
     4         if find_child(device, i) == nil then
*****0           local name = string.format("%s%d", string.sub(device.label, 0, -2), i)
*****0           local metadata = {
                   type = "EDGE_CHILD",
                   label = name,
                   profile = "button",
                   parent_device_id = device.id,
                   parent_assigned_child_key = string.format("%02X", i),
                   vendor_provided_label = name,
                 }
*****0           driver:try_create_device(metadata)
               end
             end
           end

@thinkaName thinkaName force-pushed the firstled-io_M4S4BAC branch 4 times, most recently from ab102dd to 927cc97 Compare May 22, 2026 08:31
@thinkaName thinkaName force-pushed the firstled-io_M4S4BAC branch from 927cc97 to 90c7984 Compare May 22, 2026 10:01
Comment on lines +107 to +118
for i = children_amount + 1, children_amount + button_amount, 1 do
if find_child(device, i) == nil then
local name = string.format("%s%d", string.sub(device.label, 0, -2), i)
local metadata = {
type = "EDGE_CHILD",
label = name,
profile = "button",
parent_device_id = device.id,
parent_assigned_child_key = string.format("%02X", i),
vendor_provided_label = name,
}
driver:try_create_device(metadata)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please add tests that test this part of device added.

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