Enphase Envoy - Switching on and off loads

I am using an Enphase Envoy with production and consumption monitoring. I was running a Python script that was detecting export power and slowly switching on more load (basically an array of immersion heaters in a thermal store) as power increases (depending on Grid costs).
New to home assistant I can’t see an easy way to do this at the moment and just wondered if there is some sort of standard blueprint to do this (I guess I could move my python script in somehow).