SOLVED - Use number of hours of high cloud coverage to switch on water heater

If it is sunny I do not need to switch on my water heater because the water is heated by solar panels.
I have the Open Weather Map integration which provides a Cloud Coverage sensor, which gives a percentage measurement.
At 16:00 each day I want to check how many hours the Cloud Coverage was over 75% since sunrise.
If the result is over 4 hours I will automate switching on the water heater.
I am sure this can be done with history stats (possibly using utility_meter as well), but I have not found the answer yet.
I would be happy to see a solution either in HA automations or in Node-Red.
Looks like I am on the way to solving this on my own!