My Velux roof windows do this automatically for me every day. Works great as they won't open if it is raining or too cold. Sucks that the radiators don't turn off at the same time, so some wasted energy there.
1. https://www.baubay.de/home-interface-velux-klf-200.html
2. https://community.home-assistant.io/t/velux-kfl200-ha-config...