Skip to content

Commit 7ae5cb0

Browse files
committed
add multiir_motion_MIR-IR100
1 parent 98114d8 commit 7ae5cb0

File tree

8 files changed

+393
-0
lines changed

8 files changed

+393
-0
lines changed

drivers/SmartThings/zigbee-motion-sensor/fingerprints.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ zigbeeManufacturer:
209209
manufacturer: sengled
210210
model: E1M-G7H
211211
deviceProfileName: motion-battery
212+
- id: "MultIR/MIR-IR100"
213+
deviceLabel: MultiIR Motion Detector MIR-IR100
214+
manufacturer: MultIR
215+
model: MIR-IR100
216+
deviceProfileName: motion-battery-illuminance-sensitivity-frequency-no-fw-update
212217
zigbeeGeneric:
213218
- id: kickstarter/motion/1
214219
deviceLabel: SmartThings Motion Sensor
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: motion-battery-illuminance-sensitivity-frequency-no-fw-update
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: motionSensor
6+
version: 1
7+
- id: illuminanceMeasurement
8+
version: 1
9+
- id: stse.sensitivityAdjustment
10+
version: 1
11+
- id: battery
12+
version: 1
13+
- id: refresh
14+
version: 1
15+
categories:
16+
- name: MotionSensor
17+
preferences:
18+
- title: "检测频率/秒(detection frequency/sec)"
19+
name: detectionfrequency
20+
description: "传感器检测频率(Sensor detects frequency unit: seconds)"
21+
required: false
22+
preferenceType: integer
23+
definition:
24+
minimum: 10
25+
maximum: 1800
26+
default: 60
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Copyright 2026 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
return function(opts, driver, device, ...)
5+
local FINGERPRINTS = require "MultiIR.fingerprints"
6+
for _, fingerprint in ipairs(FINGERPRINTS) do
7+
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
8+
local subdriver = require("MultiIR")
9+
return true, subdriver
10+
end
11+
end
12+
return false
13+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Copyright 2026 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
return {
5+
{ mfr = "MultIR", model = "MIR-IR100" }
6+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
-- Copyright 2026 SmartThings, Inc.
2+
-- Licensed under the Apache License, Version 2.0
3+
4+
local zcl_clusters = require "st.zigbee.zcl.clusters"
5+
local capabilities = require "st.capabilities"
6+
local data_types = require "st.zigbee.data_types"
7+
local FrameCtrl = require "st.zigbee.zcl.frame_ctrl"
8+
local zcl_messages = require "st.zigbee.zcl"
9+
local messages = require "st.zigbee.messages"
10+
local zb_const = require "st.zigbee.constants"
11+
12+
local sensitivityAdjustment = capabilities["stse.sensitivityAdjustment"]
13+
local sensitivityAdjustmentCommandName = "setSensitivityAdjustment"
14+
local IASZone = zcl_clusters.IASZone
15+
local IASZone_PRIVATE_COMMAND_ID = 0xF4
16+
17+
local PREF_SENSITIVITY_VALUE_HIGH = 3
18+
local PREF_SENSITIVITY_VALUE_MEDIUM = 2
19+
local PREF_SENSITIVITY_VALUE_LOW = 1
20+
21+
local function send_iaszone_private_cmd(device, priv_cmd, data)
22+
local frame_ctrl = FrameCtrl(0x00)
23+
frame_ctrl:set_cluster_specific()
24+
25+
local zclh = zcl_messages.ZclHeader({
26+
frame_ctrl = frame_ctrl,
27+
cmd = data_types.ZCLCommandId(priv_cmd)
28+
})
29+
30+
local message_body = zcl_messages.ZclMessageBody({
31+
zcl_header = zclh,
32+
zcl_body = data_types.Uint16(data)
33+
})
34+
35+
local addr_header = messages.AddressHeader(
36+
zb_const.HUB.ADDR,
37+
zb_const.HUB.ENDPOINT,
38+
device:get_short_address(),
39+
device:get_endpoint(IASZone.ID),
40+
zb_const.HA_PROFILE_ID,
41+
IASZone.ID
42+
)
43+
44+
local zigbee_msg = messages.ZigbeeMessageTx({
45+
address_header = addr_header,
46+
body = message_body
47+
})
48+
49+
device:send(zigbee_msg)
50+
end
51+
52+
local function iaszone_attr_sen_handler(driver, device, value, zb_rx)
53+
if value.value == PREF_SENSITIVITY_VALUE_HIGH then
54+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.High())
55+
elseif value.value == PREF_SENSITIVITY_VALUE_MEDIUM then
56+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.Medium())
57+
elseif value.value == PREF_SENSITIVITY_VALUE_LOW then
58+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.Low())
59+
end
60+
end
61+
62+
local function send_sensitivity_adjustment_value(device, value)
63+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:write(device, value))
64+
end
65+
66+
local function sensitivity_adjustment_capability_handler(driver, device, command)
67+
local sensitivity = command.args.sensitivity
68+
if sensitivity == 'High' then
69+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_HIGH)
70+
elseif sensitivity == 'Medium' then
71+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_MEDIUM)
72+
elseif sensitivity == 'Low' then
73+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_LOW)
74+
end
75+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:read(device))
76+
end
77+
78+
local function added_handler(self, device)
79+
device:emit_event(capabilities.motionSensor.motion.inactive())
80+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.High())
81+
device:emit_event(capabilities.battery.battery(100))
82+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:read(device))
83+
end
84+
85+
local function info_changed(driver, device, event, args)
86+
for name, value in pairs(device.preferences) do
87+
if (device.preferences[name] ~= nil and args.old_st_store.preferences[name] ~= device.preferences[name]) then
88+
if (name == "detectionfrequency") then
89+
local detectionfrequency = tonumber(device.preferences.detectionfrequency)
90+
send_iaszone_private_cmd(device, IASZone_PRIVATE_COMMAND_ID, detectionfrequency)
91+
end
92+
end
93+
end
94+
end
95+
96+
local MultiIR_motion_handler = {
97+
NAME = "MultiIR motion handler",
98+
lifecycle_handlers = {
99+
added = added_handler,
100+
infoChanged = info_changed
101+
},
102+
capability_handlers = {
103+
[sensitivityAdjustment.ID] = {
104+
[sensitivityAdjustmentCommandName] = sensitivity_adjustment_capability_handler,
105+
}
106+
},
107+
zigbee_handlers = {
108+
attr = {
109+
[IASZone.ID] = {
110+
[IASZone.attributes.CurrentZoneSensitivityLevel.ID] = iaszone_attr_sen_handler
111+
}
112+
}
113+
},
114+
can_handle = require("MultiIR.can_handle")
115+
}
116+
117+
return MultiIR_motion_handler

drivers/SmartThings/zigbee-motion-sensor/src/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ local zigbee_motion_driver = {
118118
lazy_load_if_possible("smartsense"),
119119
lazy_load_if_possible("thirdreality"),
120120
lazy_load_if_possible("sengled"),
121+
lazy_load_if_possible("MultiIR"),
121122
},
122123
additional_zcl_profiles = {
123124
[0xFC01] = true

0 commit comments

Comments
 (0)