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:
