Add step functionality to Zigbee curtains using Common Handler.#3108
Add step functionality to Zigbee curtains using Common Handler.#3108zhangshen001 wants to merge 1 commit into
Conversation
| @@ -0,0 +1,16 @@ | |||
| id: stse.statelessWindowShadeLevelStep | |||
There was a problem hiding this comment.
Why do we need to define a proposed capability explicitly at edge driver?
| end | ||
|
|
||
| local function shade_level_report_handler(driver, device, value, zb_rx) | ||
| local latest_target_level = device:get_field(LATEST_TARGET_LEVEL) |
There was a problem hiding this comment.
Here what we can get is current position of window treatment, right?
There was a problem hiding this comment.
The common driver only clears the "LATEST_TARGET_LEVEL" state when the device reports its location and does not handle report-level events. The child driver is responsible for report-level processing and UI events. The report handlers of both drivers will be triggered and will not affect each other.
There was a problem hiding this comment.
Since the curtain position status has been updated, the target value is no longer used as a reference for position offset calculation, so LATEST_TARGET_LEVEL needs to be set to null.
| device:get_latest_state("main", capabilities.windowShadeLevel.ID, capabilities.windowShadeLevel.shadeLevel.NAME) or 0 | ||
|
|
||
| -- Calculate UI target_level (user's expected percentage) | ||
| local ui_target_level= utils.clamp_value(current_level + step, 0, 100) |
| { | ||
| name = "aqara", | ||
| mfr = "LUMI", | ||
| models = { "lumi.curtain", "lumi.curtain.v1", "lumi.curtain.aq2", "lumi.curtain.agl001", "lumi.curtain.acn002" }, |
| invert_level = true, | ||
| }, | ||
| { | ||
| name = "invert-lift-percentage", |
There was a problem hiding this comment.
If we must need these three parts, please consider to merge them
| -- Brand-specific configuration for window treatment devices | ||
| -- Supports statelessWindowShadeLevelStep capability | ||
|
|
||
| local BRAND_CONFIGS = { |
There was a problem hiding this comment.
Name file and variable using fingerprints
b89ff06 to
3573329
Compare
| -- Field keys for tracking target level and timeout timer | ||
| local LATEST_TARGET_LEVEL = "_latest_target_level" | ||
|
|
||
| -- Get brand configuration for a device |
There was a problem hiding this comment.
It's better to use 'fingerprint' into function name and comments
| -- Step shade level handler for statelessWindowShadeLevelStep capability | ||
| local function step_shade_level_handler(driver, device, command) | ||
| -- Get brand-specific configuration | ||
| local brand_config = get_brand_config(device) |
| end | ||
|
|
||
| local function shade_level_report_handler(driver, device, value, zb_rx) | ||
| local latest_target_level = device:get_field(LATEST_TARGET_LEVEL) |
There was a problem hiding this comment.
merge into one sentence and explain why it is required
ef2520e to
8acd43e
Compare
| local current_level = latest_target_level or | ||
| device:get_latest_state("main", capabilities.windowShadeLevel.ID, capabilities.windowShadeLevel.shadeLevel.NAME) or 0 |
There was a problem hiding this comment.
For example, if the curtain is initially at level 30 and receives a +10 command, setting the target_level to 40, and then receives a +2 command when the actual curtain position reaches 35, the current_level might still be 30. If the current_level were used as the baseline and the target_level were set to 32, the motor would reverse. Therefore, the target_level is calculated based on the saved LATEST_TARGET_LEVEL and is set to 42.
Check all that apply
Type of Change
Checklist
Description of Change
Summary of Completed Tests