Help with presence automation

I have an AQARA presence detection. I want to poweron a light when it detects movement.

I can do it at first try, but if I poweroff the light manually and I re-trigger the device, it doesn’t re-light and not retrigger cause for next minute state is on.

How can I trigger the light when state is on? I noticed that Zigbee2Mqtt re-send a payload if presence detection is re-triggered.

Thank you

- id: '1610904943967'
  alias: Luci - Corridoio - ON
  description: ''
  - platform: state
    entity_id: binary_sensor.0x00158d00032c28fb_occupancy
    from: 'off'
    to: 'on'
  - platform: template
    value_template: '{{ states("binary_sensor.0x00158d00032c28fb_occupancy") == "on" }}'
  condition: []
  - service: light.turn_on
    data: {}
    entity_id: light.84cca8a5aec7
  mode: single

I’ve had similar situations with my non Zigbee motion sensors because the sensor may not send the off signal for two minutes.

One way would be you could trigger off of the timestamp of the last update if it is in the attributes of the sensor, if not then perhaps you could take out the from and to trigger conditions so that the automation fires on any update from the sensor, then do your own coding for sensing on or off. On mine the motion sensor may stick on for 2 minutes but it will send other updates like temperature or lux (lux is what I use most often because if the light goes off I get an immediate lux notification).

Use an event trigger rather than a state trigger.