Skip to content

Conversation

@petewaddy-petewaddy
Copy link

Check all that apply

Type of Change

  • [x ] WWST Certification Request
    • If this is your first time contributing code:
      • [ x] I have reviewed the README.md file
      • [ x] I have reviewed the CODE_OF_CONDUCT.md file
      • [ x] I have signed the CLA
    • [x ] I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • [x ] New feature
  • Refactor

Checklist

  • [ x] I have performed a self-review of my code
  • [ x] I have commented my code in hard-to-understand areas
  • [x ] I have verified my changes by testing with a device or have communicated a plan for testing
  • [x ] I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

add a sub driver to the standard edge driver for Zigbee Power meter to supply temperature and battery percentage readings

Summary of Completed Tests

Smartthings full 14 test test suite from the certification console, all 14 tests passed

Test date: 13 November 2025 at 11:28:28
Test duration: 00:12:27
Session ID: WHJ1WLTHID

Test date: 13 November 2025 at 11:51:55
Test duration: 00:09:10
Session ID: 1DIHUP08CV

@greens greens changed the title Ct clamp driver wwsm WWSTCERT-9096 Ct clamp driver wwsm Nov 25, 2025

local function battery_level_handler(driver, device, value, _zb_rx)
if type(value.value) == "number" then
local number = value.value/2

Choose a reason for hiding this comment

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

spacing

Choose a reason for hiding this comment

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

now corrected

petewaddy-petewaddy added a commit to petewaddy-petewaddy/SmartThingsEdgeDrivers that referenced this pull request Nov 26, 2025
PR SmartThingsCommunity#2552

indent code under the statement to the right   as per pull request comment
Copy link

@pegor-karoglanian pegor-karoglanian left a comment

Choose a reason for hiding this comment

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

lgtm

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Comment on lines 43 to 63
- id: "ChameleonCTClamp"
deviceLabel: Zigbee CT
deviceIdentifiers:
- 0x000D
zigbeeProfiles:
- 0x0104
clusters:
server:
- 0x0000 #Basic
- 0x0001 #Power Configuration
- 0x0002 #Device Temperature Configuration
- 0x0003 #Identify
- 0x0019 #Over the Air Bootloading
- 0x0020 #Poll Control
- 0x0702 #Simple Metering
- 0x0B04 #Electrical Measurement
client:
- 0x0003 #Identify
deviceProfileName: ct-clamp


Copy link
Contributor

Choose a reason for hiding this comment

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

Please just include the manufacturer-specific fingerprint

Choose a reason for hiding this comment

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

other fingerprints now removed

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

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Test Results

   71 files    469 suites   0s ⏱️
2 457 tests 2 457 ✅ 0 💤 0 ❌
4 177 runs  4 177 ✅ 0 💤 0 ❌

Results for commit e04499e.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

File Coverage
All files 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/frient/init.lua 77%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/shinasystems/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/chameleon/init.lua 73%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-power-meter/src/configurations.lua 95%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against e04499e

Comment on lines 68 to 71
local batt_level = device:get_latest_state("main", capabilities.battery.ID, capabilities.battery.battery.NAME) or nil
if batt_level == nil then
device:emit_event(capabilities.battery.battery.normal())
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect this to go in added. Is there a reason you included it in init?

Choose a reason for hiding this comment

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

now removed as unnecessary

Comment on lines 43 to 59
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
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.

Choose a reason for hiding this comment

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

We've moved battery but temperatureMeasurement wasn't possible to move as we think it's a different ZCL temperature attribute from a different cluster to what you were thinking of @greens but we may have missed something?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are correct. I see now that you are using clusters.DeviceTemperatureConfiguration rather than clusters.TemperatureMeasurement, so you are correct, that is not handled by our defaults.

@greens
Copy link
Contributor

greens commented Dec 1, 2025

Checking drivers/SmartThings/zigbee-power-meter/src/chameleon/init.lua 2 warnings

    drivers/SmartThings/zigbee-power-meter/src/chameleon/init.lua:2:7: (W211) unused variable cluster_base
    drivers/SmartThings/zigbee-power-meter/src/chameleon/init.lua:3:7: (W211) unused variable data_types

Copy link
Contributor

@greens greens left a comment

