-
Notifications
You must be signed in to change notification settings - Fork 529
add MultiIR Smart button MIR-SO100 #2862
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_smart_button_MIR-SO100
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
13 changes: 13 additions & 0 deletions
13
drivers/SmartThings/zigbee-button/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-button/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-SO100" } | ||
| } |
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,39 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
|
|
||
| local zcl_clusters = require "st.zigbee.zcl.clusters" | ||
| local capabilities = require "st.capabilities" | ||
| local button_utils = require "button_utils" | ||
| local log = require "log" | ||
|
|
||
| local IASZone = zcl_clusters.IASZone | ||
| local PRIVATE_CMD_ID = 0xF1 | ||
|
|
||
| local function ias_zone_private_cmd_handler(self, device, zb_rx) | ||
| local cmd_data = zb_rx.body.zcl_body.body_bytes:byte(1) | ||
| if cmd_data == 0 then | ||
| device:emit_event(capabilities.button.button.pushed({state_change = true})) | ||
| elseif cmd_data == 1 then | ||
| device:emit_event(capabilities.button.button.double({state_change = true})) | ||
| elseif cmd_data == 0x80 then | ||
| device:emit_event(capabilities.button.button.held({state_change = true})) | ||
| else | ||
| log.info("ias_zone_private_cmd Unknown value",zb_rx.body.zcl_body.body_bytes:byte(1)) | ||
| end | ||
| end | ||
|
|
||
| local MultiIR_Emergency_Button = { | ||
| NAME = "MultiIR Emergency Button", | ||
| zigbee_handlers = { | ||
| cluster = { | ||
| [IASZone.ID] = { | ||
| [PRIVATE_CMD_ID] = ias_zone_private_cmd_handler | ||
| } | ||
| } | ||
| }, | ||
| sub_drivers = {}, | ||
| can_handle = require("MultiIR.can_handle"), | ||
| } | ||
|
|
||
| return MultiIR_Emergency_Button | ||
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
133 changes: 133 additions & 0 deletions
133
drivers/SmartThings/zigbee-button/src/test/test_multiir_smart_button.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,133 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| -- Mock out globals | ||
| local capabilities = require "st.capabilities" | ||
| local clusters = require "st.zigbee.zcl.clusters" | ||
| local t_utils = require "integration_test.utils" | ||
| local test = require "integration_test" | ||
| local zigbee_test_utils = require "integration_test.zigbee_test_utils" | ||
|
|
||
| local IASZone = clusters.IASZone | ||
|
|
||
| local button_attr = capabilities.button.button | ||
|
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. luacheck: Remove this line |
||
| local PRIVATE_CMD_ID = 0xF1 | ||
|
|
||
| local mock_device = test.mock_device.build_test_zigbee_device( | ||
| { | ||
| profile = t_utils.get_profile_definition("one-button-battery.yml"), | ||
| zigbee_endpoints = { | ||
| [1] = { | ||
| id = 1, | ||
| manufacturer = "MultIR", | ||
| model = "MIR-SO100", | ||
| server_clusters = {0x0000, 0x0001, 0x0003, 0x0020, 0x0500, 0x0B05} | ||
| } | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| zigbee_test_utils.prepare_zigbee_env_info() | ||
| local function test_init() | ||
| test.mock_device.add_test_device(mock_device) | ||
| end | ||
|
|
||
| test.set_test_init_function(test_init) | ||
|
|
||
|
|
||
|
|
||
| test.register_coroutine_test( | ||
| "added lifecycle event", | ||
| function() | ||
| -- The initial button pushed event should be send during the device's first time onboarding | ||
| test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" }) | ||
| test.socket.capability:__set_channel_ordering("relaxed") | ||
| test.socket.capability:__expect_send( | ||
| mock_device:generate_test_message( | ||
| "main", | ||
| capabilities.button.supportedButtonValues({ "pushed","held","double" }, { visibility = { displayed = false } }) | ||
| ) | ||
| ) | ||
| test.socket.capability:__expect_send( | ||
| mock_device:generate_test_message( | ||
| "main", | ||
| capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } }) | ||
| ) | ||
| ) | ||
| test.socket.capability:__expect_send({ | ||
| mock_device.id, | ||
| { | ||
| capability_id = "button", component_id = "main", | ||
| attribute_id = "button", state = { value = "pushed" } | ||
| } | ||
| }) | ||
| -- Avoid sending the initial button pushed event after driver switch-over, as the switch-over event itself re-triggers the added lifecycle. | ||
| test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" }) | ||
| test.socket.capability:__set_channel_ordering("relaxed") | ||
| test.socket.capability:__expect_send( | ||
| mock_device:generate_test_message( | ||
| "main", | ||
| capabilities.button.supportedButtonValues({ "pushed","held","double" }, { visibility = { displayed = false } }) | ||
| ) | ||
| ) | ||
| test.socket.capability:__expect_send( | ||
| mock_device:generate_test_message( | ||
| "main", | ||
| capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } }) | ||
| ) | ||
| ) | ||
| end, | ||
| { | ||
| min_api_version = 19 | ||
| } | ||
| ) | ||
|
|
||
| test.register_message_test( | ||
| "IASZone cmd 0xF1 0x00 are handled", | ||
| { | ||
| { | ||
| channel = "zigbee", | ||
| direction = "receive", | ||
| message = { mock_device.id, zigbee_test_utils.build_custom_command_id(mock_device, IASZone.ID, PRIVATE_CMD_ID, 0x0000, "\x00", 0x01) } | ||
| }, | ||
| { | ||
| channel = "capability", | ||
| direction = "send", | ||
| message = mock_device:generate_test_message("main", capabilities.button.button.pushed({state_change = true})) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| test.register_message_test( | ||
| "IASZone cmd 0xF1 0x01 are handled", | ||
| { | ||
| { | ||
| channel = "zigbee", | ||
| direction = "receive", | ||
| message = { mock_device.id, zigbee_test_utils.build_custom_command_id(mock_device, IASZone.ID, PRIVATE_CMD_ID, 0x0000, "\x01", 0x01) } | ||
| }, | ||
| { | ||
| channel = "capability", | ||
| direction = "send", | ||
| message = mock_device:generate_test_message("main", capabilities.button.button.double({state_change = true})) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| test.register_message_test( | ||
| "IASZone cmd 0xF1 0x01 are handled", | ||
| { | ||
| { | ||
| channel = "zigbee", | ||
| direction = "receive", | ||
| message = { mock_device.id, zigbee_test_utils.build_custom_command_id(mock_device, IASZone.ID, PRIVATE_CMD_ID, 0x0000, "\x80", 0x01) } | ||
| }, | ||
| { | ||
| channel = "capability", | ||
| direction = "send", | ||
| message = mock_device:generate_test_message("main", capabilities.button.button.held({state_change = true})) | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| test.run_registered_tests() | ||
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.
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.
luacheck: Remove this and it should be good to go