SmartThingsCommunity / SmartThingsEdgeDrivers

Apache License 2.0
257 stars 444 forks source link

[BUG]Matter-window-covering update operational state incorrectly #1436

Open 404-code opened 1 month ago

404-code commented 1 month ago

I found that the operational state was displayed incorrectly when the window covering stopped. It always showed "opening" or "closing" unless I refreshed it manually. Maybe there is something that needs to be fixed in the functions current_pos_handler and current_status_handler.

In this case, it would cause the bug:

When the blind starts to move, the blind only updates the operational status, setting IS_MOVING to true and EVENT_STATE to OPERATIONAL_STATE_EVENT. Until the blind stops, the operational status and current position update simultaneously (the message packet is added at the end). The message of the current position will be processed first. Because EVENT_STATE is OPERATIONAL_STATE_EVENT but IS_MOVING is true, it will set EVENT_STATE to NO_EVENT. Thus, when it processes the message of operational status, the code will not execute device::emit_event_for_endpoint to update the status, because EVENT_STATE is NO_EVENT. Finally, it just sets IS_MOVING to false and shows "opening" or "closing".

If just replace line 159 with device:set_field(EVENT_STATE, WindowCoveringEventEnum.CURRENT_POSITION_EVENT), could it cause other problems?

Looking forward to your reply. Thanks.

The message packet of the matter subscription response showed the following. It always reports the current position first:

[1718162472.140788][34296:34298]` CHIP:EM: >>> [E:4155r S:20551 M:67760107] (S) Msg RX from 1:0000000000000001 [5F03] --- Type 0001:05 (IM:ReportData) [1718162472.140841][34296:34298] CHIP:EM: Handling via exchange: 4155r, Delegate: 0xaaaabdd5ba30 [1718162472.140986][34296:34298] CHIP:DMG: ReportDataMessage = [1718162472.141022][34296:34298] CHIP:DMG: { [1718162472.141053][34296:34298] CHIP:DMG: SubscriptionId = 0xc267cab4, [1718162472.141085][34296:34298] CHIP:DMG: AttributeReportIBs = [1718162472.141127][34296:34298] CHIP:DMG: [ [1718162472.141159][34296:34298] CHIP:DMG: AttributeReportIB = [1718162472.141208][34296:34298] CHIP:DMG: { [1718162472.141242][34296:34298] CHIP:DMG: AttributeDataIB = [1718162472.141279][34296:34298] CHIP:DMG: { [1718162472.141319][34296:34298] CHIP:DMG: DataVersion = 0x79ff2eea, [1718162472.141358][34296:34298] CHIP:DMG: AttributePathIB = [1718162472.141400][34296:34298] CHIP:DMG: { [1718162472.141441][34296:34298] CHIP:DMG: Endpoint = 0x1, [1718162472.141486][34296:34298] CHIP:DMG: Cluster = 0x102, [1718162472.141530][34296:34298] CHIP:DMG: Attribute = 0x0000_000E, [1718162472.141573][34296:34298] CHIP:DMG: } [1718162472.141617][34296:34298] CHIP:DMG:
[1718162472.141660][34296:34298] CHIP:DMG: Data = 0, [1718162472.141699][34296:34298] CHIP:DMG: }, [1718162472.141742][34296:34298] CHIP:DMG:
[1718162472.141776][34296:34298] CHIP:DMG: }, [1718162472.141824][34296:34298] CHIP:DMG:
[1718162472.141855][34296:34298] CHIP:DMG: AttributeReportIB = [1718162472.141897][34296:34298] CHIP:DMG: { [1718162472.141930][34296:34298] CHIP:DMG: AttributeDataIB = [1718162472.141999][34296:34298] CHIP:DMG: { [1718162472.142039][34296:34298] CHIP:DMG: DataVersion = 0x79ff2eea, [1718162472.142079][34296:34298] CHIP:DMG: AttributePathIB = [1718162472.142120][34296:34298] CHIP:DMG: { [1718162472.142162][34296:34298] CHIP:DMG: Endpoint = 0x1, [1718162472.142251][34296:34298] CHIP:DMG: Attribute = 0x0000_000A, [1718162472.142293][34296:34298] CHIP:DMG: } [1718162472.142336][34296:34298] CHIP:DMG:
[1718162472.142378][34296:34298] CHIP:DMG: Data = 0, [1718162472.142417][34296:34298] CHIP:DMG: }, [1718162472.142459][34296:34298] CHIP:DMG:
[1718162472.142493][34296:34298] CHIP:DMG: }, [1718162472.142533][34296:34298] CHIP:DMG:
[1718162472.142563][34296:34298] CHIP:DMG: ], [1718162472.142640][34296:34298] CHIP:DMG: InteractionModelRevision = 1 [1718162472.142669][34296:34298] CHIP:DMG: } [1718162472.142810][34296:34298] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0102 Attribute 0x0000_000E DataVersion: 2046766826 [1718162472.142861][34296:34298] CHIP:TOO: CurrentPositionLiftPercent100ths: 0 [1718162472.142948][34296:34298] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0102 Attribute 0x0000_000A DataVersion: 2046766826 [1718162472.142985][34296:34298] CHIP:TOO: OperationalStatus: 0

LucasLzh commented 1 month ago

I had a similar problem where when the motor was running to the 0% or 100% position, the motor percentage slider position was successfully updated, but the label was still opening or closing. smartthing