Amber Electric (Australia) Custom Component

Looks like it has stabilised and is functioning correctly now.

Thanks.

Good Morning, I seem to be getting a similar issue as Repairs I try to add Amber Electric with my API key and get an error.

4 days ago I setup my API key in dev tools and tested with curl and was getting an empty array, as I had just setup the API I thought I would just leave it as for a few days in case there is other back end stuff that has to happen for the key to work. I tried it again now and the curl command still gives me an empty array but hangs the curl command so I have to Ctrl-C to get out of it.

When I add the integration in HA I get ā€œNo Site Providedā€ error.
image

Any help would be greatly appreciated.

Email [email protected]

Itā€™s likely that there was a delay in your site onboarding or you are still on a basic meter (we automatically order a smart meter but they can take a few weeks), but if you email in, I can check for you. Make it attn: Myles and theyā€™ll push it through to me.

We donā€™t have a smart meter yet, I thought I would still get the power costs data regardless. So it could purely be that I donā€™t have my smart meter yet (been a month and no word) that the API wonā€™t work until i do?

No, we donā€™t price basic meters. Because of the way we bill them, your 30-minute usage is based on a synthetic load curve, so there isnā€™t a huge advantage in knowing the specific price (the app actually shows you your default network tariff).

We are reviewing this though - more and more basic meter API users want the price to get a feel for what is happening even if it isnā€™t really reflecting their bill.

Sorry mate my writing on that was pore ā€¦ I meant that if my smart meter is not installed yet does that mean my API key may not work?
I was hoping to get the Amber wholesale rates feed into HA so i could start working on automation rules for my solar & battery while i wait for my smart meterā€¦ I am also looking at the emhass stuff as well as that looks good.

Yeah, thatā€™s right.

Does anybody happen to know how to pass the custom component called forecast? From amber?

Iā€™d like to set something to true or use it if there is a spike forecasted in the next X number of hours.

Id like to turn stuff on prior to spike ie my under tile heating before it gets expensive. Thanks

Further up in this thread there were some explanations about why HA does not support forecasting and then a user performed a Kludge using APEX cards to enable the forecast to be monitored

Suggest you read through this thread (which is what i just did)

Craig

Sorry to drag up an old post, but hoping you can help expand on this code just a touch.

My goal is to be able to ask my google assistant around the home ā€œwhen is the cheapest power today?ā€, and itā€™s response will include the cheapest 2hr price, and at what time this begins (between current time and 10pm)

Iā€™ve already got "what is the power price? " working, so I more need to work out a way to find the cheapest 2hr block in the time period, and what time it occurs to incorporate in.
Maybe even just a single sensor that outputs these two values which can be called upon in the script?

Cheers for any help

