Update matter window covering edge driver#3052
Conversation
571f3d8 to
efdf5b3
Compare
|
Edge driver development for R2 new feature (https://smartthings.atlassian.net/browse/CHAD-18661) |
d97b8d2 to
c659987
Compare
Signed-off-by: Hong Ye/MDE Lab /SRC-Nanjing/Staff Engineer/Samsung Electronics <hong.ye@samsung.com>
c659987 to
f5b95e2
Compare
hcarter-775
left a comment
There was a problem hiding this comment.
Seems like the new fields may be unnecessary, and may be adding some unnecessary complexity
| [capabilities.windowShadeLevel.commands.setShadeLevel.NAME] = handle_shade_level, | ||
| }, | ||
| [capabilities.statelessWindowShadeLevelStep.ID] = { | ||
| [capabilities.statelessWindowShadeLevelStep.commands.stepShadeLevel.NAME] = window_shade_step_level_cmd |
There was a problem hiding this comment.
| [capabilities.statelessWindowShadeLevelStep.commands.stepShadeLevel.NAME] = window_shade_step_level_cmd | |
| [capabilities.statelessWindowShadeLevelStep.commands.stepShadeLevel.NAME] = handle_step_shade_level |
let's keep the same language consistency
|
|
||
| local matter_driver = MatterDriver("matter-window-covering", matter_driver_template) | ||
| matter_driver:run() | ||
| matter_driver:run() No newline at end of file |
There was a problem hiding this comment.
we shouldn't remove the newline
|
|
||
| -- capability handlers | ||
| local function handle_preset(driver, device, cmd) | ||
| device:set_field(LATEST_TARGET_LEVEL, nil) |
There was a problem hiding this comment.
why are we setting this to nil in every handler?
| local target_level = current_level + step | ||
| if target_level > 100 then target_level = 100 | ||
| elseif target_level < 0 then target_level = 0 | ||
| end |
There was a problem hiding this comment.
| local target_level = current_level + step | |
| if target_level > 100 then target_level = 100 | |
| elseif target_level < 0 then target_level = 0 | |
| end | |
| local target_level = st_utils.clamp_value(current_level + step, 0, 100) |
and then you can do local st_utils = require "st.utils" at the top of the file.
| -- Matter uses inverted logic (like IKEA) | ||
| -- User level: 0=closed, 100=open | ||
| -- Matter level: 10000=open, 0=closed (in percent100ths) |
| local lift_percentage_value = 100 - target_level | ||
| local hundredths_lift_percentage = lift_percentage_value * 100 | ||
|
|
||
| local endpoint_id = device:component_to_endpoint(cmd.component) | ||
| local req = clusters.WindowCovering.server.commands.GoToLiftPercentage( | ||
| device, endpoint_id, hundredths_lift_percentage | ||
| ) | ||
| device:send(req) |
There was a problem hiding this comment.
we need to handle the case where the device is in the reverse mode
| end | ||
|
|
||
| -- Update tracking state | ||
| device:set_field(LATEST_TARGET_LEVEL, target_level) |
There was a problem hiding this comment.
why do we even need this field? What purpose is it really serving here?
| -- Step control logic | ||
| local target_level_field = device:get_field(LATEST_TARGET_LEVEL) | ||
| if target_level_field and attribute == capabilities.windowShadeLevel.shadeLevel then | ||
| -- Allow ±1 degree tolerance for reaching target | ||
| if math.abs(position - target_level_field) <= TARGET_REACH_TOLERANCE then | ||
| -- Device reached target position, clear target marker and timeout timer | ||
| device:set_field(LATEST_TARGET_LEVEL, nil) | ||
| local timer = device:get_field(TARGET_LEVEL_TIME_OUT) | ||
| if timer ~= nil then | ||
| device.thread:cancel_timer(timer) | ||
| device:set_field(TARGET_LEVEL_TIME_OUT, nil) | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
I don't think I understand why this is useful. The command will send the device here anyway? This just removes the field without changing anything as far as I can see
| device.thread:cancel_timer(timer) | ||
| device:set_field(TARGET_LEVEL_TIME_OUT, nil) | ||
| end | ||
| end |
There was a problem hiding this comment.
I don't see why this is needed. kinda repeating myself here, but I'm not really sure what this logic is gaining for us.
| version: 1 | ||
| - id: windowShadeTiltLevel | ||
| version: 1 | ||
| - id: statelessWindowShadeLevelStep |
There was a problem hiding this comment.
My initial thought is we'd only add the new capability to profiles that have the windowShadeLevel capability, and so it shouldn't be added to all these profiles that have windowShadeTiltLevel and not windowShadeLevel. In other words, we wouldn't support the stateless step commands on shades that only support tilt. If we want to do that in the future we should add a statelessWindowShadeTiltStep capability, but that isn't in scope for the current project.
| - id: statelessWindowShadeLevelStep | ||
| version: 1 |
There was a problem hiding this comment.
I might recommend moving the statelessWindowShadeLevelStep capability just below the windowShadeLevel capability in all cases, for consistency. A few of these profile updates have the new capability in different spots.
Check all that apply
Type of Change
Checklist
Description of Change
Summary of Completed Tests