I found this and it works perfectly: https://community.home-assistant.io/t/zha-automatically-calibrate-zigbee-covers/778544