Oh-Boy! A chance to put on my mechanical engineer hat.
First, you don’t really say if you have PV solar panels or solar thermal panels. Big difference. I’m going to assume it’s PV, and that you mention it because you also heat the water with resistance.
Being in the USA, I always do these calculations using btu’s so I’ll not get into the nitty gritty of your math. It’s pretty straightforward and I think you have the concept pretty well. I’ll just make a few comments about my own experiences in this area.
First, it’s my experience that when available, manufacturer’s COP data is usually pretty good. It’s fun to calibrate, measure, and validate, but I’ve always ended up confirming what I already should have known. So take a look at what’s available, and have some respect for any variance you get from that.
Accurately measuring static tank temperature is a challenge. Any time you put a sensor in or on the tank, it becomes usually reads low after awhile unless there is some movement in the fluid. Where you might be looking at 10deg rise in the tank, 1deg can mean a big error.
Your approach requires a closed system. Heat pump water heaters usually run a long time (compared to resistance heating). If there is any use during that period, the results will be off.
I don’t have a heat-pump, I have a solar-thermal system. I’ve monitored it for years with a mind toward determining the overall contribution of the solar vs electric resistance backup. Here’s what I do:
I have a water meter on the cold water feed to the tank(s). It is a pulse type meter, and I have a datalogger that records the 1 gal pulses. I have a temperature sensor on the cold water input which varies only seasonally, and on the hot water output which is pretty consistent with a fast acting accurate mixing valve fed by the tank and the metered cold water feed.
So my net BTUs out of the system is delta T (output-input) x gallons * 8.4 (pounds/gal). Divide that by 3412 to get kWh. In fact, except for adjusting the input temperature about once per month, I could get a decent measurement with the gallons alone. You could do the same with your system. It really doesn’t matter for this metric how you add the heat to the system. To get COP, you would just divide the kWh out by the kWh into the heat pump and resistance heaters.
The other thing you might want to get a handle on is standby heat loss. That’s pretty much a constant that only needs to be measured once. I did it by recording the kWh consumed by my system over a rainy weekend when we were not at home. I reduced that to a BTU (or kWh) loss per hour. So with that, I can add the standby loss to the previous hot water energy output calculation to get the total system energy output.
I’ll be curious to see what you come up with and how it compares to the nameplate ratings and manufacturer’s data of your equipment.