Repository navigation
[Aqara] Roller Shade T1S #3292
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
seojune79
wants to merge
5
commits into
SmartThingsCommunity:main
Choose a base branch
from
seojune79:Aqara-Roller-Shade-T1S
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
[Aqara] Roller Shade T1S #3292
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
98b234a
Add Aqara Roller Shade T1S
seojune79 901759b
remove unnecessary code and fix minor errors
seojune79 3ce2a43
apply Aqara common functions
seojune79 b9bc5b4
read init state on shade stop instead of lift reports
seojune79 5d5b792
use base AnalogOutput handler and remove RemoveAllGroups
seojune79 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
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
6 changes: 5 additions & 1 deletion
6
drivers/SmartThings/zigbee-window-treatment/src/aqara/roller-shade/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
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
8 changes: 8 additions & 0 deletions
8
drivers/SmartThings/zigbee-window-treatment/src/aqara/roller-shade/sub_drivers.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,8 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local lazy_load_if_possible = require "lazy_load_subdriver" | ||
| local sub_drivers = { | ||
| lazy_load_if_possible("aqara.roller-shade.t1s"), | ||
| } | ||
| return sub_drivers |
11 changes: 11 additions & 0 deletions
11
drivers/SmartThings/zigbee-window-treatment/src/aqara/roller-shade/t1s/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,11 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function t1s_can_handle(opts, driver, device, ...) | ||
| if device:get_model() == "lumi.curtain.vagl02" then | ||
| return true, require("aqara.roller-shade.t1s") | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return t1s_can_handle |
186 changes: 186 additions & 0 deletions
186
drivers/SmartThings/zigbee-window-treatment/src/aqara/roller-shade/t1s/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,186 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local capabilities = require "st.capabilities" | ||
| local clusters = require "st.zigbee.zcl.clusters" | ||
| local cluster_base = require "st.zigbee.cluster_base" | ||
| local FrameCtrl = require "st.zigbee.zcl.frame_ctrl" | ||
| local data_types = require "st.zigbee.data_types" | ||
| local aqara_utils = require "aqara/aqara_utils" | ||
| local window_treatment_utils = require "window_treatment_utils" | ||
|
|
||
| local WindowCovering = clusters.WindowCovering | ||
| local AnalogOutput = clusters.AnalogOutput | ||
|
|
||
| local initializedStateWithGuide = capabilities["stse.initializedStateWithGuide"] | ||
| local reverseRollerShadeDir = capabilities["stse.reverseRollerShadeDir"] | ||
| local shadeRotateState = capabilities["stse.shadeRotateState"] | ||
| local setRotateStateCommandName = "setRotateState" | ||
|
|
||
| local MULTISTATE_CLUSTER_ID = 0x0013 | ||
| local MULTISTATE_ATTRIBUTE_ID = 0x0055 | ||
| local INIT_STATE_ATTRIBUTE_ID = 0x0407 | ||
| local DIRECTION_ATTRIBUTE_ID = 0x0400 | ||
|
|
||
| local ROTATE_UP_VALUE = 0x0006 | ||
| local ROTATE_DOWN_VALUE = 0x0005 | ||
| local SHADE_STATE_STOP = 2 | ||
| local SHADE_STATE_OPEN = 1 | ||
| local SHADE_STATE_CLOSE = 0 | ||
| local SHADE_STATE_BLOCKED = 4 | ||
|
|
||
| local function is_not_init(device) | ||
|
cjswedes marked this conversation as resolved.
Resolved
|
||
| -- True until the device reports that its travel points have been initialized | ||
| return device:get_latest_state("main", initializedStateWithGuide.ID, initializedStateWithGuide.initializedStateWithGuide.NAME) ~= | ||
| initializedStateWithGuide.initializedStateWithGuide.initialized.NAME | ||
| end | ||
|
cjswedes marked this conversation as resolved.
Resolved
|
||
|
|
||
| local function window_shade_level_cmd(driver, device, command) | ||
| -- Cannot be controlled if not initialized | ||
| if is_not_init(device) then return end | ||
| aqara_utils.shade_level_cmd(driver, device, command) | ||
| end | ||
|
|
||
| local function window_shade_open_cmd(driver, device, command) | ||
| -- Cannot be controlled if not initialized | ||
| if is_not_init(device) then return end | ||
| device:send_to_component(command.component, WindowCovering.server.commands.GoToLiftPercentage(device, 100)) | ||
| end | ||
|
|
||
| local function window_shade_close_cmd(driver, device, command) | ||
| -- Cannot be controlled if not initialized | ||
| if is_not_init(device) then return end | ||
| device:send_to_component(command.component, WindowCovering.server.commands.GoToLiftPercentage(device, 0)) | ||
| end | ||
|
|
||
| local function set_rotate_command_handler(driver, device, command) | ||
| device:emit_event(shadeRotateState.rotateState.idle({ state_change = true, visibility = { displayed = false } })) -- update UI | ||
|
|
||
| -- Cannot be controlled if not initialized | ||
| if is_not_init(device) then return end | ||
| local state = command.args.state | ||
| if state == "rotateUp" then | ||
| local message = cluster_base.write_manufacturer_specific_attribute(device, MULTISTATE_CLUSTER_ID, | ||
| MULTISTATE_ATTRIBUTE_ID, aqara_utils.MFG_CODE, data_types.Uint16, ROTATE_UP_VALUE) | ||
| message.body.zcl_header.frame_ctrl = FrameCtrl(0x10) | ||
| device:send(message) | ||
| elseif state == "rotateDown" then | ||
| local message = cluster_base.write_manufacturer_specific_attribute(device, MULTISTATE_CLUSTER_ID, | ||
| MULTISTATE_ATTRIBUTE_ID, aqara_utils.MFG_CODE, data_types.Uint16, ROTATE_DOWN_VALUE) | ||
| message.body.zcl_header.frame_ctrl = FrameCtrl(0x10) | ||
| device:send(message) | ||
| end | ||
| end | ||
|
|
||
| local function do_refresh(driver, device) | ||
| device:send(AnalogOutput.attributes.PresentValue:read(device)) | ||
| device:send(cluster_base.read_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID, INIT_STATE_ATTRIBUTE_ID, aqara_utils.MFG_CODE)) | ||
| end | ||
|
|
||
| local function init_state_handler(driver, device, value, zb_rx) | ||
| local state = value.value == 0x02 and initializedStateWithGuide.initializedStateWithGuide.initialized() or | ||
| initializedStateWithGuide.initializedStateWithGuide.notInitialized() | ||
| device:emit_event(state) | ||
| end | ||
|
|
||
| -- The position of this device is reported through the present value of the analog output | ||
| -- cluster, where 0 is fully closed and 100 is fully open. The lift percentage of the window | ||
| -- covering cluster is reported with the opposite polarity (100% = fully closed), so it is | ||
| -- ignored here to keep the parent Aqara handler from emitting an inverted shade level. | ||
|
cjswedes marked this conversation as resolved.
Resolved
|
||
| local function current_position_lift_percentage_handler(driver, device, value, zb_rx) | ||
| end | ||
|
cjswedes marked this conversation as resolved.
Resolved
|
||
|
|
||
| local function shade_state_report_handler(driver, device, value, zb_rx) | ||
| local state = value.value | ||
| -- update state ui | ||
| if state == SHADE_STATE_STOP or state == SHADE_STATE_BLOCKED then | ||
| -- read shade position to update the UI | ||
| device:send(AnalogOutput.attributes.PresentValue:read(device)) | ||
| -- The device does not report the init state when its travel points have been set, so it is | ||
| -- re-read once each time the shade stops while the device is still not initialized. | ||
| if is_not_init(device) then | ||
| device:send(cluster_base.read_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID, | ||
| INIT_STATE_ATTRIBUTE_ID, aqara_utils.MFG_CODE)) | ||
| end | ||
| elseif state == SHADE_STATE_OPEN then | ||
| device:emit_event(capabilities.windowShade.windowShade.opening()) | ||
| elseif state == SHADE_STATE_CLOSE then | ||
| device:emit_event(capabilities.windowShade.windowShade.closing()) | ||
| end | ||
| end | ||
|
|
||
| local function device_info_changed(driver, device, event, args) | ||
| if device.preferences ~= nil then | ||
| local reverseRollerShadeDirPrefValue = device.preferences[reverseRollerShadeDir.ID] | ||
| if reverseRollerShadeDirPrefValue ~= nil and | ||
| reverseRollerShadeDirPrefValue ~= args.old_st_store.preferences[reverseRollerShadeDir.ID] then | ||
| device:send(cluster_base.write_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID, | ||
| DIRECTION_ATTRIBUTE_ID, aqara_utils.MFG_CODE, data_types.Boolean, reverseRollerShadeDirPrefValue)) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local function device_added(driver, device) | ||
| device:emit_event(capabilities.windowShade.supportedWindowShadeCommands({ "open", "close", "pause" }, | ||
| { visibility = { displayed = false } })) | ||
| window_treatment_utils.emit_event_if_latest_state_missing(device, "main", capabilities.windowShadeLevel, | ||
| capabilities.windowShadeLevel.shadeLevel.NAME, capabilities.windowShadeLevel.shadeLevel(0)) | ||
| window_treatment_utils.emit_event_if_latest_state_missing(device, "main", capabilities.windowShade, | ||
| capabilities.windowShade.windowShade.NAME, capabilities.windowShade.windowShade.closed()) | ||
| window_treatment_utils.emit_event_if_latest_state_missing(device, "main", initializedStateWithGuide, | ||
| initializedStateWithGuide.initializedStateWithGuide.NAME, | ||
| initializedStateWithGuide.initializedStateWithGuide.notInitialized()) | ||
| device:emit_event(shadeRotateState.rotateState.idle({ visibility = { displayed = false } })) | ||
| device:send(cluster_base.write_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID, | ||
| aqara_utils.PRIVATE_ATTRIBUTE_ID, aqara_utils.MFG_CODE, data_types.Uint8, 1)) | ||
|
|
||
| -- The direction is stored on the device and survives a re-pairing, so sync it with the preference | ||
| local reverse = device.preferences ~= nil and device.preferences[reverseRollerShadeDir.ID] == true | ||
| device:send(cluster_base.write_manufacturer_specific_attribute(device, aqara_utils.PRIVATE_CLUSTER_ID, | ||
| DIRECTION_ATTRIBUTE_ID, aqara_utils.MFG_CODE, data_types.Boolean, reverse)) | ||
| end | ||
|
|
||
| local function do_configure(self, device) | ||
| device:configure() | ||
| do_refresh(self, device) | ||
| end | ||
|
|
||
| local aqara_roller_shade_t1s_handler = { | ||
| NAME = "Aqara T1S Blinder Controller Handler", | ||
| lifecycle_handlers = { | ||
| added = device_added, | ||
| doConfigure = do_configure, | ||
| infoChanged = device_info_changed | ||
| }, | ||
| capability_handlers = { | ||
| [capabilities.windowShadeLevel.ID] = { | ||
| [capabilities.windowShadeLevel.commands.setShadeLevel.NAME] = window_shade_level_cmd | ||
| }, | ||
| [capabilities.windowShade.ID] = { | ||
| [capabilities.windowShade.commands.open.NAME] = window_shade_open_cmd, | ||
| [capabilities.windowShade.commands.close.NAME] = window_shade_close_cmd | ||
| }, | ||
| [shadeRotateState.ID] = { | ||
| [setRotateStateCommandName] = set_rotate_command_handler | ||
| }, | ||
| [capabilities.refresh.ID] = { | ||
| [capabilities.refresh.commands.refresh.NAME] = do_refresh | ||
| } | ||
| }, | ||
| zigbee_handlers = { | ||
| attr = { | ||
| [aqara_utils.PRIVATE_CLUSTER_ID] = { | ||
| [INIT_STATE_ATTRIBUTE_ID] = init_state_handler, | ||
| }, | ||
| [WindowCovering.ID] = { | ||
| [WindowCovering.attributes.CurrentPositionLiftPercentage.ID] = current_position_lift_percentage_handler | ||
| }, | ||
| [MULTISTATE_CLUSTER_ID] = { | ||
| [MULTISTATE_ATTRIBUTE_ID] = shade_state_report_handler | ||
| } | ||
| } | ||
| }, | ||
| can_handle = require("aqara.roller-shade.t1s.can_handle"), | ||
| } | ||
|
|
||
| return aqara_roller_shade_t1s_handler | ||
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.