Skip to content

Commit 3b5d613

Browse files
committed
add multiir_motion_MIR-IR100
1 parent c39614b commit 3b5d613

File tree

8 files changed

+418
-0
lines changed

8 files changed

+418
-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
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
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: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
local read_attribute = require "st.zigbee.zcl.global_commands.read_attribute"
12+
13+
local sensitivityAdjustment = capabilities["stse.sensitivityAdjustment"]
14+
local sensitivityAdjustmentCommandName = "setSensitivityAdjustment"
15+
local IASZone = zcl_clusters.IASZone
16+
local IASZone_PRIVATE_COMMAND_ID = 0xF4
17+
18+
local PREF_SENSITIVITY_VALUE_HIGH = 3
19+
local PREF_SENSITIVITY_VALUE_MEDIUM = 2
20+
local PREF_SENSITIVITY_VALUE_LOW = 1
21+
22+
local function send_iaszone_private_cmd(device, priv_cmd, data)
23+
local frame_ctrl = FrameCtrl(0x00)
24+
frame_ctrl:set_cluster_specific()
25+
26+
local zclh = zcl_messages.ZclHeader({
27+
frame_ctrl = frame_ctrl,
28+
cmd = data_types.ZCLCommandId(priv_cmd)
29+
})
30+
31+
local message_body = zcl_messages.ZclMessageBody({
32+
zcl_header = zclh,
33+
zcl_body = data_types.Uint16(data)
34+
})
35+
36+
local addr_header = messages.AddressHeader(
37+
zb_const.HUB.ADDR,
38+
zb_const.HUB.ENDPOINT,
39+
device:get_short_address(),
40+
device:get_endpoint(IASZone.ID),
41+
zb_const.HA_PROFILE_ID,
42+
IASZone.ID
43+
)
44+
45+
local zigbee_msg = messages.ZigbeeMessageTx({
46+
address_header = addr_header,
47+
body = message_body
48+
})
49+
50+
device:send(zigbee_msg)
51+
end
52+
53+
local function iaszone_attr_sen_handler(driver, device, value, zb_rx)
54+
if value.value == PREF_SENSITIVITY_VALUE_HIGH then
55+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.High())
56+
elseif value.value == PREF_SENSITIVITY_VALUE_MEDIUM then
57+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.Medium())
58+
elseif value.value == PREF_SENSITIVITY_VALUE_LOW then
59+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.Low())
60+
end
61+
end
62+
63+
local function send_sensitivity_adjustment_value(device, value)
64+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:write(device, value))
65+
end
66+
67+
local function sensitivity_adjustment_capability_handler(driver, device, command)
68+
local sensitivity = command.args.sensitivity
69+
if sensitivity == 'High' then
70+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_HIGH)
71+
elseif sensitivity == 'Medium' then
72+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_MEDIUM)
73+
elseif sensitivity == 'Low' then
74+
send_sensitivity_adjustment_value(device, PREF_SENSITIVITY_VALUE_LOW)
75+
end
76+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:read(device))
77+
end
78+
79+
local function added_handler(self, device)
80+
device:emit_event(capabilities.motionSensor.motion.inactive())
81+
device:emit_event(sensitivityAdjustment.sensitivityAdjustment.High())
82+
device:emit_event(capabilities.battery.battery(100))
83+
device:send(IASZone.attributes.CurrentZoneSensitivityLevel:read(device))
84+
end
85+
86+
local function do_configure(self, device)
87+
device:configure()
88+
end
89+
90+
local function info_changed(driver, device, event, args)
91+
for name, value in pairs(device.preferences) do
92+
if (device.preferences[name] ~= nil and args.old_st_store.preferences[name] ~= device.preferences[name]) then
93+
if (name == "detectionfrequency") then
94+
local detectionfrequency = tonumber(device.preferences.detectionfrequency)
95+
send_iaszone_private_cmd(device, IASZone_PRIVATE_COMMAND_ID, detectionfrequency)
96+
end
97+
end
98+
end
99+
end
100+
101+
local MultiIR_motion_handler = {
102+
NAME = "MultiIR motion handler",
103+
lifecycle_handlers = {
104+
added = added_handler,
105+
doConfigure = do_configure,
106+
infoChanged = info_changed
107+
},
108+
capability_handlers = {
109+
[sensitivityAdjustment.ID] = {
110+
[sensitivityAdjustmentCommandName] = sensitivity_adjustment_capability_handler,
111+
}
112+
},
113+
zigbee_handlers = {
114+
attr = {
115+
[IASZone.ID] = {
116+
[IASZone.attributes.CurrentZoneSensitivityLevel.ID] = iaszone_attr_sen_handler
117+
}
118+
}
119+
},
120+
can_handle = require("MultiIR.can_handle")
121+
}
122+
123+
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)