Trigger charging a solar battery off of the grid

I have HASSIO setup, and am looking into getting solar panels with a battery setup this summer. I have nearly all the information I need, but I have this one issue left to understand.

I am in the UK, and would like to use Agile Octopus, which means energy costs vary each day (which I can access via their API). Therefore I wondered whether I could “top-up” the battery overnight from the grid at varying times depending on this data.

Has anyone done anything similar? Not really sure where to look, I can see there are read APIs for batteries, but nothing that triggers charging from the grid. So wonder if some other device would be required to achieve this.

Any advise would be most welcome.
Dan

I doubt that since HASSIO has not been available for three years. You likely have Home Assistant Operating System (HAOS for short).

What you can do depends entirely on the sensors available via the energy provider’s API.

Sure, okay I have HAOS.

sensors available via the energy provider’s API

How does my energy providor control the physical battery charging? I would have though this would have been handled by some local switch or battery API would it not?

You said you wanted to charge your battery depending on the cost available from Agile Octopus.

Ah okay, sorry I may not have been clear in my original post in which case. I have access to the API, and am able to get the data I need, the issue I have is knowing what battery to buy and how to control its charging via an API.

For example, assuming some API data says that the price is cheap enough, how can I then tell the battery to charge for 30minutes from the grid.

Thanks again for your time