Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c8278e8
ledvance zigbee meter plug driver pull
LQ107 Jan 26, 2026
316276d
add the handle file
LQ107 Jan 26, 2026
c01a9d0
add driver fingerprints
LQ107 Jan 30, 2026
5e5a387
modify the ledvance zigbee meter plug device Label
LQ107 Jan 30, 2026
98aafe1
add driver for PLUG EU EM T
LQ107 Jan 30, 2026
6a76283
delete the PLUG EU EM T driver
LQ107 Jan 30, 2026
14de7ba
Update the PLUG COMPACT EU EM T device driver
LQ107 Feb 10, 2026
99ce6ea
set the multiplier and divisor fields in the initial handler
LQ107 Mar 3, 2026
22bc75b
disable the rely on the defaults to read the multiplier/divisor and A…
LQ107 Mar 4, 2026
b81fa6b
fixing the init.lua multiplier/divisor handle ,fixing the commit conf…
LQ107 Mar 4, 2026
328797c
update sub driver init.lua files
LQ107 Mar 4, 2026
8f598e7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 Mar 4, 2026
5004c95
Remove unnecessary files
LQ107 Mar 5, 2026
09b89b7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 Mar 5, 2026
3a46f9d
Remove redundant code
LQ107 Mar 6, 2026
b7eb6b6
Merge branch 'ledvance_zigbee_meter_plug' of https://github.com/LQ107…
LQ107 Mar 6, 2026
6b409cb
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 Mar 6, 2026
41d31e7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 Mar 10, 2026
28e7783
1.add the test unit 2. add sub driver register 3.fixing the energy_me…
LQ107 Mar 11, 2026
875c75f
revert the gitgnore file to the default
LQ107 Mar 11, 2026
4011278
Merge branch 'ledvance_zigbee_meter_plug' of https://github.com/LQ107…
LQ107 Mar 11, 2026
3347541
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 Mar 11, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Copy link
Contributor

Choose a reason for hiding this comment

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

revert these changes

just use git rm to remove files from tracking

Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tools/coverage_output_html/
tools/__pycache__/
.DS_Store
.venv/

5 changes: 5 additions & 0 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,11 @@ zigbeeManufacturer:
manufacturer: LEDVANCE
model: RT TW
deviceProfileName: color-temp-bulb
- id: "LEDVANCE/PLUG COMPACT EU EM T"
deviceLabel: SMART ZIGBEE COMPACT OUTDOOR PLUG EU
manufacturer: LEDVANCE
model: PLUG COMPACT EU EM T
deviceProfileName: switch-power-energy
- id: "OSRAM/LIGHTIFY Edge-lit flushmount"
deviceLabel: SYLVANIA Light
manufacturer: OSRAM
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

return function(opts, driver, device, ...)
local FINGERPRINTS = require("simple-metering-config.fingerprints")
for _, fingerprint in ipairs(FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
local subdriver = require("simple-metering-config")
return true, subdriver
end
end
return false
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

return {
{ mfr = "LEDVANCE", model = "PLUG COMPACT EU EM T" }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should only need the init functions, or just rely on the defaults to read the multiplier/divisor.

Please include some unit tests if you think your changes are necessary.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local capabilities = require "st.capabilities"
local zigbee_constants = require "st.zigbee.constants"
local SimpleMetering = require "st.zigbee.cluster".clusters.SimpleMetering

local function energy_meter_handler(driver, device, value, zb_rx)
local raw_value = value.value

if type(raw_value) ~= "number" or raw_value < 0 then
return
end

local divisor = device:get_field(zigbee_constants.SIMPLE_METERING_DIVISOR_KEY) or 100
local multiplier = device:get_field(zigbee_constants.SIMPLE_METERING_MULTIPLIER_KEY) or 1

if divisor == 0 then
return
end

local calculated_value = (raw_value * multiplier) / divisor

device:emit_event_for_endpoint(
zb_rx.address_header.src_endpoint.value,
capabilities.energyMeter.energy({ value = calculated_value, unit = "kWh" })
)
end

local function device_init(driver, device)
-- Set default multiplier and divisor values as suggested by SmartThings
device:set_field(zigbee_constants.SIMPLE_METERING_MULTIPLIER_KEY, 1, {persist = true})
device:set_field(zigbee_constants.SIMPLE_METERING_DIVISOR_KEY, 100, {persist = true})
end

local simple_metering_config_subdriver = {
NAME = "Simple Metering Config",
supported_capabilities = {
capabilities.energyMeter,
capabilities.powerMeter
},
zigbee_handlers = {
attr = {
[SimpleMetering.ID] = {
[SimpleMetering.attributes.CurrentSummationDelivered.ID] = energy_meter_handler
}
}
},
lifecycle_handlers = {
init = device_init
},
can_handle = require("simple-metering-config.can_handle")
}

return simple_metering_config_subdriver
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local test = require "integration_test"
local zigbee_test_utils = require "integration_test.zigbee_test_utils"
local clusters = require "st.zigbee.zcl.clusters"
local SimpleMetering = clusters.SimpleMetering
local capabilities = require "st.capabilities"
local t_utils = require "integration_test.utils"

local mock_device = test.mock_device.build_test_zigbee_device(
{
profile = t_utils.get_profile_definition("switch-power-energy.yml"),
zigbee_endpoints = {
[1] = {
id = 1,
manufacturer = "LEDVANCE",
model = "PLUG COMPACT EU EM T",
server_clusters = { 0x0006, 0x0702 }
}
}
}
)

zigbee_test_utils.prepare_zigbee_env_info()

local function test_init()
test.mock_device.add_test_device(mock_device)
end

test.set_test_init_function(test_init)

test.register_message_test(
"Energy meter report should be handled with default multiplier and divisor",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, SimpleMetering.attributes.CurrentSummationDelivered:build_test_attr_report(mock_device, 1000) }
},
{
channel = "capability",
direction = "send",
message = mock_device:generate_test_message("main", capabilities.energyMeter.energy({ value = 10, unit = "kWh" }))
}
}
)

test.register_message_test(
"Energy meter report with zero value should be ignored",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, SimpleMetering.attributes.CurrentSummationDelivered:build_test_attr_report(mock_device, 0) }
}
}
)

test.register_message_test(
"Energy meter report with negative value should be ignored",
{
{
channel = "zigbee",
direction = "receive",
message = { mock_device.id, SimpleMetering.attributes.CurrentSummationDelivered:build_test_attr_report(mock_device, -100) }
}
}
)

test.run_registered_tests()
1 change: 1 addition & 0 deletions drivers/SmartThings/zigbee-switch/src/sub_drivers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ return {
lazy_load_if_possible("sinope"),
lazy_load_if_possible("sinope-dimmer"),
lazy_load_if_possible("zigbee-dimmer-power-energy"),
lazy_load_if_possible("simple-metering-config"),
lazy_load_if_possible("zigbee-metering-plug-power-consumption-report"),
lazy_load_if_possible("jasco"),
lazy_load_if_possible("multi-switch-no-master"),
Expand Down