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
2 changes: 1 addition & 1 deletion .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

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

changes to this file should be omitted

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ lua_libs-api_*
tools/test_output/*
tools/coverage_output/*
.DS_Store
.venv/
.venv/
7 changes: 6 additions & 1 deletion drivers/SmartThings/zigbee-power-meter/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ zigbeeManufacturer:
manufacturer: ShinaSystem
model: "PMM-300Z3"
deviceProfileName: power-meter-consumption-report-sihas
- id: Chameleon/CT101xxxx
deviceLabel: Chameleon CT Clamp
manufacturer: Chameleon Technology
model: CT101xxxx
deviceProfileName: power-energy-battery-temperature
zigbeeGeneric:
- id: "genericMeter"
deviceLabel: Zigbee Meter
clusters:
server:
- 0x0702 #Simple Metering
deviceProfileName: power-meter
deviceProfileName: power-meter
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: power-energy-battery-temperature
components:
- id: main
capabilities:
- id: powerMeter
version: 1
- id: energyMeter
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
- id: battery
version: 1
- id: temperatureMeasurement
version: 1
categories:
- name: CurbPowerMeter

104 changes: 104 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/chameleon/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
-- Copyright 2025 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.

local clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"
local log = require "log"

local TemperatureMeasurement = clusters.DeviceTemperatureConfiguration
local PowerConfiguration = clusters.PowerConfiguration

local ZIGBEE_FINGERPRINT = {
{model = "CT101xxxx" }
}

local configuration = {
{
cluster = TemperatureMeasurement.ID,
attribute = TemperatureMeasurement.attributes.CurrentTemperature.ID,
minimum_interval = 30,
maximum_interval = 3600,
data_type = TemperatureMeasurement.attributes.CurrentTemperature.base_type,
reportable_change = 1
},
{
cluster = PowerConfiguration.ID,
attribute = PowerConfiguration.attributes.BatteryPercentageRemaining.ID,
minimum_interval = 30,
maximum_interval = 3600,
data_type = PowerConfiguration.attributes.BatteryPercentageRemaining.base_type,
reportable_change = 2
}
}

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

local function battery_level_handler(driver, device, value, _zb_rx)
if type(value.value) == "number" then
local number = value.value/2
local integer_result = math.floor(number)
device:emit_event(capabilities.battery.battery(integer_result))
else
log.error("Invalid battery level value received: " .. tostring(value.value))
end
end

local function temperature_handler(driver, device, value, _zb_rx)
if type(value.value) == "number" then
device:emit_event(capabilities.temperatureMeasurement.temperature({ value = value.value, unit = "C" }))
else
log.error("Invalid temperature value received: " .. tostring(value.value))
end
end
Comment on lines +54 to +70
Copy link
Contributor

Choose a reason for hiding this comment

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

if you just added battery and temperatureMeasurement here: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-power-meter/src/init.lua#L53

You could omit most of this file.


local function device_init(driver, device)
if configuration ~= nil then
for _, attribute in ipairs(configuration) do
device:add_configured_attribute(attribute)
end
end
end

local function added_handler(self, device)
device:emit_event(capabilities.temperatureMeasurement.temperature({ value = 0, unit = "C" }))
device:emit_event(capabilities.battery.battery({value = 0, unit = "%" }))
end

local ct_clamp_battery_temperature_handler = {
NAME = "ct_clamp_battery_temperature_handler",
zigbee_handlers = {
attr = {
--[PowerConfiguration.ID] = {
-- [PowerConfiguration.attributes.BatteryPercentageRemaining.ID] = battery_level_handler
--},
[TemperatureMeasurement.ID] = {
[TemperatureMeasurement.attributes.CurrentTemperature.ID] = temperature_handler
}
}
},
lifecycle_handlers = {
init = device_init,
added = added_handler
},
can_handle = is_chameleon_ct_clamp
}

return ct_clamp_battery_temperature_handler
2 changes: 2 additions & 0 deletions drivers/SmartThings/zigbee-power-meter/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ local zigbee_power_meter_driver_template = {
capabilities.powerMeter,
capabilities.energyMeter,
capabilities.powerConsumptionReport,
capabilities.battery,
},
zigbee_handlers = {
global = {
Expand All @@ -67,6 +68,7 @@ local zigbee_power_meter_driver_template = {
require("ezex"),
require("frient"),
require("shinasystems"),
require("chameleon"),
},
lifecycle_handlers = {
init = configurations.power_reconfig_wrapper(device_init),
Expand Down