Skip to content

Commit 96c4bd3

Browse files
committed
add yanmi Y-K003-001 switch
1 parent 9d596dc commit 96c4bd3

File tree

5 files changed

+504
-1
lines changed

5 files changed

+504
-1
lines changed

drivers/SmartThings/zigbee-switch/fingerprints.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2369,6 +2369,11 @@ zigbeeManufacturer:
23692369
manufacturer: LAISIAO
23702370
model: yuba
23712371
deviceProfileName: switch-smart-bath-heater-laisiao
2372+
- id: "JNL/Y-K003-001"
2373+
deviceLabel: Yanmi Switch (3 Way) 1
2374+
manufacturer: JNL
2375+
model: Y-K003-001
2376+
deviceProfileName: basic-switch
23722377
zigbeeGeneric:
23732378
- id: "genericSwitch"
23742379
deviceLabel: Zigbee Switch
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
-- Copyright 2025 SmartThings
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
local stDevice = require "st.device"
16+
local configurations = require "configurations"
17+
18+
19+
local FINGERPRINTS = {
20+
{ mfr = "JNL", model = "Y-K003-001", switches = 3 }
21+
}
22+
23+
local function can_handle_Yanmi(opts, driver, device, ...)
24+
for _, fingerprint in ipairs(FINGERPRINTS) do
25+
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
26+
local subdriver = require("Yanmi")
27+
return true, subdriver
28+
end
29+
end
30+
return false
31+
end
32+
33+
local function get_children_info(device)
34+
for _, fingerprint in ipairs(FINGERPRINTS) do
35+
if device:get_model() == fingerprint.model then
36+
return fingerprint.switches
37+
end
38+
end
39+
end
40+
41+
local function find_child(parent, ep_id)
42+
return parent:get_child_by_parent_assigned_key(string.format("%02X", ep_id))
43+
end
44+
45+
local function create_child_devices(driver, device)
46+
local switch_amount = get_children_info(device)
47+
local base_name = string.sub(device.label, 0, -2)
48+
-- Create Switch 2-3
49+
for i = 2, switch_amount, 1 do
50+
if find_child(device, i) == nil then
51+
local metadata = {
52+
type = "EDGE_CHILD",
53+
parent_assigned_child_key = string.format("%02X", i),
54+
label = base_name .. i,
55+
profile = "basic-switch",
56+
parent_device_id = device.id,
57+
vendor_provided_label = base_name .. i,
58+
}
59+
driver:try_create_device(metadata)
60+
end
61+
end
62+
device:refresh()
63+
end
64+
65+
local function device_added(driver, device)
66+
if device.network_type ~= stDevice.NETWORK_TYPE_CHILD then
67+
create_child_devices(driver, device)
68+
end
69+
end
70+
71+
local function device_init(driver, device, event)
72+
device:set_find_child(find_child)
73+
end
74+
75+
local Yanmi_switch = {
76+
NAME = "Zigbee Yanmi Switch",
77+
lifecycle_handlers = {
78+
added = device_added,
79+
init = configurations.power_reconfig_wrapper(device_init)
80+
},
81+
can_handle = can_handle_Yanmi
82+
}
83+
84+
return Yanmi_switch

drivers/SmartThings/zigbee-switch/src/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ local zigbee_switch_driver_template = {
166166
lazy_load_if_possible("inovelli-vzm31-sn"),
167167
lazy_load_if_possible("laisiao"),
168168
lazy_load_if_possible("tuya-multi"),
169-
lazy_load_if_possible("frient")
169+
lazy_load_if_possible("frient"),
170+
lazy_load_if_possible("Yanmi")
170171
},
171172
zigbee_handlers = {
172173
global = {

0 commit comments

Comments
 (0)