ZNJLBL01LM: HA cover never shows opening/closing for set commands (optimistic position defeats #33037)
What happened?
Z2M 2.14.2, Aqara Roller shade driver E1 (ZNJLBL01LM), two devices.
#33037 should show opening/closing in Home Assistant when the cover starts moving from 0/100. For moves started by a set command it never does: lumi_curtain_position_state.convertSet returns {state: {position: value}}, so the target position is published before the motor reports.
Z2M log, close command, cover at 100: 09:39:06 {"motor_state":"stopped","position":0,"running":false} <- optimistic target 09:39:07 {"motor_state":"closing","position":0,"running":true} 09:40:05 {"motor_state":"stopped","position":0,"running":false}
The new HA value_template only accepts "closing" if position != 0, so HA goes open -> closed immediately and shows no movement for the whole run. Same for opening. Reproduced 4/4 on both devices.
What did you expect to happen?
HA shows closing/opening while the motor runs (motor_state closing/opening, running true), and closed/open only after the motor stops.
How to reproduce it (minimal and precise)
Cover at position 100, send {"state":"CLOSE"} (or cover.close_cover from HA) and watch the HA cover state.
Zigbee2MQTT version
2.14.2
Adapter firmware version
20250321
Adapter
Z-Stack 3.x.0 (TI)
Setup
Home Assistant OS add-on 2.14.2-1
Device database.db entry
No response
Debug log
No response
Notes
No response
Hi, the discovery template change in #33037 exposed an existing semantic problem in lumi_curtain_position_state.convertSet().
It publishes the requested target position as the current position, which it should not. For ZNJLBL01LM, this is particularly inappropriate because the device already reports motor_state during movement and obtains the actual position once the motor stops.
Therefore, I don't think this is really a regression in the intent of #33037. That change made Home Assistant rely more accurately on the distinction between current position and movement direction, while the optimistic state update for ZNJLBL01LM violates that distinction by temporarily reporting the target as if it were the actual position.
I would suggest fixing this in zigbee-herdsman-converters/src/lib/lumi.ts, probably narrowly for ZNJLBL01LM initially, rather than removing the optimistic position update for every device using lumi_curtain_position_state.
Other Lumi cover motors may still depend on that optimistic update if they do not report their actual position as reliably.
Thanks, that matches what I see in the logs. Agreed that #33037 only exposed the optimistic position in lumi_curtain_position_state.convertSet(). For ZNJLBL01LM the device reports motor_state while moving and Z2M already re-reads the position after the motor stops (lumiReadPositionOnReport), so the early target position is redundant there. A narrow change for ZNJLBL01LM in lumi.ts sounds right to me; I have two of these motors and can test a build.
PR with the narrow fix for ZNJLBL01LM: Koenkk/zigbee-herdsman-converters#13362