Amber Electric (Australia) Custom Component

Lovin’ the existing feed.
I’ve set up a ESPHome ESP32 light that runs the light template to show Cyan, Green, Yellow, Red depending on pricing.
Plus I’ve got a set of automations that turn of the aircon units if there is a price spike as well as flash red the status light.

I just started a post on this…but then saw your reply here.

Does that mean that Forecast Data would difficult or impossible to use as is current?

Display and automations are different beasts. I was talking about displaying forecasts.

I’ll head over to the other thread.

I have figured a way to graph the forecast data. Not very refined yet but working.
Using a HACS frontend card ApexCharts-card. Below is my yaml code.
Screenshot 2022-02-14 220412

type: custom:apexcharts-card
graph_span: 24h
span:
  start: minute
header:
  show: true
  title: Amber Electricty Forecast
  show_states: false
  colorize_states: true
series:
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    stroke_width: 1
    name: range min
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), entry.range_min];
      });
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    stroke_width: 1
    name: range max
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), entry.range_max];
      }); 
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: blue
    name: price kwh
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), entry.per_kwh];
      });
yaxis:
  - min: 0
    max: ~0.40
    decimals: 2
    apex_config:
      forceNiceScale: true

1 Like

A bit nicer looking, price only and some bands
Screenshot 2022-02-15 172128

type: custom:apexcharts-card
graph_span: 24h
span:
  start: minute
header:
  show: true
  title: Amber Electricty Forecast - $/kwh
  show_states: false
  colorize_states: true
series:
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: cyan
    stroke_width: 1
    show:
      legend_value: false
    name: Low Price
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), 0];
      });
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: green
    stroke_width: 1
    show:
      legend_value: false
    name: Average Price
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), 0.16];
      });
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: yellow
    stroke_width: 1
    show:
      legend_value: false
    name: Medium Price
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), 0.25];
      }); 
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: red
    stroke_width: 1
    show:
      legend_value: false
    name: High Price
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), 0.4];
      }); 
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color: blue
    show:
      legend_value: false
    name: $/kwh
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), entry.per_kwh];
      });
yaxis:
  - min: 0
    max: ~0.40
    decimals: 2
    apex_config:
      forceNiceScale: true
3 Likes

@markpurcell has come up with a great way to identify the trigger or condition value for “Best X number of hours” in the next 24hours.

Gives the KW/hr rate likely to give you X hours based on current forecast (obviously changes)

I’m using this to run my pool heatpump heater in the best hours of the day and will probably automate the circulation pump and chlorinator. Try and get it to wait till best period, and also not have to seasonally adjust a static value.

I’ve set up a heap for different run times

-sensor
      amber_daily_forecast_best4hr:
        friendly_name: "Amber Forecast Best 2hours"
        value_template:   >-
          {{ (state_attr('sensor.amber_general_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).4}}

  - binary_sensor:
      - name: "Amber Cheapest 2 Hours Trigger"
        state: "{{ states('sensor.durst_home_general_price')|float(0) <= (state_attr('sensor.durst_home_general_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).4}}"

1 Like

3rd version (and final … i promise) - using experimental feature of colouring the curve

image

type: custom:apexcharts-card
experimental:
  color_threshold: true
graph_span: 24h
span:
  start: minute
header:
  show: true
  title: Amber Electricty Forecast
  show_states: false
  colorize_states: true
series:
  - entity: sensor.amberelectricity_general_forecast
    float_precision: 2
    color_threshold:
      - value: 0
        color: cyan
      - value: 0.16
        color: green
      - value: 0.25
        color: yellow
      - value: 0.4
        color: red
    name: price kwh
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
        return [new Date(entry.start_time), entry.per_kwh];
      });
yaxis:
  - min: 0
    max: ~0.5
    decimals: 2
    apex_config:
      forceNiceScale: true
2 Likes

Good work.

Never call anything final, release 3 is fine as there will be future iterations.

I have a price spike coming up this afternoon, which really distorts the graph.

image

Mark, the ~ in front of the 0.5 set the scale to 0.5max unless it goes above this figure. If you remove the ~ it will have a fixed scale and the peak will just be above the display area.
Some pretty wild price swings - the wholesale pricing max is particularly volatile

Thanks removing the ~ makes it more readable.

The spikes do seen very high, while the negative events are rare.

My automations switch most things off during price spike so not too bad, but looking forward to getting my battery so I can export during these times.

I’m starting to think seriously about a battery…possibly solar less. Or with a solar system that is sized very tightly to requirements. And an inverter I can turn off with HA automations in the case of a negative fit event.

In SA we are getting great runs of sub 0.1/kwh for many hours midday and a few negative price moments. Solar itself seems be becoming less advantageous. Either needs a battery to shift it to when it is used or cover price spike events. Or possibly just a battery that is charged off the grid at the periods of lowest rates each day. Cover our use evenings and price spikes. Maybe even discharge to grid if it made sense.

Major issue is that I’ve got 3 phase and a 3 phase Aircon :thinking:

But I’m not sure which hardware would accommodate this…especially with HA

@madpilot how does smart shift actually work? Beyond just pre selecting the best hours in advance from forecast…is it dynamic to adjust to weather? Adelaide today is a good example of that. I’m sure forecast from midnight was pretty different to what actually happened.

It uses price and solar forecasts, your past usage, and past solar generation and tries to optimise for minimising costs. But it reruns the optimisation every five minutes to deal with changing forecasts.

Re: three phase. In some configurations you can still supply all phases with one battery.

1 Like

Yes the economics are interesting.

The high price spike events seen to be a lot more severe than the low price episodes.

Fill a 10 kWh battery in the morning for a cost of $0-$2 and then discharge in the evening for a sale of $4-$10+ and your ROI for a $15k battery is between 5-10 years and you help stabilize the grid.

Price spike events become revenue opportunities rather stressing about excess consumption.

Solaredge seems to have pretty good battery control in HA:

People are doing it with Powewall2 but send a bit more complex:

I have just ordered a powerwall mainly to see what it can do and to see if I can drive down that ROI period with automation. Delivery expected in April. Showed my installer what HA could do and he got very excited as he thinks he has a lot of users that could benefit.

Modbus is the way to go - the cloud API’s rate limiting effectively limits you to 5 minute control at best.

I have a SolarEdge inverter - researching batteries at the moment (the LG Chem batteries seem to be the recommendation)

+1 for ModBus.

I have my Solaredge reporting every second, which is excellent for balancing excess solar charging into my EV under HA control.

Good summary here:

To cope with the billing being the price in the last 5min of a 30min block. Does smart shift try and cut out earlier?

I felt like I’ve gotten a text message and turned it all off…and the next day I was still on the hook for power during the spike. My guess is that I was happy paying $0.5c to be comfortable in that moment…but then it switched to a spike (of $14-17) in the last 5-10min, so was on the hook. Acting on the text message or app notification isn’t enough. Need to preemptively reduce incase high prices switch over within the block.

It tries to minimise damage by reacting to 5 minute prices, which is the best you can do with 30-minute billing.

We are all waiting with baited breath for 5-minute billing so that problem goes away (to be replaced with the “how do we get the current price, and then control the device in a timely manner” problem)

1 Like

Hi, I’m trying to create a basic script that I can “call on” via google around the home.
I want to be able to say “when’s the cheapest power”, and the script to output data, so google responds “The cheapest power will be XXcents at (time) YY:00/30”

The time frame I’m flexible on, best case it’s hours remaining between the time the question is asked, and say 9pm (“getting things done hours), but otherwise, in the next 6 hours would work.

I have tried adapting a solution from above for cheapest price in next 2 hours, but 1) I can’t work out how to extend it to 6hour period, and 2) also output the time at which the cheapest value occurs (if more than one time has an equal lowest value, then the closest one is fine).

value_template:   >-
            {{ (state_attr('sensor.amber_general_forecast', 'forecasts') | map(attribute='per_kwh')|list|sort).4}}

My current “hey google, what’s the power price” script looks like this (and works perfectly for me):

speak_power_rates:
  alias: Speak power rates
  sequence:
  - delay:
      seconds: 2
  - service: tts.google_say
    entity_id:
    - media_player.living_room_speaker
    data_template:
      message: The power currently costs {{(states('sensor.amber_general_price')
        | float * 100) | int }} cents

Is there a way on your solar edge to limit export to zero when FIT goes negative with HA?

I just got a 10kw 3 phase solar edge inverter with modbus. My only concern is when fit goes negative, I do want to export.