lewisbenge / hass-amber-electric

Home Assistant Component to pull the latest energy prices from Amber Electric
MIT License
27 stars 7 forks source link

Potentially useful HA template #19

Open sjwright opened 3 years ago

sjwright commented 3 years ago

Thanks for a great plug-in.

Here is a simple sensor template that has been very practical for me. I publish this sensor in lovelace as a gauge to see at a glance if it's a suitable time to be starting the dishwasher, laundry etc. I can also imagine many ways where I could use this in automations. For example I could send notification to my phone if the forecast will be going high while the air conditioner is running.

sensor:
  - platform: amberelectric
    postcode: "2000"

  - platform: template
    sensors:
      amber_peak_predicted_2h:
        friendly_name: "Amber 2 hour peak predicted"
        unit_of_measurement: "c/kWh"
        value_template: >-
          {% set forecast = states.sensor.amber_general_usage_price.attributes['price_forcecast'] %}
          {% set highest = forecast[0:4] | sort(reverse=true, attribute='price') | first() %}
          {{highest['price']}}
      amber_peak_predicted_4h:
        friendly_name: "Amber 4 hour peak predicted"
        unit_of_measurement: "c/kWh"
        value_template: >-
          {% set forecast = states.sensor.amber_general_usage_price.attributes['price_forcecast'] %}
          {% set highest = forecast[0:8] | sort(reverse=true, attribute='price') | first() %}
          {{highest['price']}}
CRCinAU commented 3 years ago

This works quite well, thanks :)

bengAThome commented 3 years ago

Great work. Thanks for sharing.

davewatson91 commented 3 years ago

@sjwright

I've created a fork which I hope to be able to maintain (also noting there are breaking changes next release which need to be fixed, and this repo hasn't moved since last year).

I've added your template onto the doco on my fork :)

davewatson91/hass-amber-electric