Automating Water Heater Based on Cloud Coverage

I’m working on a project to automate my water heater based on cloud coverage data, and I’m curious if anyone has tackled something similar. Here’s the idea: if it’s sunny, I don’t need the water heater because the solar panels handle it. But if there are several hours of high cloud coverage, I want the heater to kick in automatically.

I’ve integrated OpenWeatherMap into my system, which provides a cloud coverage sensor with percentage values. My plan is to check the cloud coverage at 4 PM each day and see if it was over 75% for more than four hours since sunrise. If so, the water heater should turn on.

I think this can be done using history stats, maybe with utility_meter, but I’m still figuring it out. I’m open to solutions using either Home Assistant automations or Node-Red. Any tips or experiences would be greatly appreciated! I’m really excited to crack this one.