If you do it right and it works well, it can be quite efficient. But free after Pareto, it’s a lot of effort for little added benefit.
Why:
First, you have to define what should happen at all when there is "too much" photovoltaic power. Should the heat pump only run when the sun is shining? Probably not. Should it just heat a little warmer? That also works with my suggestion. Should it produce hot water? That also works with my suggestion. Even better, because then it’s not heated up three times by five degrees, but once by 15. That’s better for the heat pump.
In the core of winter, there is almost always too little photovoltaic power anyway. So you benefit most from increasing the power a bit spread out over the whole day and drawing on it for part of the night. But caution is advised here too: efficiency suffers. The heat pump doesn’t want to be "hotter than necessary now and then." For me, after the "optimization" for photovoltaic, the coefficient of performance dropped by about 0.3 points. But the electricity is cheaper. You have to calculate.
The last point why controlling hardly pays off: the heat pump is simply not a big consumer. Yes, it consumes a lot over time, but not much at once. It has to be pretty cold outside for a heat pump to draw over 1-2 kW. And if 10 kW are available at that moment, that doesn’t change anything for the heat pump. A car battery can then ramp up to e.g. 11 kW. But the heat pump, which maybe should produce 2° more, only needs 100 watts extra for that, which doesn’t make a big difference.
So first K.I.S.S. and get to know the systems.
And if you’re really into home automation, you can gladly do a bit of programming around the counter. It’s fun. But saving is hardly possible.