Motion Sensor automation for light

Hi, I integrated my Reolink sensor on Home Assistant with this code:

binary_sensor:
    
  - platform: rest

    resource: http://*/*****/api.cgi?cmd=GetMdState&user=*****&password=****

    name: Reolink_Ingresso

    device_class: motion

    value_template: "{{ value_json[0].value.state }}"

    scan_interval: 2

the code it works, but when I go to the automation I want to make sure that if the sensor detects a movement it turns on the light

but this must only work when it is dark and when it is days the autonomy will be deactivated

how should i configure it?

Use the sun’s state as a condition when switching on the lights on movement.