Amber Electric (Australia) Custom Component

any chance of getting the sensor to populate into HomeKit for use in HomeKit Automations?

Many other items from HA populate as sensors (my action que aircon zones, switch states etc).

I’m not sure how HA propagates sensors to Homekit, but as Homekit doesn’t support price sensors I’d wager than it’s not possible (without some janky work around - I’ve heard of people exposing it as a climate sensor, We 1c = 1 degree).

You should be able to see the price spike sensor, though, as that is just a regular binary sensor.

1 Like

Myles, any suggestion on how to best display the forecast price. A statistics graph and sensor graphs only seems to show historical prices.

Not really - Home Assistant doesn’t really handle forecasts. I’ll need to developer a custom UI component at some point, I think.

3 Likes

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: