Repository navigation
Zigbee window treatment: extend step timeout, use input step component #3319
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ utils.PRESET_LEVEL_KEY = "_presetLevel" | |
| -- within a short time frame while preventing indefinite accumulation. | ||
| local LATEST_TARGET_LEVEL = "_latestTargetLevel" | ||
| -- Timeout in seconds for the stateless step accumulation window | ||
| local TARGET_LEVEL_TIME_OUT_SECONDS = 15 | ||
| local TARGET_LEVEL_TIME_OUT_SECONDS = 120 | ||
| -- Field name for the timer that clears LATEST_TARGET_LEVEL after timeout | ||
| local TARGET_LEVEL_TIME_OUT = "_targetLevelTimeOut" | ||
|
|
||
|
|
@@ -48,17 +48,18 @@ utils.step_shade_level_handler = function(driver, device, command) | |
|
|
||
| -- Step from the latest target level if it exists, or from the current shade level | ||
| local latest_target_level = device:get_field(LATEST_TARGET_LEVEL) or | ||
| device:get_latest_state("main", capabilities.windowShadeLevel.ID, capabilities.windowShadeLevel.shadeLevel.NAME, 0) | ||
| device:get_latest_state(command.component, capabilities.windowShadeLevel.ID, capabilities.windowShadeLevel.shadeLevel.NAME, 0) | ||
| local new_target_level = st_utils.clamp_value(latest_target_level + step, 0, 100) | ||
|
|
||
| -- Cancel any previous timer and set a 15 second timeout timer to ensure LATEST_TARGET_LEVEL is cleared | ||
| -- Cancel any previous timer and set a 120 second timeout timer to ensure LATEST_TARGET_LEVEL is cleared | ||
| -- This is to prevent the stateless step from accumulating indefinitely, while ensuring that a single | ||
| -- "scroll" action can accumulate multiple steps within a short time frame | ||
| if device:get_field(TARGET_LEVEL_TIME_OUT) then | ||
| device.thread:cancel_timer(device:get_field(TARGET_LEVEL_TIME_OUT)) | ||
| end | ||
| local timer = device.thread:call_with_delay(TARGET_LEVEL_TIME_OUT_SECONDS, function(d) | ||
| device:set_field(LATEST_TARGET_LEVEL, nil) | ||
| device:set_field(TARGET_LEVEL_TIME_OUT, nil) | ||
|
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. This is the only place the target timeout and target level is cleared. You should clear it from the open, close, preset, and setShadeLevel handlers also (which is what matter does). Its needed to avoid a situation where subsequent commands dont have stale data. Example (all within the 2 min window):
Contributor
Author
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. Matter is much more comprehensive, I agree. I put a lot of work into making that driver tick in tune, haha. However, I do not think adding a bunch of handling like that is particular helpful, as the case you described is fairly unlikely in my opinion. I would prefer to track something like you're describing, a more comprehensive state-tracking system, in some kind of follow up. One big difference of Matter, for example, is that there aren't 10 subdrivers that might override open/close, etc in various ways. This basically is just a cleanup commit, to actually nil out what should be unset anyway, but just wasn't. |
||
| end) | ||
| device:set_field(TARGET_LEVEL_TIME_OUT, timer) | ||
| device:set_field(LATEST_TARGET_LEVEL, new_target_level) | ||
|
|
||
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.
This seems excessively long. What blinds actually take 2 minutes to move through their full range? Was this from a testing situation?
Uh oh!
There was an error while loading. Please reload this page.
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.
It definitely can take over a minute, especially to go 0-100 -- to clarify, if the device reaches the final state, it will stop this timer. So it really is just a backup, catchall. I recall Ikea takes a long time. This is mostly cleanup while investigating improvements while I'm doing Zwave.