Energy use metering realtime

Hi, , I can generate 4.8KW, if the sun ever come out, My grid supplier is offering either wholesale market rates or a fix rate of GBP 0.15/kwh or the wholesale rate in 1/2 hour intervals, which at peak times can go as high as 0.60/kwh, but that around 5pm and its dark, but in the morning peak is around 0.22/kwh.
Conundrum:
at the moment I am paid for what I generated , before my own use, theses rate are for export, so over the winter season I could lose out if I change systems.
At the moment I use this to show actual power use:-

    sensors:
      actual_power_usage: #generated minus total grid power
        entity_id:
          - sensor.shellyem_109664_channel_1_power
          - sensor.shellyem_109664_channel_2_power
        value_template: >-
          {% set generated = states.sensor.shellyem_109664_channel_1_power.state|float %}
          {% set grid = states.sensor.shellyem_109664_channel_2_power.state| float %}
          {{ (generated - grid)|abs|round(1) }}

I can change “power” to “energy” which the Shelly EM shows in Kwh, and use grid minus generated to give the surplus , exported. A Gauge on Lovelace can be used to show exported
What would be nice would be to scrape the current half hourly wholesale rate of electricity to use in automations to stop power hungry devices , like hot water heaters when the price is highest.
Has anyone done this ? , the supplier in the UK is Octopus Energy,
TIA