-
Notifications
You must be signed in to change notification settings - Fork 516
Lazy loading test for zigbee switch #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cjswedes
wants to merge
2
commits into
main
Choose a base branch
from
test/zb-switch-memory-reduction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
drivers/SmartThings/zigbee-switch/src/aqara-light/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function(opts, driver, device) | ||
| local FINGERPRINTS = { | ||
| { mfr = "LUMI", model = "lumi.light.acn004" }, | ||
| { mfr = "Aqara", model = "lumi.light.acn014" } | ||
| } | ||
|
|
||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| local subdriver = require("aqara-light") | ||
| return true, subdriver | ||
| end | ||
| end | ||
| return false | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
drivers/SmartThings/zigbee-switch/src/aqara/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function(opts, driver, device) | ||
| local FINGERPRINTS = require("aqara.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| local subdriver = require("aqara") | ||
| return true, subdriver | ||
| end | ||
| end | ||
| return false | ||
| end |
22 changes: 22 additions & 0 deletions
22
drivers/SmartThings/zigbee-switch/src/aqara/fingerprints.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return { | ||
| { mfr = "LUMI", model = "lumi.plug.maeu01" }, | ||
| { mfr = "LUMI", model = "lumi.plug.macn01" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n0agl1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.l0agl1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n0acn2" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n1acn1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n2acn1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n3acn1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b1laus01" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b2laus01" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n1aeu1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n2aeu1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.l1aeu1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.l2aeu1" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b1nacn01" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b2nacn01" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b3n01" } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function(opts, driver, device) | ||
| local FINGERPRINTS = require("aqara.multi-switch.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| return true, require("aqara.multi-switch") | ||
| end | ||
| end | ||
| return false | ||
| end |
14 changes: 14 additions & 0 deletions
14
drivers/SmartThings/zigbee-switch/src/aqara/multi-switch/fingerprints.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return { | ||
| { mfr = "LUMI", model = "lumi.switch.n1acn1", children = 1, child_profile = "" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n2acn1", children = 2, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n3acn1", children = 3, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b1laus01", children = 1, child_profile = "" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b2laus01", children = 2, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.l2aeu1", children = 2, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.n2aeu1", children = 2, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b2nacn01", children = 2, child_profile = "aqara-switch-child" }, | ||
| { mfr = "LUMI", model = "lumi.switch.b3n01", children = 3, child_profile = "aqara-switch-child" } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local lazy_load = require "lazy_load_subdriver" | ||
|
|
||
| return { | ||
| lazy_load("aqara.multi-switch"), | ||
| lazy_load("aqara.version"), | ||
| } |
13 changes: 13 additions & 0 deletions
13
drivers/SmartThings/zigbee-switch/src/aqara/version/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function (opts, driver, device) | ||
| local PRIVATE_MODE = "PRIVATE_MODE" | ||
| local private_mode = device:get_field(PRIVATE_MODE) or 0 | ||
| local res = private_mode == 1 | ||
| if res then | ||
| return res, require("aqara.version") | ||
| else | ||
| return res | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
drivers/SmartThings/zigbee-switch/src/bad_on_off_data_type/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
|
|
||
| -- There are reports of at least one device (SONOFF 01MINIZB) which occasionally | ||
| -- reports this value as an Int8, rather than a Boolean, as per the spec | ||
| return function(opts, driver, device, zb_rx, ...) | ||
| local zcl_clusters = require "st.zigbee.zcl.clusters" | ||
| local data_types = require "st.zigbee.data_types" | ||
| local can_handle = opts.dispatcher_class == "ZigbeeMessageDispatcher" and | ||
| device:get_manufacturer() == "SONOFF" and | ||
| zb_rx.body and | ||
| zb_rx.body.zcl_body and | ||
| zb_rx.body.zcl_body.attr_records and | ||
| zb_rx.address_header.cluster.value == zcl_clusters.OnOff.ID and | ||
| zb_rx.body.zcl_body.attr_records[1].attr_id.value == zcl_clusters.OnOff.attributes.OnOff.ID and | ||
| zb_rx.body.zcl_body.attr_records[1].data_type.value ~= data_types.Boolean.ID | ||
| if can_handle then | ||
| local subdriver = require("bad_on_off_data_type") | ||
| return true, subdriver | ||
| else | ||
| return false | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
drivers/SmartThings/zigbee-switch/src/configurations/devices.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 2 additions & 13 deletions
15
drivers/SmartThings/zigbee-switch/src/configurations/init.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.