-
Notifications
You must be signed in to change notification settings - Fork 517
zb-motion: Lazy loading of can handle and scripting testing ground #2551
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| local is_aqara_products = 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 | ||
| return true, require("aqara") | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return is_aqara_products |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local FINGERPRINTS = { | ||
| { mfr = "LUMI", model = "lumi.motion.ac02" }, | ||
| { mfr = "LUMI", model = "lumi.motion.agl02" }, | ||
| { mfr = "LUMI", model = "lumi.motion.agl04" } | ||
| } | ||
|
|
||
| return FINGERPRINTS |
| 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 | ||
|
|
||
| return function(opts, driver, device, ...) | ||
| if device:get_model() == "lumi.motion.agl04" then | ||
| return true, require("aqara.high-precision-motion") | ||
| end | ||
| return false | ||
| end |
| 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.high-precision-motion") | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function aurora_can_handle(opts, driver, device, ...) | ||
| if device:get_manufacturer() == "Aurora" and device:get_model() == "MotionSensor51AU" then | ||
| return true, require("aurora") | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return aurora_can_handle |
| 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 | ||
|
|
||
| local can_handle_battery_voltage = function(opts, driver, device, ...) | ||
| local FINGERPRINTS = require("battery-voltage.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| return true, require("battery-voltage") | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return can_handle_battery_voltage |
| 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 | ||
|
|
||
| local DEVICES_REPORTING_BATTERY_VOLTAGE = { | ||
| { mfr = "Bosch", model = "RFPR-ZB" }, | ||
| { mfr = "Bosch", model = "RFDL-ZB-MS" }, | ||
| { mfr = "Ecolink", model = "PIRZB1-ECO" }, | ||
| { mfr = "ADUROLIGHT", model = "VMS_ADUROLIGHT" }, | ||
| { mfr = "AduroSmart Eria", model = "VMS_ADUROLIGHT" } | ||
| } | ||
|
|
||
| return DEVICES_REPORTING_BATTERY_VOLTAGE | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: newline at end of file |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function centralite_can_handle(opts, driver, device, ...) | ||
| if device:get_manufacturer() == "CentraLite" then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation |
||
| return true, require("centralite") | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return centralite_can_handle | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function compacta_can_handle(opts, driver, device, ...) | ||
| if device:get_manufacturer() == "Compacta" then | ||
| return true, require("compacta") | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return compacta_can_handle |
| 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 | ||
|
|
||
| local function can_handle_frient_motion_sensor(opts, driver, device) | ||
| local FINGERPRINTS = require("frient.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| return true, require("frient") | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return can_handle_frient_motion_sensor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local FRIENT_DEVICE_FINGERPRINTS = { | ||
| { mfr = "frient A/S", model = "MOSZB-140"}, | ||
| { mfr = "frient A/S", model = "MOSZB-141"}, | ||
| { mfr = "frient A/S", model = "MOSZB-153"} | ||
| } | ||
|
|
||
| return FRIENT_DEVICE_FINGERPRINTS |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function gatorsystem_can_handle(opts, driver, device, ...) | ||
| if device:get_manufacturer() == "GatorSystem" and device:get_model() == "GSHW01" then | ||
| return true, require("gatorsystem") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: indentation |
||
| end | ||
| return false | ||
| end | ||
|
|
||
| return gatorsystem_can_handle | ||
| 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 | ||
|
|
||
| local is_ikea_motion = function(opts, driver, device) | ||
| local FINGERPRINTS = require("ikea.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| return true, require("ikea") | ||
| end | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return is_ikea_motion |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local IKEA_MOTION_SENSOR_FINGERPRINTS = { | ||
| { mfr = "IKEA of Sweden", model = "TRADFRI motion sensor" } | ||
| } | ||
|
|
||
| return IKEA_MOTION_SENSOR_FINGERPRINTS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra newline