Skip to content

Commit 965b3f6

Browse files
Fix position from being inverted twice
There is a bug in the subdriver introduced by a previous PR where the position can be inverted twice in the current status handler, meaning that the windowShade capability could reflect as open when the shade is closed and vice versa.
1 parent a8c0180 commit 965b3f6

File tree

1 file changed

+5
-6
lines changed
  • drivers/SmartThings/matter-window-covering/src/matter-window-covering-position-updates-while-moving

1 file changed

+5
-6
lines changed

drivers/SmartThings/matter-window-covering/src/matter-window-covering-position-updates-while-moving/init.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ local function current_pos_handler(driver, device, ib, response)
6666
)
6767
end
6868
local state_machine = device:get_field(STATE_MACHINE)
69-
-- When stat_machine is STATE_IDLE or STATE_CURRENT_POSITION_FIRED, nothing to do
69+
-- When state_machine is STATE_IDLE or STATE_CURRENT_POSITION_FIRED, nothing to do
7070
if state_machine == StateMachineEnum.STATE_MOVING then
7171
device:set_field(STATE_MACHINE, StateMachineEnum.STATE_CURRENT_POSITION_FIRED)
7272
elseif state_machine == StateMachineEnum.STATE_OPERATIONAL_STATE_FIRED or state_machine == nil then
@@ -90,18 +90,17 @@ local function current_status_handler(driver, device, ib, response)
9090
"main", capabilities.windowShadeLevel.ID,
9191
capabilities.windowShadeLevel.shadeLevel.NAME
9292
) or DEFAULT_LEVEL
93-
position = reverse_polarity_if_needed(device, position)
9493
for _, rb in ipairs(response.info_blocks) do
9594
if rb.info_block.attribute_id == clusters.WindowCovering.attributes.CurrentPositionLiftPercent100ths.ID and
96-
rb.info_block.cluster_id == clusters.WindowCovering.ID and
97-
rb.info_block.data ~= nil and
98-
rb.info_block.data.value ~= nil then
95+
rb.info_block.cluster_id == clusters.WindowCovering.ID and
96+
rb.info_block.data ~= nil and
97+
rb.info_block.data.value ~= nil then
9998
position = reverse_polarity_if_needed(device, math.floor((rb.info_block.data.value / 100)))
10099
end
101100
end
102101
local state = ib.data.value & clusters.WindowCovering.types.OperationalStatus.GLOBAL --Could use LIFT instead
103102
local state_machine = device:get_field(STATE_MACHINE)
104-
-- When stat_machine is STATE_OPERATIONAL_STATE_FIRED, nothing to do
103+
-- When state_machine is STATE_OPERATIONAL_STATE_FIRED, nothing to do
105104
if state_machine == StateMachineEnum.STATE_IDLE then
106105
if state == 1 then -- opening
107106
device:emit_event_for_endpoint(ib.endpoint_id, attr.opening())

0 commit comments

Comments
 (0)