Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/ezex/can_handle.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local is_ezex_power_meter = function(opts, driver, device)
local FINGERPRINTS = require("ezex.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true, require("ezex")
end
end

return false
end

return is_ezex_power_meter
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 ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "E240-KR080Z0-HA" }
}

return ZIGBEE_POWER_METER_FINGERPRINTS
30 changes: 4 additions & 26 deletions drivers/SmartThings/zigbee-power-meter/src/ezex/init.lua
Original file line number Diff line number Diff line change
@@ -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 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
local constants = require "st.zigbee.constants"
Expand All @@ -20,19 +10,7 @@ local ElectricalMeasurement = clusters.ElectricalMeasurement
local energy_meter_defaults = require "st.zigbee.defaults.energyMeter_defaults"
local configurations = require "configurations"

local ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "E240-KR080Z0-HA" }
}

local is_ezex_power_meter = function(opts, driver, device)
for _, fingerprint in ipairs(ZIGBEE_POWER_METER_FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true
end
end

return false
end

local instantaneous_demand_configuration = {
cluster = SimpleMetering.ID,
Expand Down Expand Up @@ -88,7 +66,7 @@ local ezex_power_meter_handler = {
init = configurations.power_reconfig_wrapper(device_init),
doConfigure = do_configure,
},
can_handle = is_ezex_power_meter
can_handle = require("ezex.can_handle"),
}

return ezex_power_meter_handler
15 changes: 15 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/frient/can_handle.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local is_frient_power_meter = function(opts, driver, device)
local FINGERPRINTS = require("frient.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true, require("frient")
end
end

return false
end

return is_frient_power_meter
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 ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "ZHEMI101" },
{ model = "EMIZB-132" },
}

return ZIGBEE_POWER_METER_FINGERPRINTS
31 changes: 4 additions & 27 deletions drivers/SmartThings/zigbee-power-meter/src/frient/init.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
-- 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 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local constants = require "st.zigbee.constants"
local configurations = require "configurations"

local ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "ZHEMI101" },
{ model = "EMIZB-132" },
}

local is_frient_power_meter = function(opts, driver, device)
for _, fingerprint in ipairs(ZIGBEE_POWER_METER_FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true
end
end

return false
end

local do_configure = function(self, device)
device:refresh()
Expand All @@ -46,7 +23,7 @@ local frient_power_meter_handler = {
init = configurations.power_reconfig_wrapper(device_init),
doConfigure = do_configure,
},
can_handle = is_frient_power_meter
can_handle = require("frient.can_handle"),
}

return frient_power_meter_handler
22 changes: 4 additions & 18 deletions drivers/SmartThings/zigbee-power-meter/src/init.lua
Original file line number Diff line number Diff line change
@@ -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 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
local ZigbeeDriver = require "st.zigbee"
Expand Down Expand Up @@ -63,11 +53,7 @@ local zigbee_power_meter_driver_template = {
}
},
current_config_version = 1,
sub_drivers = {
require("ezex"),
require("frient"),
require("shinasystems"),
},
sub_drivers = require("sub_drivers"),
lifecycle_handlers = {
init = configurations.power_reconfig_wrapper(device_init),
doConfigure = do_configure,
Expand Down
15 changes: 15 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/lazy_load_subdriver.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

return function(sub_driver_name)
-- gets the current lua libs api version
local version = require "version"
local ZigbeeDriver = require "st.zigbee"
if version.api >= 16 then
return ZigbeeDriver.lazy_load_sub_driver_v2(sub_driver_name)
elseif version.api >= 9 then
return ZigbeeDriver.lazy_load_sub_driver(require(sub_driver_name))
else
return require(sub_driver_name)
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local is_shinasystems_power_meter = function(opts, driver, device)
local FINGERPRINTS = require("shinasystems.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true, require("shinasystems")
end
end

return false
end

return is_shinasystems_power_meter
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 ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "PMM-300Z1" },
{ model = "PMM-300Z2" },
{ model = "PMM-300Z3" }
}

return ZIGBEE_POWER_METER_FINGERPRINTS
32 changes: 4 additions & 28 deletions drivers/SmartThings/zigbee-power-meter/src/shinasystems/init.lua
Original file line number Diff line number Diff line change
@@ -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 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0


local capabilities = require "st.capabilities"
local constants = require "st.zigbee.constants"
Expand All @@ -19,11 +9,6 @@ local SimpleMetering = clusters.SimpleMetering
local ElectricalMeasurement = clusters.ElectricalMeasurement
local configurations = require "configurations"

local ZIGBEE_POWER_METER_FINGERPRINTS = {
{ model = "PMM-300Z1" },
{ model = "PMM-300Z2" },
{ model = "PMM-300Z3" }
}

local POWERMETER_CONFIGURATION_V2 = {
{
Expand Down Expand Up @@ -52,15 +37,6 @@ local POWERMETER_CONFIGURATION_V2 = {
}
}

local is_shinasystems_power_meter = function(opts, driver, device)
for _, fingerprint in ipairs(ZIGBEE_POWER_METER_FINGERPRINTS) do
if device:get_model() == fingerprint.model then
return true
end
end

return false
end

local function energy_meter_handler(driver, device, value, zb_rx)
local multiplier = device:get_field(constants.SIMPLE_METERING_MULTIPLIER_KEY) or 1
Expand Down Expand Up @@ -128,7 +104,7 @@ local shinasystems_power_meter_handler = {
init = configurations.power_reconfig_wrapper(device_init),
doConfigure = do_configure,
},
can_handle = is_shinasystems_power_meter
can_handle = require("shinasystems.can_handle"),
}

return shinasystems_power_meter_handler
10 changes: 10 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/sub_drivers.lua
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 lazy_load_if_possible = require "lazy_load_subdriver"
local sub_drivers = {
lazy_load_if_possible("ezex"),
lazy_load_if_possible("frient"),
lazy_load_if_possible("shinasystems"),
}
return sub_drivers
Loading