-
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
base: main
Are you sure you want to change the base?
Conversation
| fingerprints: | ||
| - manufacturer: "LEDVANCE" | ||
| model: "PLUG COMPACT EU EM T" | ||
| deviceProfileName: "switch-power-energy" | ||
| id: "LEDVANCE/PLUG COMPACT EU EM T" | ||
| deviceLabel: "SMART ZIGBEE COMPACT OUTDOOR PLUG EU" No newline at end of file |
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.
please remove the changes to this file
| deviceProfileName: basic-switch | ||
| - id: "JNL/Y-K001-001" | ||
| deviceLabel: Yanmi Switch (1 Way) | ||
| manufacturer: JNL | ||
| model: Y-K001-001 | ||
| deviceProfileName: basic-switch | ||
| - id: "JNL/Y-K002-001" | ||
| deviceLabel: Yanmi Switch (2 Way) 1 | ||
| manufacturer: JNL | ||
| model: Y-K002-001 | ||
| deviceProfileName: basic-switch | ||
| zigbeeGeneric: |
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.
please do not remove other partners' fingerprints
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.
I'm unsure where this file is used?
| local can_handle_simple_metering_config = function(opts, driver, device) | ||
| -- 检查设备是否支持 Simple Metering 集群 (0x0702) | ||
| for _, cluster in ipairs(device.server_clusters) do | ||
| if cluster == 0x0702 then |
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.
we have other devices for which this would return true where we would not want your specific device's logic to be used, which is why we usually gate subdrivers via fingerprints
| local function device_init(driver, device) | ||
| -- 在设备初始化时设置 multipliers 和 divisors | ||
| device:configure() | ||
|
|
||
| -- 设置 Multiplier 为 1 | ||
| local write_multiplier_cmd = SimpleMetering.server.commands.WriteAttributes(device) | ||
| if write_multiplier_cmd then | ||
| device:send_to_component( | ||
| write_multiplier_cmd({ | ||
| {id = SimpleMetering.attributes.Multiplier.ID, value = 1, DataType = 0x22} -- 0x22 is 24-bit integer | ||
| }), | ||
| "main" | ||
| ) | ||
| end | ||
|
|
||
| -- 设置 Divisor 为 100 | ||
| local write_divisor_cmd = SimpleMetering.server.commands.WriteAttributes(device) | ||
| if write_divisor_cmd then | ||
| device:send_to_component( | ||
| write_divisor_cmd({ | ||
| {id = SimpleMetering.attributes.Divisor.ID, value = 100, DataType = 0x23} -- 0x23 is 32-bit integer | ||
| }), | ||
| "main" | ||
| ) | ||
| end | ||
| end |
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.
It is often the case that the driver init event happens before the radio is up after a hub restart, resulting in zigbee messages failing to be sent. I would recommend moving these to added or configure, since they likely do not need to be re-sent to the device every time they hub restarts.
| local divisor = device:get_field(SimpleMetering.attributes.Divisor.ID) or 100 | ||
| local multiplier = device:get_field(SimpleMetering.attributes.Multiplier.ID) or 1 |
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.
this field is not likely to be set. We do set a similar field from "st.zigbee.constants": constants.SIMPLE_METERING_MULTIPLIER_KEY (and divisor) in our defaults, but we never use the attribute ID as a key,
| if write_multiplier_cmd then | ||
| device:send_to_component( | ||
| write_multiplier_cmd({ | ||
| {id = SimpleMetering.attributes.Multiplier.ID, value = 1, DataType = 0x22} -- 0x22 is 24-bit integer |
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.
we provide "st.zigbee.data_types" which has a Int24 (and Int32 constant)
| if write_divisor_cmd then | ||
| device:send_to_component( | ||
| write_divisor_cmd({ | ||
| {id = SimpleMetering.attributes.Divisor.ID, value = 100, DataType = 0x23} -- 0x23 is 32-bit integer |
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.
in the ZCL this attribute is an Int24
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.
It seems fairly obvious that your AI agent was not up to the task here.
|
Hi Steven ,
I have updated the driver according to the suggestion you provided. Please help me review it again, thank you very much .
Best regards!
Long,Jack
***@***.***
发件人: Steven Green ***@***.***>
发送时间: 2026年2月5日 4:23
收件人: SmartThingsCommunity/SmartThingsEdgeDrivers ***@***.***>
抄送: Long, Jack ***@***.***>; Author ***@***.***>
主题: Re: [SmartThingsCommunity/SmartThingsEdgeDrivers] WWSTCERT-10189 Ledvance zigbee meter plug (PR #2729)
You don't often get email from ***@***.******@***.***>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
@greens commented on this pull request.
________________________________
In drivers/SmartThings/zigbee-switch/fingerprints.yml<#2729 (comment)>:
- - id: "JNL/Y-K001-001"
- deviceLabel: Yanmi Switch (1 Way)
- manufacturer: JNL
- model: Y-K001-001
- deviceProfileName: basic-switch
- - id: "JNL/Y-K002-001"
- deviceLabel: Yanmi Switch (2 Way) 1
- manufacturer: JNL
- model: Y-K002-001
- deviceProfileName: basic-switch
zigbeeGeneric:
please do not remove other partners' fingerprints
―
Reply to this email directly, view it on GitHub<#2729 (review)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/B32Y5R5HB5C67Q7L5IPRYLD4KJII5AVCNFSM6AAAAACS4NOPFCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTONJSHA4TGMRYHE>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
| 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 |
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.
our default handlers should handle this case, provided your device properly reports its simple metering multiplier and divisor.
| @@ -0,0 +1,44 @@ | |||
| -- Copyright 2025 SmartThings, Inc. | |||
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.
date
greens
left a comment
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.
Based on what you have here, I think all you need to add is the entry in fingerprints.yml. There does not seem to be any device-specific behavior that is different from our default handlers.
Check all that apply
Type of Change
Checklist
Description of Change
Summary of Completed Tests