martinarva / dynamic_energy_cost

61 stars 13 forks source link

Projection graph for future energy price #23

Closed oywino closed 3 months ago

oywino commented 4 months ago

Hi, please forgive me that my "issue" is not directly related to your fine integration which I found to work really well. 👍👍 I am using the "Spain Electricity Pricing (PVPC)" integration to retrieve the price in €/kWh. This sensor also contains future prices over the next 48 hours. We have the same system in my country (Norway) called "Nordpool". Allthough both these sensors give more or less the same information, their attribute values, names and organization are quite different. Someone clever made the following Apex card to visualize the past, current and future prices from Nordpool in Norway:

image

Here you can easily see that it may be worth while waiting until tomorrow afternoon, to run the laundry etc. Do you now if any such attempt has been made by anyone to make a card view like this for the PVPC pricing sensor? The YAML code used for the above card is fairly complex, and I am no programmer:


type: custom:apexcharts-card
header:
  show: true
  title: Strømpris Nordpool inkl..mva
  show_states: true
series:
  - entity: sensor.nordpool
    name: Pris Nå
    type: column
    curve: stepline
    extend_to: false
    float_precision: 3
    stroke_width: 2
    opacity: 0.2
    color: rgb(255,111,0)
  - entity: sensor.nordpool
    name: Pris slutt idag
    type: column
    curve: stepline
    extend_to: false
    float_precision: 3
    stroke_width: 2
    opacity: 0.2
    color: rgb(2,93,136)
    data_generator: |
      return entity.attributes.raw_today.map((p) => {
        return [new Date(p.start), (new Date() > new Date(p.start)) ? null : p.value];
      });
  - entity: sensor.nordpool
    name: Pris slutt imorgen
    type: column
    curve: stepline
    extend_to: false
    color: rgb(2,93,136)
    float_precision: 3
    stroke_width: 2
    opacity: 0.2
    data_generator: |
      return entity.attributes.raw_tomorrow.map((p) => {
        return [new Date(p.start), p.value];
      });
now:
  show: true
graph_span: 3d
span:
  start: day
  offset: '-1d'
locale: nb
apex_config:
  chart:
    height: 300px
    zoom:
      enabled: true
    toolbar:
      show: true
      tools:
        zoom: true
        zoomin: false
        zoomout: false
        pan: false
        reset: true
  legend:
    show: false
  dataLabels:
    enabled: false
  xaxis:
    type: datetime
    labels:
      datetimeFormatter:
        month: ddd
        day: ddd
  tooltip:
    fixed:
      enabled: true
      position: bottomLeft
martinarva commented 4 months ago

We have Nordpool in Estonia as well, and there are lot's of Apex Chart codes for that. I have fine tuned my to this result: Screenshot 2024-05-28 at 10 13 34

Unfortunately I don't have experience with the Spain PVPC, but found this custom lovelace card: https://github.com/danimart1991/pvpc-hourly-pricing-card

In first look, seems that it will do what you are looking for. You don't get the flexibility of apex chart, but get the price chart as is

Also if you share the PVPC entity attributes, i could check the format

martinarva commented 3 months ago

Closing this issue