Skip to content

Commit

Permalink
Update drivers/SmartThings/matter-window-covering/src/init.lua
Browse files Browse the repository at this point in the history
Co-authored-by: Harrison Carter <[email protected]>
  • Loading branch information
nickolas-deboom and hcarter-775 authored Jan 17, 2025
1 parent e1554f0 commit 3701671
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions drivers/SmartThings/matter-window-covering/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3701671

Please sign in to comment.