-
Notifications
You must be signed in to change notification settings - Fork 539
add firstled-io_M4S4BAC #2971
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:firstled-io_M4S4BAC
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
add firstled-io_M4S4BAC #2971
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
39 changes: 39 additions & 0 deletions
39
drivers/SmartThings/zigbee-switch/profiles/switch-button-light-restore-wireless.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,39 @@ | ||
| name: switch-button-light-restore-wireless | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: switch | ||
| version: 1 | ||
| - id: button | ||
| version: 1 | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: RemoteController | ||
| preferences: | ||
| - title: "背光灯(backlight/백라이트)" | ||
| name: backlight | ||
| description: "背光灯(backlight/백라이트)" | ||
| required: false | ||
| preferenceType: enumeration | ||
| definition: | ||
| options: | ||
| 0: "关闭(close/닫다)" | ||
| 1: "打开(open/열다)" | ||
| 2: "人体移动检测(human detection/인체 움직임 검사)" | ||
| default: 2 | ||
| - title: "开关上电状态(relay powerOn state)" | ||
| name: powerOnStatus | ||
| description: "开关上电状态(relay powerOn state/릴레이 초기 동작 상태)" | ||
| required: false | ||
| preferenceType: enumeration | ||
| definition: | ||
| options: | ||
| 0: "关闭(close/닫다)" | ||
| 1: "打开(open/열다)" | ||
| 2: "恢复记忆状态(restore/복원)" | ||
| default: 2 | ||
| - preferenceId: stse.changeToWirelessSwitch | ||
| explicit: true |
17 changes: 17 additions & 0 deletions
17
drivers/SmartThings/zigbee-switch/profiles/switch-button-wireless.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,17 @@ | ||
| name: switch-button-wireless | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: switch | ||
| version: 1 | ||
| - id: button | ||
| version: 1 | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: RemoteController | ||
| preferences: | ||
| - preferenceId: stse.changeToWirelessSwitch | ||
| explicit: true |
12 changes: 12 additions & 0 deletions
12
drivers/SmartThings/zigbee-switch/src/firstled-io/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,12 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| return function(opts, driver, device) | ||
| local FINGERPRINTS = require("firstled-io.fingerprints") | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then | ||
| return true, require("firstled-io") | ||
| end | ||
| end | ||
| return false | ||
| end |
6 changes: 6 additions & 0 deletions
6
drivers/SmartThings/zigbee-switch/src/firstled-io/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 = "FIRSTLED", model = "M4S4BAC", buttons = 4 , children = 4, child_profile = "switch-button-wireless" } | ||
| } |
164 changes: 164 additions & 0 deletions
164
drivers/SmartThings/zigbee-switch/src/firstled-io/init.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,164 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local device_lib = require "st.device" | ||
| local capabilities = require "st.capabilities" | ||
| local cluster_base = require "st.zigbee.cluster_base" | ||
| local data_types = require "st.zigbee.data_types" | ||
| local zcl_clusters = require "st.zigbee.zcl.clusters" | ||
|
|
||
| local Scenes = zcl_clusters.Scenes | ||
| local PRIVATE_CLUSTER_ID = 0xFCCA | ||
| local MFG_CODE = 0x1235 | ||
| local FINGERPRINTS = require("firstled-io.fingerprints") | ||
|
|
||
| local preference_map = { | ||
| ["backlight"] = { | ||
| cluster_id = PRIVATE_CLUSTER_ID, | ||
| attribute_id = 0x0000, | ||
| mfg_code = MFG_CODE, | ||
| data_type = data_types.Uint8, | ||
| }, | ||
| ["powerOnStatus"] = { | ||
| cluster_id = PRIVATE_CLUSTER_ID, | ||
| attribute_id = 0x0001, | ||
| mfg_code = MFG_CODE, | ||
| data_type = data_types.Uint8, | ||
| }, | ||
| ["stse.changeToWirelessSwitch"] = { | ||
| cluster_id = PRIVATE_CLUSTER_ID, | ||
| attribute_id = 0x0002, | ||
| mfg_code = MFG_CODE, | ||
| data_type = data_types.Boolean | ||
| } | ||
| } | ||
|
|
||
| local function device_info_changed(driver, device, event, args) | ||
| local preferences = device.preferences | ||
| local old_preferences = args.old_st_store.preferences | ||
| if preferences ~= nil then | ||
| for id, attr in pairs(preference_map) do | ||
| local old_value = old_preferences[id] | ||
| local value = preferences[id] | ||
| if value ~= nil and value ~= old_value then | ||
| if attr.data_type == data_types.Uint8 then | ||
| value = tonumber(value) | ||
| end | ||
| device:send(cluster_base.write_manufacturer_specific_attribute(device, attr.cluster_id, attr.attribute_id, | ||
| attr.mfg_code, attr.data_type, value)) | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local function get_children_amount(device) | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_model() == fingerprint.model then | ||
| return fingerprint.children | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local function get_button_amount(device) | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_model() == fingerprint.model then | ||
| return fingerprint.buttons | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local function get_child_profile_name(device) | ||
| for _, fingerprint in ipairs(FINGERPRINTS) do | ||
| if device:get_model() == fingerprint.model then | ||
| return fingerprint.child_profile | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local function find_child(parent, ep_id) | ||
| return parent:get_child_by_parent_assigned_key(string.format("%02X", ep_id)) | ||
| end | ||
|
|
||
| local function device_added(driver, device) | ||
| -- Only create children for the actual Zigbee device and not the children | ||
| if device.network_type == device_lib.NETWORK_TYPE_ZIGBEE then | ||
| local children_amount = get_children_amount(device) | ||
| if children_amount >= 2 then | ||
| for i = 2, children_amount, 1 do | ||
| if find_child(device, i) == nil then | ||
| local name = string.format("%s%d", string.sub(device.label, 0, -2), i) | ||
| local child_profile = get_child_profile_name(device) | ||
| local metadata = { | ||
| type = "EDGE_CHILD", | ||
| label = name, | ||
| profile = child_profile, | ||
| parent_device_id = device.id, | ||
| parent_assigned_child_key = string.format("%02X", i), | ||
| vendor_provided_label = name | ||
| } | ||
| driver:try_create_device(metadata) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| -- Create Button if necessary | ||
| local button_amount = get_button_amount(device) | ||
| if button_amount >= 1 then | ||
| for i = children_amount + 1, children_amount + button_amount, 1 do | ||
| if find_child(device, i) == nil then | ||
| local name = string.format("%s%d", string.sub(device.label, 0, -2), i) | ||
| local metadata = { | ||
| type = "EDGE_CHILD", | ||
| label = name, | ||
| profile = "button", | ||
| parent_device_id = device.id, | ||
| parent_assigned_child_key = string.format("%02X", i), | ||
| vendor_provided_label = name, | ||
| } | ||
| driver:try_create_device(metadata) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| -- for wireless button | ||
| device:emit_event(capabilities.button.numberOfButtons({ value = children_amount }, | ||
| { visibility = { displayed = false } })) | ||
|
|
||
| elseif device.network_type == "DEVICE_EDGE_CHILD" then | ||
| device:emit_event(capabilities.button.numberOfButtons({ value = 1 }, | ||
| { visibility = { displayed = false } })) | ||
| end | ||
| device:emit_event(capabilities.button.supportedButtonValues({ "pushed" }, | ||
| { visibility = { displayed = false } })) | ||
| end | ||
|
|
||
| local function scenes_cluster_handler(driver, device, zb_rx) | ||
| device:emit_event_for_endpoint(zb_rx.address_header.src_endpoint.value, | ||
| capabilities.button.button.pushed({ state_change = true })) | ||
| end | ||
|
|
||
| local function device_init(self, device) | ||
| -- for multiple switch | ||
| if device.network_type == device_lib.NETWORK_TYPE_ZIGBEE then | ||
| device:set_find_child(find_child) | ||
| end | ||
| end | ||
|
|
||
| local firstled_switch_handler = { | ||
| NAME = "FIRSTLED Switch Handler", | ||
| lifecycle_handlers = { | ||
| init = device_init, | ||
| added = device_added, | ||
| infoChanged = device_info_changed | ||
| }, | ||
| zigbee_handlers = { | ||
| cluster = { | ||
| [Scenes.ID] = { | ||
| [Scenes.server.commands.RecallScene.ID] = scenes_cluster_handler, | ||
| } | ||
| } | ||
| }, | ||
| can_handle = require("firstled-io.can_handle"), | ||
| } | ||
|
|
||
| return firstled_switch_handler | ||
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.
Uh oh!
There was an error while loading. Please reload this page.