I set up my integration using this forum thread, thanks to all for the detailed setup, works like a charm.
I did find that my MPAN on the Octopus developer portal is not always the import one. We have Outgoing Octopus (the smart export guarantee since we have solar panels), so we have two MPANs - one for import from the grid and one for export.
The one that the developer portal shows is the export one in my case. I referred to the latest bill to get the correct MPAN for import.
In case this is useful, with the help (or unhelp, to be perfectly honest) I found a way to filter and create a summary stat from a list of rates based on times. There is probably a better way to do this but I am quite happy with how flexible it is.
{% set rates = (state_attr('sensor.agile_rates_today', 'results')) %}
{% set valid_from_cutoff = now().replace(hour=6, minute=0, second=0, microsecond=0) %}
{% set valid_to_cutoff = now().replace(hour=20, minute=0, second=0, microsecond=0) %}
{% set ns = namespace(total=0, length = 0) %}
{% for item in rates if item.valid_from | as_datetime >= valid_from_cutoff and item.valid_from | as_datetime <= valid_to_cutoff %}
{% set ns.total = ns.total + item.value_inc_vat | float %}
{% set ns.length = loop.index %}
{% endfor %}
{{(ns.total / ns.length) | float | round(2)}}