-
Notifications
You must be signed in to change notification settings - Fork 531
add MultiIR Siren MIR-SR100 #2873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thinkaName
wants to merge
1
commit into
SmartThingsCommunity:main
Choose a base branch
from
thinkaName:multiir_siren_MIR-SR100
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...tThings/zigbee-siren/profiles/switch-alarm-tamper-warningduration-volume-no-fw-update.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: switch-alarm-tamper-warningduration-volume-no-fw-update | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: switch | ||
| version: 1 | ||
| - id: alarm | ||
| version: 1 | ||
| - id: tamperAlert | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Siren | ||
| preferences: | ||
| - title: "警报时长/秒(warning duration/sec)" | ||
| name: warningDuration | ||
| description: "警报持续时间 单位:秒(warning duration unit:seconds)" | ||
| required: false | ||
| preferenceType: integer | ||
| definition: | ||
| minimum: 30 | ||
| maximum: 1800 | ||
| default: 1800 | ||
| - title: "警报音量(siren volume)" | ||
| name: sirenVolume | ||
| description: "警报音量大小(siren volume)" | ||
| required: false | ||
| preferenceType: enumeration | ||
| definition: | ||
| options: | ||
| 0: "低(low)" | ||
| 1: "中(medium)" | ||
| 2: "高(high)" | ||
| 3: "最大(max)" | ||
| default: 3 | ||
13 changes: 13 additions & 0 deletions
13
drivers/SmartThings/zigbee-siren/src/MultiIR/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function(opts, driver, device, ...) | ||
| local FINGERPRINTS = require "MultiIR.fingerprints" | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| local subdriver = require("MultiIR") | ||
| return true, subdriver | ||
| end | ||
| end | ||
| return false | ||
| end |
6 changes: 6 additions & 0 deletions
6
drivers/SmartThings/zigbee-siren/src/MultiIR/fingerprints.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return { | ||
| { mfr = "MultIR", model = "MIR-SR100" } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,119 @@ | ||||||||||||||||||||
| -- Copyright 2026 SmartThings, Inc. | ||||||||||||||||||||
| -- Licensed under the Apache License, Version 2.0 | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| local data_types = require "st.zigbee.data_types" | ||||||||||||||||||||
| local zcl_clusters = require "st.zigbee.zcl.clusters" | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local IASWD = zcl_clusters.IASWD | ||||||||||||||||||||
| local IASZone = zcl_clusters.IASZone | ||||||||||||||||||||
| local IaswdLevel = IASWD.types.IaswdLevel | ||||||||||||||||||||
| local SirenConfiguration = IASWD.types.SirenConfiguration | ||||||||||||||||||||
| local WarningMode = IASWD.types.WarningMode | ||||||||||||||||||||
| local Strobe = IASWD.types.Strobe | ||||||||||||||||||||
| local capabilities = require "st.capabilities" | ||||||||||||||||||||
| local ALARM_COMMAND = "alarmCommand" | ||||||||||||||||||||
| local DEFAULT_MAX_WARNING_DURATION = 1800 | ||||||||||||||||||||
| local ALARM_STROBE_DUTY_CYCLE = 40 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local alarm_command = { | ||||||||||||||||||||
| OFF = 0, | ||||||||||||||||||||
| SIREN = 1, | ||||||||||||||||||||
| STROBE = 2, | ||||||||||||||||||||
| BOTH = 3 | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function device_added (driver, device) | ||||||||||||||||||||
| device:emit_event(capabilities.switch.switch.off()) | ||||||||||||||||||||
| device:emit_event(capabilities.alarm.alarm.off()) | ||||||||||||||||||||
| if(device:supports_capability(capabilities.tamperAlert)) then | ||||||||||||||||||||
| device:emit_event(capabilities.tamperAlert.tamper.clear()) | ||||||||||||||||||||
| end | ||||||||||||||||||||
| device:send(IASWD.attributes.MaxDuration:read(device)) | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function generate_event_from_zone_status(driver, device, zone_status, zb_rx) | ||||||||||||||||||||
| if device:supports_capability(capabilities.tamperAlert) then | ||||||||||||||||||||
| device:emit_event(zone_status:is_tamper_set() and capabilities.tamperAlert.tamper.detected() or capabilities.tamperAlert.tamper.clear()) | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function ias_zone_status_change_handler(driver, device, zb_rx) | ||||||||||||||||||||
| local zone_status = zb_rx.body.zcl_body.zone_status | ||||||||||||||||||||
| generate_event_from_zone_status(driver, device, zone_status, zb_rx) | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function send_siren_command(device, warning_mode, warning_siren_level, warning_duration, strobe_active, strobe_level) | ||||||||||||||||||||
| local siren_configuration | ||||||||||||||||||||
|
|
||||||||||||||||||||
| siren_configuration = SirenConfiguration(0x00) | ||||||||||||||||||||
| siren_configuration:set_warning_mode(warning_mode) | ||||||||||||||||||||
| siren_configuration:set_siren_level(warning_siren_level) | ||||||||||||||||||||
| siren_configuration:set_strobe(strobe_active) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| device:send( | ||||||||||||||||||||
| IASWD.server.commands.StartWarning( | ||||||||||||||||||||
| device, | ||||||||||||||||||||
| siren_configuration, | ||||||||||||||||||||
| data_types.Uint16(warning_duration), | ||||||||||||||||||||
| data_types.Uint8(ALARM_STROBE_DUTY_CYCLE), | ||||||||||||||||||||
| data_types.Enum8(strobe_level) | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function siren_switch_off_handler(driver, device, command) | ||||||||||||||||||||
| device:set_field(ALARM_COMMAND, alarm_command.OFF, {persist = true}) | ||||||||||||||||||||
| send_siren_command(device, WarningMode.STOP, IaswdLevel.LOW_LEVEL, DEFAULT_MAX_WARNING_DURATION, Strobe.NO_STROBE, IaswdLevel.LOW_LEVEL) | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local function siren_alarm_siren_handler(alarm_cmd, WarningMode, Strobe, strobe_level) | ||||||||||||||||||||
| return function(driver, device, command) | ||||||||||||||||||||
| device:set_field(ALARM_COMMAND, alarm_cmd, {persist = true}) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local sirenVolume_msg = tonumber(device.preferences.sirenVolume) | ||||||||||||||||||||
| local warning_duration = tonumber(device.preferences.warningDuration) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| send_siren_command(device, WarningMode , sirenVolume_msg == nil or IaswdLevel.VERY_HIGH_LEVEL ,warning_duration == nil or DEFAULT_MAX_WARNING_DURATION, Strobe, strobe_level) | ||||||||||||||||||||
|
Comment on lines
+74
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| device.thread:call_with_delay(warning_duration, function() -- Send command to switch from siren to off in the app when the siren is done | ||||||||||||||||||||
| if(device:get_field(ALARM_COMMAND) ~= alarm_command.OFF) then | ||||||||||||||||||||
| siren_switch_off_handler(driver, device, alarm_cmd) | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end) | ||||||||||||||||||||
| end | ||||||||||||||||||||
| end | ||||||||||||||||||||
|
|
||||||||||||||||||||
| local MultiIR_siren_driver = { | ||||||||||||||||||||
| NAME = "MultiIR Zigbee siren", | ||||||||||||||||||||
| lifecycle_handlers = { | ||||||||||||||||||||
| added = device_added, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| capability_handlers = { | ||||||||||||||||||||
| [capabilities.alarm.ID] = { | ||||||||||||||||||||
| [capabilities.alarm.commands.off.NAME] = siren_switch_off_handler, | ||||||||||||||||||||
| [capabilities.alarm.commands.siren.NAME] = siren_alarm_siren_handler(alarm_command.SIREN, WarningMode.BURGLAR, Strobe.NO_STROBE, IaswdLevel.LOW_LEVEL), | ||||||||||||||||||||
| [capabilities.alarm.commands.both.NAME] = siren_alarm_siren_handler(alarm_command.BOTH, WarningMode.BURGLAR, Strobe.USE_STROBE , IaswdLevel.VERY_HIGH_LEVEL), | ||||||||||||||||||||
| [capabilities.alarm.commands.strobe.NAME] = siren_alarm_siren_handler(alarm_command.STROBE, WarningMode.STOP, Strobe.USE_STROBE, IaswdLevel.VERY_HIGH_LEVEL) | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| [capabilities.switch.ID] = { | ||||||||||||||||||||
| [capabilities.switch.commands.on.NAME] = siren_alarm_siren_handler(alarm_command.BOTH, WarningMode.BURGLAR, Strobe.USE_STROBE , IaswdLevel.VERY_HIGH_LEVEL), | ||||||||||||||||||||
| [capabilities.switch.commands.off.NAME] = siren_switch_off_handler | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| zigbee_handlers = { | ||||||||||||||||||||
| cluster = { | ||||||||||||||||||||
| [IASZone.ID] = { | ||||||||||||||||||||
| [IASZone.client.commands.ZoneStatusChangeNotification.ID] = ias_zone_status_change_handler | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| attr = { | ||||||||||||||||||||
| [IASZone.ID] = { | ||||||||||||||||||||
| [IASZone.attributes.ZoneStatus.ID] = generate_event_from_zone_status | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| can_handle = require("MultiIR.can_handle"), | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return MultiIR_siren_driver | ||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: trailing whitespace