Problems with Octopus Agile 30minute pricing script(s)

I’m new to Home Assistant, and trying to create a script that feels like it should be easy to accomplish, when the 30 minute pricing of UK octopus agile drops below a threshold, turn on a smartplug, when it rises above, turn the same smartplug off.

I’ve been going round in circles with this for weeks. I have 2 independent scripts that work for a short time and then seemingly stop doing anything, never trigging ever again, until I restart Home Assistant. I turned these off, and have a single script (which uses a numeric entity, rather than a fixed value, however I have tried it with a hard coded value), and this I can’t get working at all, it never triggers. I’m wondering if my issue is more fundamental.

  • Installation method Home Assistant Container
  • Core 2025.9.4
  • Frontend 20250903.5

Here is my combined script:
(device IDs and account IDs obfuscated)

alias: Octopus Agile Price Threshold Action (new)
description: Runs different actions when the Agile price crosses a set threshold.
triggers:
  - entity_id: sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate
    below: input_number.octopus_price_threshold
    id: price_low
    trigger: numeric_state
  - entity_id: sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate
    above: input_number.octopus_price_threshold
    id: price_high
    trigger: numeric_state
  - entity_id: input_number.octopus_price_threshold
    trigger: state
conditions: []
actions:
  - data:
      message: >-
        Agile Price Threshold Action Triggered. Current Rate: {{
        states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
        }}p | Threshold: {{ states('input_number.octopus_price_threshold') }}p |
        Trigger ID: {{ trigger.id }}
      level: debug
      logger: automation.octopus_agile_price_threshold_action_new
    action: system_log.write
  - choose:
      - conditions:
          - condition: trigger
            id: price_low
        sequence:
          - data:
              message: >
                💡 Octopus Agile price is low ({{
                states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
                | float(2) }}p is below {{
                states('input_number.octopus_price_threshold') }}p)! Turn On.
              title: Octopus Agile Price Alert
            action: notify.pushover
          - target:
              entity_id: switch.octopusagile
            action: switch.turn_on
            data: {}
      - conditions:
          - condition: trigger
            id: price_high
        sequence:
          - data:
              message: >
                ⚠️ Octopus Agile price is high ({{
                states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
                | float(2) }}p is above {{
                states('input_number.octopus_price_threshold') }}p)! Turn Off.
              title: Octopus Agile Price Alert
            action: notify.pushover
          - target:
              entity_id: switch.octopusagile
            action: switch.turn_off
            data: {}
mode: single

Here are my 2 individual scripts:

Above Threshold:

alias: Energy Above Threshold
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate
    above: 3
conditions: []
actions:
  - action: notify.pushover
    metadata: {}
    data:
      message: >-
        Energy Above Threshold {{
        states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
        }}
      title: Energy Above Threshold
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      device_id: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
mode: single

Below Threshold:

alias: Energy Below Threshold
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate
    below: 3
conditions: []
actions:
  - action: notify.pushover
    metadata: {}
    data:
      message: >-
        Energy Below threshold: {{
        states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
        }}
      title: Energy Below Threshold
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      device_id: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
mode: single

I believe the incoming rates are updating correctly, as I see this in the logbook:

Never got this working in any of the ways above, so I did it with a periodic polling trigger every minute that checks the rates. Also, once things started triggering, I could see the value is in £ and not p, so needed 0.03 and not 3 to get 3 pence.

Is this the most efficient I can hope for, or is there any improvements? At least it’s working. I guess i’m not overly happy at using polling, I would rather it was event driven for performance and power management reasons.

alias: Energy Above Threshold
description: ""
triggers:
  - trigger: time_pattern
    seconds: "0"
conditions:
  - condition: numeric_state
    entity_id: sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate
    above: 0.03
  - condition: device
    type: is_on
    device_id: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
    entity_id: WWWWWWWWWWWWWWWWWWWWWW
    domain: switch
actions:
  - action: notify.pushover
    metadata: {}
    data:
      message: >-
        Energy Above Threshold (£{{
        states('sensor.octopus_energy_electricity_XXXXXXXXXX_YYYYYYYYYYYYY_current_rate')
        }})
      title: Energy Above Threshold
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      device_id: ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
mode: single