These binary sensors will get you half way:

  - binary_sensor:
      - name: "Amber Cheapest 8 hrs"
        state: "{{ states('sensor.amber_feed_in_price')|float(0) 
                    <= (state_attr('sensor.amber_feed_in_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).15}}"
      - name: "Amber Cheapest 4 hrs"
        state: "{{ states('sensor.amber_feed_in_price')|float(0) 
                    <= (state_attr('sensor.amber_feed_in_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).7}}"
      - name: "Amber Cheapest hour"
        state: "{{ states('sensor.amber_feed_in_price')|float(0) 
                    <= (state_attr('sensor.amber_feed_in_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).1}}"
      - name: highest2.5
        state: "{{ states('sensor.amber_feed_in_price')|float(0)
                >= (state_attr('sensor.amber_feed_in_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort(reverse=true)).4}}"
      - name: lowest2.5
        state: "{{ states('sensor.amber_general_price')|float(0)
                <= (state_attr('sensor.amber_general_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).4}}"

4 Likes

This might be the other half, although this is not going down the automation path (i.e. let the computers do the thinking/action).

This is just information that can be formatted as user accessible so it is just a list of "cheapest half hour start timesā€¦


{% set cheapest_cost = (state_attr('sensor.amber_grid_general_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).0 %}
{{ cheapest_cost }}


{{state_attr('sensor.amber_grid_general_forecast', 'forecasts') | selectattr('per_kwh', "<=", cheapest_cost ) | list | pprint }}



{{state_attr('sensor.amber_grid_general_forecast', 'forecasts') | selectattr('per_kwh', "<=", cheapest_cost ) | list| map(attribute='start_time')|list|sort }}

Results:


0.16


[{'date': '2023-05-28',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T02:30:00+00:00',
  'nem_date': '2023-05-28T12:30:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.22,
  'range_min': 0.04,
  'renewables': 45,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T02:00:01+00:00'},
 {'date': '2023-05-28',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T03:00:00+00:00',
  'nem_date': '2023-05-28T13:00:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.15,
  'range_min': 0.01,
  'renewables': 45,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T02:30:01+00:00'},
 {'date': '2023-05-28',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T03:30:00+00:00',
  'nem_date': '2023-05-28T13:30:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.15,
  'range_min': 0.04,
  'renewables': 43,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T03:00:01+00:00'},
 {'date': '2023-05-28',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T04:00:00+00:00',
  'nem_date': '2023-05-28T14:00:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.15,
  'range_min': 0.04,
  'renewables': 41,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T03:30:01+00:00'},
 {'date': '2023-05-29',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T16:00:00+00:00',
  'nem_date': '2023-05-29T02:00:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.09,
  'range_min': 0.06,
  'renewables': 12,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T15:30:01+00:00'},
 {'date': '2023-05-29',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T16:30:00+00:00',
  'nem_date': '2023-05-29T02:30:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.09,
  'range_min': 0.06,
  'renewables': 13,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T16:00:01+00:00'},
 {'date': '2023-05-29',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T17:00:00+00:00',
  'nem_date': '2023-05-29T03:00:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.07,
  'range_min': 0.06,
  'renewables': 13,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T16:30:01+00:00'},
 {'date': '2023-05-29',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T17:30:00+00:00',
  'nem_date': '2023-05-29T03:30:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.07,
  'range_min': 0.06,
  'renewables': 13,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T17:00:01+00:00'},
 {'date': '2023-05-29',
  'descriptor': 'very_low',
  'duration': 30.0,
  'end_time': '2023-05-28T18:00:00+00:00',
  'nem_date': '2023-05-29T04:00:00+10:00',
  'per_kwh': 0.16,
  'range_max': 0.07,
  'range_min': 0.06,
  'renewables': 13,
  'spike_status': 'none',
  'spot_per_kwh': 0.07,
  'start_time': '2023-05-28T17:30:01+00:00'}]


['2023-05-28T02:00:01+00:00', '2023-05-28T02:30:01+00:00', '2023-05-28T03:00:01+00:00', '2023-05-28T03:30:01+00:00', '2023-05-28T15:30:01+00:00', '2023-05-28T16:00:01+00:00', '2023-05-28T16:30:01+00:00', '2023-05-28T17:00:01+00:00', '2023-05-28T17:30:01+00:00']

2 Likes

Good timing in this - Iā€™m redoing my kitchen tablet at the moment and wanted this info on there

1 Like

Cheers to both of you for that - is there a simple way to limit the window in which it sorts the half hour periods to be from current time to say 11:00pm every night? (+10:00 UTC)

I presume since itā€™s a forecast, the start time limitation is taken care of, so it just needs a limit of the end window time.

Edit: I got it to this point , but canā€™t find a way to limit it to say 10pm as the latest cutoff pointā€¦

'alias: Speak cheapest power rate
sequence:

  • delay:
    seconds: 0
  • variables:
    current_time: ā€œ{{ now().strftime(ā€™%Y-%m-%dT%H:%M:%Sā€™) }}ā€
    end_time: ā€œ22:00:00ā€
    cheapest_cost: ā€œ{{ (state_attr(ā€˜sensor.amber_general_forecastā€™, ā€˜forecastsā€™) | selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, current_time) | selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, end_time) | map(attribute=ā€˜per_kwhā€™) | list | sort).0 }}ā€
    cheapest_cost_cents: ā€œ{{ (cheapest_cost * 100) | int }}ā€
    cheapest_time_utc: ā€œ{{ state_attr(ā€˜sensor.amber_general_forecastā€™, ā€˜forecastsā€™) | selectattr(ā€˜per_kwhā€™, ā€˜==ā€™, cheapest_cost) | selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, current_time) | selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, end_time) | map(attribute=ā€˜start_timeā€™) | list | sort | first }}ā€
    cheapest_time_local: ā€œ{{ (cheapest_time_utc | as_timestamp) | timestamp_custom(ā€™%-I:%M%pā€™, ā€˜Australia/Melbourneā€™) }}ā€
  • service: tts.google_say
    data_template:
    entity_id:
    - media_player.living_room_speaker
    message: >-
    The cheapest power is {{ cheapest_cost_cents }} cents, occurring at {{ cheapest_time_local }}.
    mode: single
    ā€™

(That end_time of 22:00:09 was an attempt to find the cheapest in that window, but it is being ignored.)

It would be something like what you there.

Best to play in the ā€œDeveloper Toolsā€ Template tab/tool.

Where it is:

selectattr('per_kwh', "<=", cheapest_cost )

In my example use the end time you are trying to get the subset for and compare to the date that you want to filter on

selectattr('nem_date', "<=", some_date_in_the_right_format )

However, this might be where you are having some issues as the date formats need to ā€œmatchā€ to be comparable. Play with those in the Dev tools template editor to get quick feedback on if you are filtering properly.

I donā€™t know much on the time formats here but making them comparable (timestamp or ISO format) will be the challenge.

Also, for your snippet youā€™ll want the current_time check to be >= to create your start and end of the range.

selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, current_time) | selectattr(ā€˜start_timeā€™, ā€˜<=ā€™, end_time)

I hope that helps a little.

Might be out of context here,
But anyone know how to call the ā€œPreserve Battery Energyā€ function from home assistant in the amber app? (looks like it holds the reserve for two hours)
so I may test, instead of
I have a automation (via home assistant) that at
3am sets the
batteries to its current reserve setting,
sets my Car charger to 32 A
5am sets the
batteries to a 5% reserve setting,
sets my Car charger to 0 A

1 Like

We havenā€™t implemented those controls in the API yet, so unfortunately that isnā€™t possible.

If you have a powerwall: Iā€™ve been using a custom Tesla add on from HACS ( GitHub - alandtse/tesla: Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.) to control my battery reserve value.

Unfortunately itā€™s a cloud based integration rather than a local one, but it has a lot of car-specific stuff in it too (Iā€™m not using though, I donā€™t own a Tesla, just a powerwall) which might help with your use case.

1 Like

Has anyone elseā€™s Amber integration stopped working?
Mine isnā€™t receiving any new updates from the API all day, and havenā€™t touched a thingā€¦

Try reloading the integration