From 3701671e0dd61d2139c4309e02487bf432260706 Mon Sep 17 00:00:00 2001 From: nickolas-deboom <158304111+nickolas-deboom@users.noreply.github.com> Date: Fri, 17 Jan 2025 11:53:37 -0600 Subject: [PATCH] Update drivers/SmartThings/matter-window-covering/src/init.lua Co-authored-by: Harrison Carter <137556605+hcarter-775@users.noreply.github.com> --- .../matter-window-covering/src/init.lua | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/SmartThings/matter-window-covering/src/init.lua b/drivers/SmartThings/matter-window-covering/src/init.lua index b38d89f69d..ec2597d68e 100644 --- a/drivers/SmartThings/matter-window-covering/src/init.lua +++ b/drivers/SmartThings/matter-window-covering/src/init.lua @@ -171,43 +171,42 @@ local current_pos_handler = function(attribute) local lift_position = device:get_field(CURRENT_LIFT) local tilt_position = device:get_field(CURRENT_TILT) - -- Update the window shade status according to the lift and tilt positions. +-- Update the window shade status according to the lift and tilt positions. -- LIFT TILT Window Shade + -- 100 any Open + -- 1-99 any Partially Open + -- 0 1-100 Partially Open -- 0 nil Closed -- 0 0 Closed - -- 0 1-100 Partially Open - -- 1-99 any Partially Open - -- 100 any Open - -- nil 0 Closed - -- nil 1-99 Partially Open -- nil 100 Open + -- nil 1-99 Partially Open + -- nil 0 Closed -- Note that lift or tilt may be nil if either the window shade does not -- support them or if they haven't been received from a device report yet. - if lift_position ~= nil then - if lift_position == 0 then - if tilt_position == nil or tilt_position == 0 then - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.closed()) - else - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.partially_open()) - end - elseif lift_position > 0 and lift_position < 100 then - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.partially_open()) - elseif lift_position == 100 then + + if lift_position == nil then + if tilt_position == nil or tilt_position == 0 then + device:emit_event_for_endpoint(ib.endpoint_id, windowShade.closed()) + elseif tilt_position == 100 then device:emit_event_for_endpoint(ib.endpoint_id, windowShade.open()) else - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.unknown()) + device:emit_event_for_endpoint(ib.endpoint_id, windowShade.partially_open()) end - else - if tilt_position == 0 then + + elseif lift_position == 100 then + device:emit_event_for_endpoint(ib.endpoint_id, windowShade.open()) + + elseif lift_position > 0 then + device:emit_event_for_endpoint(ib.endpoint_id, windowShade.partially_open()) + + elseif lift_position == 0 then + if tilt_position == nil or tilt_position == 0 then device:emit_event_for_endpoint(ib.endpoint_id, windowShade.closed()) - elseif tilt_position > 0 and tilt_position < 100 then + elseif tilt_position > 0 then device:emit_event_for_endpoint(ib.endpoint_id, windowShade.partially_open()) - elseif tilt_position == 100 then - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.open()) - else - device:emit_event_for_endpoint(ib.endpoint_id, windowShade.unknown()) end end + end end