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
16 changes: 5 additions & 11 deletions drivers/SmartThings/zigbee-switch/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,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 Expand Up @@ -2400,22 +2405,11 @@ zigbeeManufacturer:
manufacturer: NodOn
model: SIN-4-1-21
deviceProfileName: switch-power-energy
#Yanmi
- id: "JNL/Y-K003-001"
deviceLabel: Yanmi Switch (3 Way) 1
manufacturer: JNL
model: Y-K003-001
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:
- id: "genericSwitch"
deviceLabel: Zigbee Switch
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

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
return true
end
end
return false
end

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

-- 定义支持该子驱动程序的设备指纹
-- 这里可以指定特定的制造商和型号
return {
["Generic"] = {
["SimpleMeteringDevice"] = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
-- Copyright 2025 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 zigbee_handlers = require "st.zigbee.handlers"

-- 设置 Simple Metering 集群的 multipliers 和 divisors 属性
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

-- 处理能量计量事件
local function energy_meter_handler(driver, device, value, zb_rx)
local raw_value = value.value
local divisor = device:get_field(SimpleMetering.attributes.Divisor.ID) or 100
local multiplier = device:get_field(SimpleMetering.attributes.Multiplier.ID) or 1

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 simple_metering_config_subdriver = {
supported_capabilities = {
capabilities.energyMeter,
capabilities.powerMeter
},
lifecycle_handlers = {
init = device_init
},
zigbee_handlers = {
cluster = {
[SimpleMetering.ID] = {
[SimpleMetering.attributes.CurrentSummationDelivered.ID] = energy_meter_handler
}
}
}
}

return simple_metering_config_subdriver