The recent Wi-Fi HaLow technology focuses on adopting Wi-Fi for the needs of the Internet of Things. A key feature of Wi-Fi HaLow is the Restricted Access Window (RAW) mechanism that allows an access point to divide the sensors into groups and to assign each group to an exclusively reserved time interval where only the stations of a particular group can transmit. In this work, we study how to optimally configure RAW in a scenario with a high number of energy harvesting sensor devices. For such a scenario, we consider a problem of device grouping and develop a model of data transmission, which takes into account the peculiarities of channel access and the fact that the devices can run out of energy within the allocated intervals. We show how to use the developed model in order to determine the optimal duration of RAW intervals and the optimal number of groups that provide the required probability of data delivery and minimize the amount of consumed channel resources. The numerical results show that the optimal RAW configuration can reduce the amount of consumed channel resources by almost 50%.