Amber Electric - Best Price Block

Amber is an Australian electricity retailer that provides access to wholesale electricity prices.

This script will tell you the best time to use your appliances. You can ask for either the cheapest or most expensive block of time, and it will tell you in how many hours that block will, and what the average price would be.

One fun application is with voice commands:

The YAML for the “Next cheapest power block” automation:

alias: "Sentence: Next cheapest power block"
description: Ask when the next cheapest block of time is.
  - platform: conversation
      - "[What is |When is ]the [next] cheapest {hour} hour block"
condition: []
  - service: script.best_power_price
      min_max: min
      entity_id: sensor.amber_general_forecast
      block_size: "{{ trigger.slots.hour }}"
    response_variable: response
  - set_conversation_response: |-
      {% if response.starts_in_hours == 0 -%}
        The cheapest {{ response.block_size }} hour block is now, with an average price of {{ response.cents_per_kwh }} cents per kilowatt hour.
      {% elif response.starts_in_hours == 0.5 %}
        The cheapest {{ response.block_size }} hour block starts in 30 minutes, with an average price of {{ response.cents_per_kwh }} cents per kilowatt hour.
      {% else %}
        The cheapest {{ response.block_size }} hour block starts in {{response.starts_in_hours}} hours, with an average price of {{ response.cents_per_kwh }} cents per kilowatt hour.
      {% endif %}
mode: single

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

You can install the integration here:

Open your Home Assistant instance and start setting up a new integration.

You will need to be an Amber customer to access the API required by the integration.

Not a customer? You can sign up here:


Hey Myles,

Love the script, I have taken it and modified it so that it shows in a text box at the top of my dashboard so that i can see when the next best block is(not gone down the assist path yet) and by default i just leave it as 2 hours as that covers most appliances.

I defined a few helpers to hold the value of the output variables.

alias: test - best price
description: ""
  - platform: time_pattern
    seconds: "00"
condition: []
  - service: script.best_power_price
    metadata: {}
      block_size: 2
      min_max: min
      entity_id: sensor.general_forecast
    response_variable: response
    enabled: true
  - service: input_number.set_value
      entity_id: input_number.amber_low_cost
      value: "{{ response.cents_per_kwh }}"
  - service: input_datetime.set_datetime
      time: >-
        {% set t = as_timestamp(now()) + (response.starts_in_hours*3600) %} {{ t
        | as_datetime |as_timestamp | timestamp_custom('%H:%M') }}
      entity_id: input_datetime.amber_low_time
mode: single

Then my card looks like this

type: custom:mushroom-template-card
primary: 'Power Details '
secondary: ' The lowest power price will be at {{ states(''input_datetime.amber_low_time'') }} and cost {{ states(''input_number.amber_low_cost'')}}c'
icon: mdi:home

One update I am trying to get going but seems beyond my skills is could you define the best power price with in the next time window, say tell me the best price in the next 8 hours, or even tell me the best price before sunset or sunrise, this would be great if you need to time box something like if you want to run the washing overnight and want it done for when you wake up in the morning.



1 Like

This looks like a very useful blueprint, but I’m getting “unknown error” when trying to import the blueprint.
Updated to latest OS and core. Still doesn’t work.
Tried importing another blueprint which worked fine, but still no success with this one.
Can you tell me what is wrong?

This is the log

Logger: homeassistant.components.websocket_api.http.connection
Source: components/blueprint/
integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 19:28:46 (2 occurrences)
Last logged: 19:35:03

  • [547157884224] Error handling message: Unknown error (unknown_error) Ivan from fe80::83e7:219c:23cb:1ad9 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36)
  • [547267858624] Error handling message: Unknown error (unknown_error) Ivan from fe80::83e7:219c:23cb:1ad9 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36)

Traceback (most recent call last): File “/usr/src/homeassistant/homeassistant/components/websocket_api/”, line 27, in _handle_async_response await func(hass, connection, msg) File “/usr/src/homeassistant/homeassistant/components/blueprint/”, line 77, in ws_import_blueprint imported_blueprint = await importer.fetch_blueprint_from_url(hass, msg[“url”]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/components/blueprint/”, line 257, in fetch_blueprint_from_url imported_bp = await func(hass, url) ^^^^^^^^^^^^^^^^^^^^^ File “/usr/src/homeassistant/homeassistant/components/blueprint/”, line 168, in fetch_blueprint_from_github_url resp = await session.get(import_url, raise_for_status=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “/usr/local/lib/python3.12/site-packages/aiohttp/”, line 696, in _request resp.raise_for_status() File “/usr/local/lib/python3.12/site-packages/aiohttp/”, line 1070, in raise_for_status raise ClientResponseError( aiohttp.client_exceptions.ClientResponseError: 404, message=‘Not Found’, url=URL(‘’)

Whoops - I had the file name wrong.


(I’ve updated the link above)

You know the response variable that is returned in the script is that the amount of “blocks” before the time that window is in, because mine keeps spitting out 13 hours away, which doesnt match up in app?

What other parameters are you passing in?

Sorry my apologies, looks like the forecast entity goes out further than the app shows you.

I’m going to try work in a way for it to exclude certain hours of the day eg 00:00-4:00 and 22:00-24:00

Also thanks for creating this I was trying to do something similar to schedule out my deferrable loads based on this :smiley:

@matt2468 Ah, yes it does.

Jinja2 templates are kind of terrible for this, but a cheat way of doing it would be to set the intervals you want to avoid to either 17 if you want to find the cheapest or -2 if you want to find the most expensive (those two numbers are guaranteed to be higher/lower than the max/min prices that can be returned).

Yeah they really are :sweat_smile: I was trying to get chatgpt to help create the template but it kept adding more and more and getting confused hahha, its just moreso I dont want certain appliances running say overnight or whatnot. If I get something working ill post in this thread in case anyone else need something similar