From f89ad93d9518fff574d4dd5d8c3151620d50a6c1 Mon Sep 17 00:00:00 2001 From: Alec Lorimer Date: Tue, 16 Dec 2025 09:35:21 -0600 Subject: [PATCH] CHAD-17161: lazy loading of matter-sensor sub-drivers --- .../PressureMeasurement/init.lua | 17 +++-------------- .../server/attributes/AcceptedCommandList.lua | 17 +++-------------- .../server/attributes/AttributeList.lua | 17 +++-------------- .../server/attributes/EventList.lua | 17 +++-------------- .../server/attributes/MaxMeasuredValue.lua | 17 +++-------------- .../server/attributes/MaxScaledValue.lua | 17 +++-------------- .../server/attributes/MeasuredValue.lua | 17 +++-------------- .../server/attributes/MinMeasuredValue.lua | 17 +++-------------- .../server/attributes/MinScaledValue.lua | 17 +++-------------- .../server/attributes/Scale.lua | 17 +++-------------- .../server/attributes/ScaledTolerance.lua | 17 +++-------------- .../server/attributes/ScaledValue.lua | 17 +++-------------- .../server/attributes/Tolerance.lua | 17 +++-------------- .../server/attributes/init.lua | 17 +++-------------- .../server/commands/init.lua | 17 +++-------------- .../PressureMeasurement/server/events/init.lua | 17 +++-------------- .../PressureMeasurement/types/Feature.lua | 17 +++-------------- .../PressureMeasurement/types/init.lua | 17 +++-------------- drivers/SmartThings/matter-sensor/src/init.lua | 8 ++------ .../matter-sensor/src/lazy_load_subdriver.lua | 14 ++++++++++++++ .../matter-sensor/src/sub_drivers.lua | 10 ++++++++++ .../air_quality_sensor_utils/utils.lua | 14 +------------- .../air_quality_sensor/can_handle.lua | 17 +++++++++++++++++ .../sub_drivers/air_quality_sensor/init.lua | 4 ++-- .../bosch_button_contact/can_handle.lua | 16 ++++++++++++++++ .../sub_drivers/bosch_button_contact/init.lua | 17 ++--------------- .../sub_drivers/smoke_co_alarm/can_handle.lua | 17 +++++++++++++++++ .../src/sub_drivers/smoke_co_alarm/init.lua | 18 +++--------------- 28 files changed, 138 insertions(+), 303 deletions(-) create mode 100644 drivers/SmartThings/matter-sensor/src/lazy_load_subdriver.lua create mode 100644 drivers/SmartThings/matter-sensor/src/sub_drivers.lua create mode 100644 drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/can_handle.lua create mode 100644 drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/can_handle.lua create mode 100644 drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/can_handle.lua diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/init.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/init.lua index 8b1661152a..42b058eb02 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/init.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/init.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -141,4 +131,3 @@ setmetatable(PressureMeasurement.events, event_helper_mt) setmetatable(PressureMeasurement, {__index = cluster_base}) return PressureMeasurement - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AcceptedCommandList.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AcceptedCommandList.lua index ee9fad2526..dc301eba35 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AcceptedCommandList.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AcceptedCommandList.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -123,4 +113,3 @@ end setmetatable(AcceptedCommandList, {__call = AcceptedCommandList.new_value, __index = AcceptedCommandList.base_type}) return AcceptedCommandList - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AttributeList.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AttributeList.lua index d4d85b00a0..deba9d030f 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AttributeList.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/AttributeList.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -123,4 +113,3 @@ end setmetatable(AttributeList, {__call = AttributeList.new_value, __index = AttributeList.base_type}) return AttributeList - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/EventList.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/EventList.lua index b3dc7bf94c..f6040a17a0 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/EventList.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/EventList.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -123,4 +113,3 @@ end setmetatable(EventList, {__call = EventList.new_value, __index = EventList.base_type}) return EventList - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxMeasuredValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxMeasuredValue.lua index 2484d99ef3..7bbf34d9e5 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxMeasuredValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxMeasuredValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(MaxMeasuredValue, {__call = MaxMeasuredValue.new_value, __index = MaxMeasuredValue.base_type}) return MaxMeasuredValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxScaledValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxScaledValue.lua index 56fe3132f9..91e5f4edc4 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxScaledValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MaxScaledValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(MaxScaledValue, {__call = MaxScaledValue.new_value, __index = MaxScaledValue.base_type}) return MaxScaledValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MeasuredValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MeasuredValue.lua index 7d850f1a7c..b7c0484722 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MeasuredValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MeasuredValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(MeasuredValue, {__call = MeasuredValue.new_value, __index = MeasuredValue.base_type}) return MeasuredValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinMeasuredValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinMeasuredValue.lua index 35ec62854f..ed4e421c77 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinMeasuredValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinMeasuredValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(MinMeasuredValue, {__call = MinMeasuredValue.new_value, __index = MinMeasuredValue.base_type}) return MinMeasuredValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinScaledValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinScaledValue.lua index 97bb0d44df..552ae6160a 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinScaledValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/MinScaledValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(MinScaledValue, {__call = MinScaledValue.new_value, __index = MinScaledValue.base_type}) return MinScaledValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Scale.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Scale.lua index 5533e4e486..085153bd7a 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Scale.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Scale.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(Scale, {__call = Scale.new_value, __index = Scale.base_type}) return Scale - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledTolerance.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledTolerance.lua index d00d2a4195..4c14d72ea3 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledTolerance.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledTolerance.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(ScaledTolerance, {__call = ScaledTolerance.new_value, __index = ScaledTolerance.base_type}) return ScaledTolerance - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledValue.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledValue.lua index f2e513477b..28cfe27a7a 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledValue.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/ScaledValue.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(ScaledValue, {__call = ScaledValue.new_value, __index = ScaledValue.base_type}) return ScaledValue - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Tolerance.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Tolerance.lua index 55a39514a3..4d1b45ee48 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Tolerance.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/Tolerance.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -113,4 +103,3 @@ end setmetatable(Tolerance, {__call = Tolerance.new_value, __index = Tolerance.base_type}) return Tolerance - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/init.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/init.lua index 51844f7b7f..ebd4480609 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/init.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/attributes/init.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -51,4 +41,3 @@ end setmetatable(PressureMeasurementServerAttributes, attr_mt) return PressureMeasurementServerAttributes - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/commands/init.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/commands/init.lua index 94f1c0849a..db5c3d9d45 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/commands/init.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/commands/init.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -38,4 +28,3 @@ end setmetatable(PressureMeasurementServerCommands, command_mt) return PressureMeasurementServerCommands - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/events/init.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/events/init.lua index fa444e129a..d96e0d7438 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/events/init.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/server/events/init.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -39,4 +29,3 @@ end setmetatable(PressureMeasurementEvents, event_mt) return PressureMeasurementEvents - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/Feature.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/Feature.lua index 5f5f070b7d..814c5ef226 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/Feature.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/Feature.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -78,4 +68,3 @@ end setmetatable(Feature, new_mt) return Feature - diff --git a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/init.lua b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/init.lua index f83681fdb8..4f0c8b6bdc 100644 --- a/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/init.lua +++ b/drivers/SmartThings/matter-sensor/src/embedded_clusters/PressureMeasurement/types/init.lua @@ -1,16 +1,6 @@ --- Copyright 2022 SmartThings --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. +-- Copyright 2022 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + -- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. @@ -32,4 +22,3 @@ local PressureMeasurementTypes = {} setmetatable(PressureMeasurementTypes, types_mt) return PressureMeasurementTypes - diff --git a/drivers/SmartThings/matter-sensor/src/init.lua b/drivers/SmartThings/matter-sensor/src/init.lua index 4f6b204aea..73e34fcd56 100644 --- a/drivers/SmartThings/matter-sensor/src/init.lua +++ b/drivers/SmartThings/matter-sensor/src/init.lua @@ -1,4 +1,4 @@ --- Copyright © 2025 SmartThings, Inc. +-- Copyright 2025 SmartThings, Inc. -- Licensed under the Apache License, Version 2.0 local capabilities = require "st.capabilities" @@ -295,11 +295,7 @@ local matter_driver_template = { capabilities.hardwareFault, capabilities.flowMeasurement, }, - sub_drivers = { - require("sub_drivers.air_quality_sensor"), - require("sub_drivers.smoke_co_alarm"), - require("sub_drivers.bosch_button_contact") - } + sub_drivers = require("sub_drivers"), } local matter_driver = MatterDriver("matter-sensor", matter_driver_template) diff --git a/drivers/SmartThings/matter-sensor/src/lazy_load_subdriver.lua b/drivers/SmartThings/matter-sensor/src/lazy_load_subdriver.lua new file mode 100644 index 0000000000..a04740d267 --- /dev/null +++ b/drivers/SmartThings/matter-sensor/src/lazy_load_subdriver.lua @@ -0,0 +1,14 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +return function(sub_driver_name) + local MatterDriver = require "st.matter.driver" + local version = require "version" + if version.api >= 16 then + return MatterDriver.lazy_load_sub_driver_v2(sub_driver_name) + elseif version.api >= 9 then + return MatterDriver.lazy_load_sub_driver(require(sub_driver_name)) + else + return require(sub_driver_name) + end +end diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers.lua new file mode 100644 index 0000000000..3bf4c46f73 --- /dev/null +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers.lua @@ -0,0 +1,10 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +local lazy_load_if_possible = require "lazy_load_subdriver" +local sub_drivers = { + lazy_load_if_possible("sub_drivers.air_quality_sensor"), + lazy_load_if_possible("sub_drivers.smoke_co_alarm"), + lazy_load_if_possible("sub_drivers.bosch_button_contact"), +} +return sub_drivers diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/utils.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/utils.lua index 2462ced55d..1a36f5f920 100644 --- a/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/utils.lua +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/air_quality_sensor_utils/utils.lua @@ -1,4 +1,4 @@ --- Copyright © 2025 SmartThings, Inc. +-- Copyright 2025 SmartThings, Inc. -- Licensed under the Apache License, Version 2.0 local capabilities = require "st.capabilities" @@ -9,18 +9,6 @@ local fields = require "sub_drivers.air_quality_sensor.air_quality_sensor_utils. local AirQualitySensorUtils = {} -function AirQualitySensorUtils.is_matter_air_quality_sensor(opts, driver, device) - for _, ep in ipairs(device.endpoints) do - for _, dt in ipairs(ep.device_types) do - if dt.device_type_id == fields.AIR_QUALITY_SENSOR_DEVICE_TYPE_ID then - return true - end - end - end - - return false - end - function AirQualitySensorUtils.supports_capability_by_id_modular(device, capability, component) if not device:get_field(fields.SUPPORTED_COMPONENT_CAPABILITIES) then device.log.warn_with({hub_logs = true}, "Device has overriden supports_capability_by_id, but does not have supported capabilities set.") diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/can_handle.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/can_handle.lua new file mode 100644 index 0000000000..9c1a1ab762 --- /dev/null +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/can_handle.lua @@ -0,0 +1,17 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +local function is_matter_air_quality_sensor(opts, driver, device) + local fields = require "sub_drivers.air_quality_sensor.air_quality_sensor_utils.fields" + for _, ep in ipairs(device.endpoints) do + for _, dt in ipairs(ep.device_types) do + if dt.device_type_id == fields.AIR_QUALITY_SENSOR_DEVICE_TYPE_ID then + return true, require("sub_drivers.air_quality_sensor") + end + end + end + + return false +end + +return is_matter_air_quality_sensor diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/init.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/init.lua index a0427ac665..61280fd107 100644 --- a/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/init.lua +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/air_quality_sensor/init.lua @@ -1,4 +1,4 @@ --- Copyright © 2025 SmartThings, Inc. +-- Copyright 2025 SmartThings, Inc. -- Licensed under the Apache License, Version 2.0 local version = require "version" @@ -148,7 +148,7 @@ local matter_air_quality_sensor_handler = { } } }, - can_handle = aqs_utils.is_matter_air_quality_sensor + can_handle = require("sub_drivers.air_quality_sensor.can_handle") } return matter_air_quality_sensor_handler diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/can_handle.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/can_handle.lua new file mode 100644 index 0000000000..9c679f3607 --- /dev/null +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/can_handle.lua @@ -0,0 +1,16 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +local function is_bosch_button_contact(opts, driver, device) + local device_lib = require "st.device" + local BOSCH_VENDOR_ID = 0x1209 + local BOSCH_PRODUCT_ID = 0x3015 + if device.network_type == device_lib.NETWORK_TYPE_MATTER and + device.manufacturer_info.vendor_id == BOSCH_VENDOR_ID and + device.manufacturer_info.product_id == BOSCH_PRODUCT_ID then + return true, require("sub_drivers.bosch_button_contact") + end + return false +end + +return is_bosch_button_contact diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/init.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/init.lua index 9b4635d87c..cbbd71cf53 100644 --- a/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/init.lua +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/bosch_button_contact/init.lua @@ -1,26 +1,13 @@ --- Copyright © 2025 SmartThings, Inc. +-- Copyright 2025 SmartThings, Inc. -- Licensed under the Apache License, Version 2.0 local capabilities = require "st.capabilities" local clusters = require "st.matter.clusters" -local device_lib = require "st.device" local lua_socket = require "socket" local log = require "log" local START_BUTTON_PRESS = "__start_button_press" -local BOSCH_VENDOR_ID = 0x1209 -local BOSCH_PRODUCT_ID = 0x3015 - -local function is_bosch_button_contact(opts, driver, device) - if device.network_type == device_lib.NETWORK_TYPE_MATTER and - device.manufacturer_info.vendor_id == BOSCH_VENDOR_ID and - device.manufacturer_info.product_id == BOSCH_PRODUCT_ID then - return true - end - return false -end - local function get_field_for_endpoint(device, field, endpoint) return device:get_field(string.format("%s_%d", field, endpoint)) end @@ -145,7 +132,7 @@ local Bosch_Button_Contact_Sensor = { } }, }, - can_handle = is_bosch_button_contact, + can_handle = require("sub_drivers.bosch_button_contact.can_handle"), } return Bosch_Button_Contact_Sensor diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/can_handle.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/can_handle.lua new file mode 100644 index 0000000000..31bd7e025b --- /dev/null +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/can_handle.lua @@ -0,0 +1,17 @@ +-- Copyright 2025 SmartThings, Inc. +-- Licensed under the Apache License, Version 2.0 + +local function is_matter_smoke_co_alarm(opts, driver, device) + local SMOKE_CO_ALARM_DEVICE_TYPE_ID = 0x0076 + for _, ep in ipairs(device.endpoints) do + for _, dt in ipairs(ep.device_types) do + if dt.device_type_id == SMOKE_CO_ALARM_DEVICE_TYPE_ID then + return true, require("sub_drivers.smoke_co_alarm") + end + end + end + + return false +end + +return is_matter_smoke_co_alarm diff --git a/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/init.lua b/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/init.lua index 374bbd5ad9..8f8653b936 100644 --- a/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/init.lua +++ b/drivers/SmartThings/matter-sensor/src/sub_drivers/smoke_co_alarm/init.lua @@ -1,4 +1,4 @@ --- Copyright © 2025 SmartThings, Inc. +-- Copyright 2025 SmartThings, Inc. -- Licensed under the Apache License, Version 2.0 local capabilities = require "st.capabilities" @@ -19,23 +19,11 @@ end local smoke_co_alarm_utils = {} local CARBON_MONOXIDE_MEASUREMENT_UNIT = "CarbonMonoxideConcentrationMeasurement_unit" -local SMOKE_CO_ALARM_DEVICE_TYPE_ID = 0x0076 local HardwareFaultAlert = "__HardwareFaultAlert" local BatteryAlert = "__BatteryAlert" local BatteryLevel = "__BatteryLevel" -function smoke_co_alarm_utils.is_matter_smoke_co_alarm(opts, driver, device) - for _, ep in ipairs(device.endpoints) do - for _, dt in ipairs(ep.device_types) do - if dt.device_type_id == SMOKE_CO_ALARM_DEVICE_TYPE_ID then - return true - end - end - end - - return false -end local supported_profiles = { @@ -271,7 +259,7 @@ local matter_smoke_co_alarm_handler = { }, }, }, - can_handle = smoke_co_alarm_utils.is_matter_smoke_co_alarm + can_handle = require("sub_drivers.smoke_co_alarm.can_handle") } -return matter_smoke_co_alarm_handler \ No newline at end of file +return matter_smoke_co_alarm_handler