-
Notifications
You must be signed in to change notification settings - Fork 524
WWSTCERT-10189 Ledvance zigbee meter plug #2729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LQ107
wants to merge
22
commits into
SmartThingsCommunity:main
Choose a base branch
from
LQ107:ledvance_zigbee_meter_plug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 316276d
add the handle file
LQ107 c01a9d0
add driver fingerprints
LQ107 5e5a387
modify the ledvance zigbee meter plug device Label
LQ107 98aafe1
add driver for PLUG EU EM T
LQ107 6a76283
delete the PLUG EU EM T driver
LQ107 14de7ba
Update the PLUG COMPACT EU EM T device driver
LQ107 99ce6ea
set the multiplier and divisor fields in the initial handler
LQ107 22bc75b
disable the rely on the defaults to read the multiplier/divisor and A…
LQ107 b81fa6b
fixing the init.lua multiplier/divisor handle ,fixing the commit conf…
LQ107 328797c
update sub driver init.lua files
LQ107 8f598e7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 5004c95
Remove unnecessary files
LQ107 09b89b7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 3a46f9d
Remove redundant code
LQ107 b7eb6b6
Merge branch 'ledvance_zigbee_meter_plug' of https://github.com/LQ107…
LQ107 6b409cb
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 41d31e7
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 28e7783
1.add the test unit 2. add sub driver register 3.fixing the energy_me…
LQ107 875c75f
revert the gitgnore file to the default
LQ107 4011278
Merge branch 'ledvance_zigbee_meter_plug' of https://github.com/LQ107…
LQ107 3347541
Merge branch 'main' into ledvance_zigbee_meter_plug
LQ107 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ tools/coverage_output_html/ | |
| tools/__pycache__/ | ||
| .DS_Store | ||
| .venv/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
drivers/SmartThings/zigbee-switch/src/simple-metering-config/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
6 changes: 6 additions & 0 deletions
6
drivers/SmartThings/zigbee-switch/src/simple-metering-config/fingerprints.lua
greens marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" } | ||
| } |
55 changes: 55 additions & 0 deletions
55
drivers/SmartThings/zigbee-switch/src/simple-metering-config/init.lua
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should only need the Please include some unit tests if you think your changes are necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
71 changes: 71 additions & 0 deletions
71
...SmartThings/zigbee-switch/src/simple-metering-config/test/test_simple_metering_config.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 rmto remove files from tracking