Skip to content

Commit 1101b3c

Browse files
authored
Add Aqara Dimmer Switch H2 models (#1964)
- 1 Button, 1 Channel (PID=0x100A) - 3 Buttons, 1 Channel (PID=0x1006)
1 parent d7846ad commit 1101b3c

File tree

2 files changed

+50
-15
lines changed

2 files changed

+50
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: light-level-power-energy-powerConsumption
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: switch
6+
version: 1
7+
- id: switchLevel
8+
version: 1
9+
config:
10+
values:
11+
- key: "level.value"
12+
range: [1, 100]
13+
- id: powerMeter
14+
version: 1
15+
- id: energyMeter
16+
version: 1
17+
- id: powerConsumptionReport
18+
version: 1
19+
- id: firmwareUpdate
20+
version: 1
21+
- id: refresh
22+
version: 1
23+
categories:
24+
- name: Light

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

+26-15
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,20 @@ local device_type_attribute_map = {
170170
}
171171
}
172172

173-
local child_device_profile_overrides = {
174-
{ vendor_id = 0x1321, product_id = 0x000C, target_profile = "switch-binary", initial_profile = "plug-binary" },
175-
{ vendor_id = 0x1321, product_id = 0x000D, target_profile = "switch-binary", initial_profile = "plug-binary" },
176-
{ vendor_id = 0x115F, product_id = 0x1003, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons, 1 Channel
177-
{ vendor_id = 0x115F, product_id = 0x1004, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons, 2 Channels
178-
{ vendor_id = 0x115F, product_id = 0x1005, target_profile = "light-power-energy-powerConsumption" }, -- 4 Buttons, 3 Channels
179-
{ vendor_id = 0x115F, product_id = 0x1008, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons, 1 Channel
180-
{ vendor_id = 0x115F, product_id = 0x1009, target_profile = "light-power-energy-powerConsumption" }, -- 4 Buttons, 2 Channels
173+
local child_device_profile_overrides_per_vendor_id = {
174+
[0x1321] = {
175+
{ product_id = 0x000C, target_profile = "switch-binary", initial_profile = "plug-binary" },
176+
{ product_id = 0x000D, target_profile = "switch-binary", initial_profile = "plug-binary" },
177+
},
178+
[0x115F] = {
179+
{ product_id = 0x1003, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 1 Channel(On/Off Light)
180+
{ product_id = 0x1004, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 2 Channels(On/Off Light)
181+
{ product_id = 0x1005, target_profile = "light-power-energy-powerConsumption" }, -- 4 Buttons(Generic Switch), 3 Channels(On/Off Light)
182+
{ product_id = 0x1006, target_profile = "light-level-power-energy-powerConsumption" }, -- 3 Buttons(Generic Switch), 1 Channels(Dimmable Light)
183+
{ product_id = 0x1008, target_profile = "light-power-energy-powerConsumption" }, -- 2 Buttons(Generic Switch), 1 Channel(On/Off Light)
184+
{ product_id = 0x1009, target_profile = "light-power-energy-powerConsumption" }, -- 4 Buttons(Generic Switch), 2 Channels(On/Off Light)
185+
{ product_id = 0x100A, target_profile = "light-level-power-energy-powerConsumption" }, -- 1 Buttons(Generic Switch), 1 Channels(Dimmable Light)
186+
}
181187
}
182188

183189
local detect_matter_thing
@@ -383,6 +389,11 @@ local function device_type_supports_button_switch_combination(device, endpoint_i
383389
if ep.endpoint_id == endpoint_id then
384390
for _, dt in ipairs(ep.device_types) do
385391
if dt.device_type_id == DIMMABLE_LIGHT_DEVICE_TYPE_ID then
392+
for _, fingerprint in ipairs(child_device_profile_overrides_per_vendor_id[0x115F]) do
393+
if device.manufacturer_info.product_id == fingerprint.product_id then
394+
return false -- For Aqara Dimmer Switch with Button.
395+
end
396+
end
386397
return true
387398
end
388399
end
@@ -467,12 +478,12 @@ local function assign_child_profile(device, child_ep)
467478
-- determined in the "for" loop above (e.g., light-binary)
468479
-- 2. The selected profile for the child device matches the initial profile defined in
469480
-- child_device_profile_overrides
470-
for _, fingerprint in ipairs(child_device_profile_overrides) do
471-
if device.manufacturer_info.vendor_id == fingerprint.vendor_id and
472-
device.manufacturer_info.product_id == fingerprint.product_id and
473-
((device.manufacturer_info.vendor_id == AQARA_MANUFACTURER_ID and child_ep == 1) or profile == fingerprint.initial_profile) then
474-
profile = fingerprint.target_profile
475-
break
481+
for id, vendor in pairs(child_device_profile_overrides_per_vendor_id) do
482+
for _, fingerprint in ipairs(vendor) do
483+
if device.manufacturer_info.product_id == fingerprint.product_id and
484+
((device.manufacturer_info.vendor_id == AQARA_MANUFACTURER_ID and child_ep == 1) or profile == fingerprint.initial_profile) then
485+
return fingerprint.target_profile
486+
end
476487
end
477488
end
478489

@@ -603,7 +614,7 @@ local function try_build_child_switch_profiles(driver, device, switch_eps, main_
603614
}
604615
)
605616
parent_child_device = true
606-
if _ == 1 and child_profile == "light-power-energy-powerConsumption" then
617+
if _ == 1 and string.find(child_profile, "energy") then
607618
-- when energy management is defined in the root endpoint(0), replace it with the first switch endpoint and process it.
608619
device:set_field(ENERGY_MANAGEMENT_ENDPOINT, ep, {persist = true})
609620
end

0 commit comments

Comments
 (0)