Choose a reason for hiding this comment

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

Please address the remaining comments.

Comment on lines 43 to 45



Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

Choose a reason for hiding this comment

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

made suggested change and removed newlines

{model = "CT101xxxx" }
}

-- temperature: 0.5C, battery level remaining: 1%
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still needed?

Choose a reason for hiding this comment

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

now removed

Comment on lines 46 to 42
for _, fingerprint in ipairs(ZIGBEE_FINGERPRINT) do
if device:get_model() == fingerprint.model then
return true
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spacing

Choose a reason for hiding this comment

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

adjusted spacing

Comment on lines 35 to 42
{
cluster = PowerConfiguration.ID,
attribute = PowerConfiguration.attributes.BatteryPercentageRemaining.ID,
minimum_interval = 30,
maximum_interval = 3600,
data_type = PowerConfiguration.attributes.BatteryPercentageRemaining.base_type,
reportable_change = 2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend that you omit this and use the defaults here, which has a maximum_interval of 6 hours and a reportable change of 1.

Choose a reason for hiding this comment

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

omitted and using defaults

Comment on lines 54 to 62
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
Copy link
Contributor

Choose a reason for hiding this comment

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

since you are using the defaults here now, this function can be removed

Choose a reason for hiding this comment

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

function removed

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this log statement.

Choose a reason for hiding this comment

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

log statement removed

@petewaddy-petewaddy
Copy link
Author

Last 4 comments have been actioned.
Device tested, working as expected.
ran the WWST 14 point test suite , passed as below

Test summary for Chameleon CT Clamp

Congratulations! Your product passed the test and no issues were detected with your product.
Test date: 15 December 2025 at 11:43:07
Test duration: 00:10:38
Session ID: 3L1W0P48DR
Device Profile: power-energy-battery-temperature (3fd2150c-62d6-3df7-9389-0ccceb843096)
Driver: Zigbee Power/Meter (1c09b903-7601-48cf-9a5b-8e3bb0e63b90)

@greens
Copy link
Contributor

greens commented Dec 16, 2025

You'll need to rebase your branch to resolve the merge conflicts.

@petewaddy-petewaddy
Copy link
Author

Regarding the conflicts the fingerprints.yml is just an additional of chameleon along side the BITUO TECHNIK entry.

but my init.lua originally had

sub_drivers = {
require("ezex"),
require("frient"),
require("shinasystems"),
require("chameleon"),
},

but currently the current master/main has sub_drivers = require("sub_drivers"), with a new file sub_drivers.lua and also a new file lazy_load_subdriver.lua

this looks like a newer feature for sub drivers, I am right in assuming I will need to implement this before we can merge?

…driver for temperature, battery percentage

e
battery seems to always be at 100% on both tested clamps, even throiugh one is as 98%
Now calling the ct clamp sub driver - have temperature,battery,power meter and energy meter on the screen, last two are correct values, first two are not as yet
…nd deployed to the hub, using the standard smartthings zigbee power meter as the base and adding as a sub driver the temperature and battery level
PR SmartThingsCommunity#2552

indent code under the statement to the right   as per pull request comment
rename file from ct-clamp.yml to power-energy-battery-temperature.yml
add copyright information
removed unused variables cluster_base and data_types
add changed name into yaml file
remove non manufacturer specific items
Added longer copyright at top of our init.lua file
removed comment about tempeature and battery
removed battery level handler to main init.lua file under capabilities.battery, temperature syayed as its cluster 0x0402 not the normal temperature cluster and didn't update the temperature
removed 3 lines as requested in comments on the pull request
remove unintentional extra line in .gitignore
add new line, that was erased by accicent in these two files
trying to insert a new line at the end of the file to remove the red circle in github, when the file is checked in
remove battery percentage config, and use defaults
remove battery_level_handler as usinf the capabilites function
remove log function in temperature handler
adjust spacing in is_chameleon_ct_clamp function
after a rebase add in the chameleon entry into the sub_drivers.lua file
petewaddy-petewaddy and others added 2 commits December 18, 2025 16:11
after a rebase add in the chameleon entry into the sub_drivers.lua file
add in the new files can_handle.lua and fingerprints.lua, for the new type of sub driver architecture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants