JaccoR / hass-entso-e

Integration for Home Assistant to fetch day ahead energy prices from European countries via ENTSO-e Transparency Platform
Apache License 2.0
177 stars 29 forks source link

Feature: Describe how you can show the prices in a graph #19

Closed istaveren closed 1 year ago

istaveren commented 1 year ago

Would be nice if you can show the prices per hour in a graph.

JaccoR commented 1 year ago

Using the ApexCharts Card you can plot the prices by using the prices and hours in the attributes of the sensors as shown below.

Example graph:

Example lovelace code:

type: custom:apexcharts-card
graph_span: 24h
span:
  start: day
now:
  show: true
  label: Now
header:
  show: true
  title: Electriciteitsprijzen Vandaag (€/kwh)
series:
  - entity: sensor.current_electricity_market_price
    stroke_width: 2
    float_precision: 3
    type: column
    opacity: 1
    color: ''
    data_generator: |
      return entity.attributes.prices_today.map((record, index) => {
        return [record.time, record.price];
      });
istaveren commented 1 year ago

I know I was using:

type: custom:apexcharts-card
graph_span: 48h
update_delay: 2s
span:
  start: day
now:
  show: true
  label: Nu
header:
  show: false
  title: Day ahead prices
  show_states: true
  colorize_states: true
series:
  - entity: sensor.current_electricity_market_price
    type: column
    name: Today
    float_precision: 4
    data_generator: |
      return entity.attributes.prices_today.map((data, index) => {
        return [data.time, data.price];
      });
  - entity: sensor.current_electricity_market_price
    name: Tomorrow
    type: column
    float_precision: 4
    data_generator: |
      return entity.attributes.prices_tomorrow.map((data, index) => {
        return [new Date(data.time).getTime(), data.price];
      });

Was planning to create a merge request to add it to the readme ;-).