RESTful API access to most recent price forecasts is available via
https://agilepredict.com/api/{REGION} for a given region.
In addition the following parameters can be used:
days: the number of days to download (default = 14)
forecast_count: the number of recent forecasts to download (default = 1, ie the most recent)
high_low: include the high and low estimates (default = True)
export: return Agile Outgoing export prices instead of Agile import prices (default = False)
So to download the three most recent forecasts for seven days for NW England (Region G) without
high and low estimate the URL would be: https://agilepredict.com/api/G?days=7&forecast_count=3&high_low=False
export=true:
https://agilepredict.com/api/G?days=7&export=true
region and export, for example:
https://agilepredict.com/api/accuracy/?region=G&export=true
The GitHub repo includes the necessary yaml files to import the forecast into a sensor
in Home Assistant. Alternatively you can simply copy the code from this page into your
configuration.yaml file.
Also included is the YAML required for a custom Lovelace card such as that shown below which plots the sensor attributes using the Apex Charts Card
sensor:
- platform: rest
resource: https://prices.fly.dev/api/G
scan_interval: 3600
name: Agile Predict
value_template: "{{ value_json[0]['name']}}"
json_attributes_path: "$[0]"
json_attributes:
- "created_at"
- "prices"
type: custom:apexcharts-card
apex_config: null
header:
show: true
show_states: true
colorize_states: true
graph_span: 7d
yaxis:
- id: price
decimals: 0
apex_config:
tickAmount: 8
stacked: false
span:
start: day
series:
- entity: sensor.octopus_energy_electricity_19m*******_************_current_rate
name: Actual Agile Import (current rate)
transform: return x * 100;
show:
in_chart: false
unit: p/kWh
- entity: >-
event.octopus_energy_electricity_19m*******_************_current_day_rates
yaxis_id: price
name: Actual Agile Import (current day)
color: yellow
opacity: 1
stroke_width: 2
extend_to: now
type: column
unit: p/kWh
data_generator: |
return entity.attributes.rates.map((entry) => {
return [new Date(entry.start), entry.value_inc_vat*100];
});
offset: '-15min'
show:
in_header: false
legend_value: false
offset_in_name: false
- entity: event.octopus_energy_electricity_19m*******_************_next_day_rates
yaxis_id: price
name: Actual Agile Import (next day)
color: yellow
opacity: 1
stroke_width: 2
type: column
unit: p/kWh
data_generator: |
return entity.attributes.rates.map((entry) => {
return [new Date(entry.start), entry.value_inc_vat*100];
});
offset: '-15min'
show:
in_header: false
legend_value: false
offset_in_name: false
- entity: sensor.agile_predict
yaxis_id: price
name: Predicted Agile
color: red
opacity: 1
stroke_width: 3
extend_to: now
unit: p/kWh
data_generator: |
return entity.attributes.prices.map((entry) => {
return [new Date(entry.date_time), entry.agile_pred];
});
offset: '-15min'
show:
in_header: false
legend_value: false
offset_in_name: false