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:
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.
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 andEVENT_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. BecauseEVENT_STATE
is OPERATIONAL_STATE_EVENT butIS_MOVING
is true, it will setEVENT_STATE
to NO_EVENT. Thus, when it processes the message of operational status, the code will not executedevice::emit_event_for_endpoint to update the status
, becauseEVENT_STATE
is NO_EVENT. Finally, it just setsIS_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: