Amber Electric (Australia) Custom Component

Hey @madpilot still can’t seem to get any sensors except the single Price Spike one. Any ideas?

Dug into my logs and have this error for the Amber integration:

" 2021-12-04 17:05:39 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up amberelectric platform for sensor

Traceback (most recent call last):

File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 249, in _async_setup_platform

await asyncio.shield(task)

File “/config/custom_components/amberelectric/sensor.py”, line 201, in async_setup_entry

description = SensorEntityDescription(

TypeError: init() got an unexpected keyword argument ‘native_unit_of_measurement’"

Ah, no need to use the custom component anymore - it’s now an official
Integration. Remove it from HACS (or remove the directory in custom_components) and restart. Then re-add the integration

@madpilot Any prospect of inclusion of a smart shift in the amber HA integration?

Unsure yet. It’s designed to allow it, but there are some hurdles to over come first.

2 Likes

@madpilot I have just started a new thread on SmartShift functionality:

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.