Load PV battery depending on epex values


I am still a little bit lost with HA, so I hope to get help here.
I have a PV installation here, including a battery.
Now, when selling power I am actually getting about 6ct/kWh. I am thinking about switching to a hourly-based rate for buying power. I already integrated this using EPEX integration into HA.
There are (especially on weekends) some hours when the power I buy is significantilly cheaper than those 6 ct I get for selling.
My idea is on such days not to load the battery from my PV generation, but to use power from the net (on some hours I am getting up to 15ct for taking it).
How would an approach for an automation look like?
My inverter is already connected and working with HA, I can switch the inverter to load the battery from the net. I am only a little bit lost regarding the automation.
Did someone already do this an could help me please?
Best regards and thanks in advance,

no one did this till now? :frowning:

damn. probably I will have to write some python code or so…