Calculating average from a forecast

My energy provider provides a forecast as attributes of a sensor. This also includes the data from yesterday.

How can I create a template that calculates the average price for only today (in this case 13/01/2023 and not 12/01/2023) ?

This is what is present in the sensor (collapse)
state_class: measurement
forcast: 
- price: 3231547
  electricity_price: 3231547
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T07:00:00.000000Z'
  sustainability_score: 463
  carbon_footprint_in_grams: 1906
- price: 3449347
  electricity_price: 3449347
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T08:00:00.000000Z'
  sustainability_score: 483
  carbon_footprint_in_grams: 1913
- price: 2885487
  electricity_price: 2885487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T09:00:00.000000Z'
  sustainability_score: 517
  carbon_footprint_in_grams: 1751
- price: 2908719
  electricity_price: 2908719
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T10:00:00.000000Z'
  sustainability_score: 554
  carbon_footprint_in_grams: 1650
- price: 2845557
  electricity_price: 2845557
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T11:00:00.000000Z'
  sustainability_score: 565
  carbon_footprint_in_grams: 1827
- price: 2799214
  electricity_price: 2799214
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T12:00:00.000000Z'
  sustainability_score: 517
  carbon_footprint_in_grams: 1973
- price: 2888391
  electricity_price: 2888391
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T13:00:00.000000Z'
  sustainability_score: 476
  carbon_footprint_in_grams: 2128
- price: 2869273
  electricity_price: 2869273
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T14:00:00.000000Z'
  sustainability_score: 451
  carbon_footprint_in_grams: 2164
- price: 2860198
  electricity_price: 2860198
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T15:00:00.000000Z'
  sustainability_score: 428
  carbon_footprint_in_grams: 2262
- price: 3127487
  electricity_price: 3127487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T16:00:00.000000Z'
  sustainability_score: 408
  carbon_footprint_in_grams: 2146
- price: 3302937
  electricity_price: 3302937
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T17:00:00.000000Z'
  sustainability_score: 422
  carbon_footprint_in_grams: 2282
- price: 3127487
  electricity_price: 3127487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T18:00:00.000000Z'
  sustainability_score: 459
  carbon_footprint_in_grams: 2342
- price: 3141280
  electricity_price: 3141280
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T19:00:00.000000Z'
  sustainability_score: 475
  carbon_footprint_in_grams: 2240
- price: 2595086
  electricity_price: 2595086
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T20:00:00.000000Z'
  sustainability_score: 498
  carbon_footprint_in_grams: 2100
- price: 2451097
  electricity_price: 2451097
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T21:00:00.000000Z'
  sustainability_score: 543
  carbon_footprint_in_grams: 1986
- price: 2043447
  electricity_price: 2043447
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T22:00:00.000000Z'
  sustainability_score: 558
  carbon_footprint_in_grams: 1831
- price: 1952819
  electricity_price: 1952819
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-12T23:00:00.000000Z'
  sustainability_score: 579
  carbon_footprint_in_grams: 1490
- price: 1762607
  electricity_price: 1762607
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T00:00:00.000000Z'
  sustainability_score: 605
  carbon_footprint_in_grams: 1391
- price: 1680690
  electricity_price: 1680690
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T01:00:00.000000Z'
  sustainability_score: 634
  carbon_footprint_in_grams: 1188
- price: 1586552
  electricity_price: 1586552
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T02:00:00.000000Z'
  sustainability_score: 647
  carbon_footprint_in_grams: 1114
- price: 1595022
  electricity_price: 1595022
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T03:00:00.000000Z'
  sustainability_score: 647
  carbon_footprint_in_grams: 1263
- price: 1865457
  electricity_price: 1865457
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T04:00:00.000000Z'
  sustainability_score: 638
  carbon_footprint_in_grams: 1396
- price: 2226037
  electricity_price: 2226037
  gas_price: 14098304
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T05:00:00.000000Z'
  sustainability_score: 602
  carbon_footprint_in_grams: 1583
- price: 2627152
  electricity_price: 2627152
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T06:00:00.000000Z'
  sustainability_score: 550
  carbon_footprint_in_grams: 1801
- price: 2914890
  electricity_price: 2914890
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T07:00:00.000000Z'
  sustainability_score: 497
  carbon_footprint_in_grams: 1990
- price: 2850034
  electricity_price: 2850034
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T08:00:00.000000Z'
  sustainability_score: 481
  carbon_footprint_in_grams: 1884
- price: 2729396
  electricity_price: 2729396
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T09:00:00.000000Z'
  sustainability_score: 506
  carbon_footprint_in_grams: 1845
- price: 2631750
  electricity_price: 2631750
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T10:00:00.000000Z'
  sustainability_score: 558
  carbon_footprint_in_grams: 1865
- price: 2483403
  electricity_price: 2483403
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T11:00:00.000000Z'
  sustainability_score: 564
  carbon_footprint_in_grams: 1785
- price: 2404391
  electricity_price: 2404391
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T12:00:00.000000Z'
  sustainability_score: 586
  carbon_footprint_in_grams: 1911
- price: 2452670
  electricity_price: 2452670
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T13:00:00.000000Z'
  sustainability_score: 557
  carbon_footprint_in_grams: 1975
- price: 2529746
  electricity_price: 2529746
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T14:00:00.000000Z'
  sustainability_score: 533
  carbon_footprint_in_grams: 2153
- price: 2614205
  electricity_price: 2614205
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T15:00:00.000000Z'
  sustainability_score: 488
  carbon_footprint_in_grams: 2151
- price: 3270630
  electricity_price: 3270630
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T16:00:00.000000Z'
  sustainability_score: 448
  carbon_footprint_in_grams: 1980
- price: 3429987
  electricity_price: 3429987
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T17:00:00.000000Z'
  sustainability_score: 444
  carbon_footprint_in_grams: 2110
- price: 3299307
  electricity_price: 3299307
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T18:00:00.000000Z'
  sustainability_score: 456
  carbon_footprint_in_grams: 2024
- price: 3027904
  electricity_price: 3027904
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T19:00:00.000000Z'
  sustainability_score: 487
  carbon_footprint_in_grams: 2304
- price: 3071827
  electricity_price: 3071827
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T20:00:00.000000Z'
  sustainability_score: 486
  carbon_footprint_in_grams: 2248
- price: 3006487
  electricity_price: 3006487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T21:00:00.000000Z'
  sustainability_score: 488
  carbon_footprint_in_grams: 2203
- price: 2731696
  electricity_price: 2731696
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-13T22:00:00.000000Z'
  sustainability_score: 472
  carbon_footprint_in_grams: 1921

unit_of_measurement: €/kWh
icon: mdi:cash
friendly_name: Zonneplan current electricity tariff

The sensor only gives you until 22, is this common? Should the calculation assume all 24 values are not there?

I think something like this:

{% set ns = namespace(sum = 0, count = 0) %}

{% for item in state_attr('sensor.sensor', 'forcast') -%}
  {% if as_datetime(item.datetime).date() == now().date()  %}
    {% set ns.sum = ns.sum + item.price %}
    {% set ns.count = ns.count + 1 %}
  {% endif %}
{%- endfor %}

{{ ns.count }}
{{ ns.sum }}
{{ ns.sum/ns.count }}
1 Like

Good point. Only notice now. Ill need to check that.

Wow. Thanks! This works and is super useful for some other stuff I want to create.

Sorry for the noob question but how do I now get this into a template sensor? Never worked worked with a template like this using variables.

You can test if first in developer tools → template to make sure it works.

1 Like

Already tested when I sent the thank you. Works fine!

Now need to create a sensor out of it to build some automations. Hence my question

@Troon thanks for the pointer. @Hellis81 thanks for the solution. For completeness the complete solution. Really happy with this!

- platform: template
  sensors:
    avg_energy_price:
      friendly_name: Average current energy price
      value_template: >
        {% set ns = namespace(sum = 0, count = 0) %}
        {% for item in state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') -%}
          {% if as_datetime(item.datetime).date() == now().date()  %}
            {% set ns.sum = ns.sum + item.price %}
            {% set ns.count = ns.count + 1 %}
          {% endif %}
        {%- endfor %}
        {{ (ns.sum/ns.count/100000) }}

@Hellis81 Maybe pushing my luck here but any chance you could help me with another problem?

From the same attributes trying to get the #of hours until the cheapest rate in the future.

So for example assuming it would be 10:00 now and at 14:00 it would be the lowest rate of ANY of the forecasted rates (ignoring date/today as at 12:00 the forecast will be updated with another batch of data which includes data of the next day), the outcome would be 4 (=4 hours from 10:00)

I didn’t expect it to work on the first try that is why I asked you to test it first :joy:

You would need to create two more name space variables

        {% set ns = namespace(lowest = 9999999, time = "") %}
        {% for item in state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') -%}
          {% if as_datetime(item.datetime).date() == now().date()  %}
            {% if item.price < ns.lowest  %}
              {% set ns.lowest = item.price %}
              {% set ns.time = item.datetime.time() %}
            {% endif %}
          {% endif %}
        {%- endfor %}
        {{ ns.lowest ~ " at " ~ns.time }}

EDIT sorry the above needs to be adjusted to be placed in the attributes

One-liner to just return the datetime of the first occurrence of the lowest price:

{{ (state_attr('sensor.zonneplan_current_electricity_tariff','forcast')|selectattr('price','eq',state_attr('sensor.zonneplan_current_electricity_tariff','forcast')|map(attribute='price')|list|min)|first)['datetime'] }}

Expanded out for readability:

{% set fclist = state_attr('sensor.zonneplan_current_electricity_tariff','forcast') %}
{% set pmin = fclist|map(attribute='price')|list|min %}
{{ (fclist|selectattr('price','eq',pmin)|first)['datetime'] }}

Thanks again! And I somewhat understand what your are doing/your logic. With small modification it has an output however it also looks ‘backward’ eg this one produces an outcome in the past while the lowest price is actually ahead (at 6am the next day). This is probably because it only looks at today and not the day after ?

Works:

        {% set ns = namespace(lowest = 9999999, time = "") %}
        {% for item in state_attr('sensor.zonneplan_current_electricity_tariff', 'forcast') -%}
          {% if as_datetime(item.datetime).date() == now().date()  %}
            {% if item.price < ns.lowest  %}
              {% set ns.lowest = item.price %}
              {% set ns.time = item.datetime %}
            {% endif %}
          {% endif %}
        {%- endfor %}
        {{ ns.lowest/100000 ~ " at " ~ns.time }}

Thanks @Troon this works.

Would it be super complicated to add logic to find the lowest 2 or 3 consecutive hours?

So you mean for example at 12 the price is 10, and at 13 it’s 5, the sum is 15.
Now is this sum of two hours the lowest of all consecutive hours of the day.

Well it’s a completely different animal for sure.

My simple thought is if you want two hours then we would need two arrays.
One that holds for instance the sum of prices at 11 and 12 o’clock then 13 and 14, and one that holds 12 and 13 then 14 and 15.
This makes the two arrays offset of each other.

Now if we get the lowest price from each of these arrays and compare them then we should get the two lowest consecutive hours.

I’m currently making dinner so not available at the time, perhaps not for the weekend.
But I’ll think about if there is a simpler solution.

Regarding the previous task, I would go for the method Trion posted.

Much more involved, yes. I used to do this with the Octopus Agile electricity tariff, with its half- hourly pricing. I used AppDaemon for this. See the discussion starting here:

As you read down, you’ll get to a Python script I wrote to do this, initially without using AppDaemon. Eventually, I moved it across to AD for various reasons — I had to install it for a different project anyway.

I’m already thankful for what you and @Troon did up till now and make sure you enjoy your diner!

To illustrate see below graph. In some cases you have tasks (eg running the washing machine) that take (for example) 2 hours. In that case you want to begin at a time you mimimize cost over those 2 hours and in those case starting at the lowest point is not always the best moment. The shorter the task, the less of problem it is but with very long tasks (eg charging your EV or heating your hottub) you want to be able to choose the right window with the right starting time.

p.s. below is using both your templates;

If this day is common then it seems the three cheapest hours are consecutive from one hour before to one hour after the cheapest price.
Which seems to make sense in my opinion.

@Troon Having some issues with this to my surprise as the data seemed correct the last 2 days…

See below graph; It things the lowest price is now while it clearly in the future. Do you understand what is going on?

\

This is the sensor:

- platform: template
  sensors:
    time_low_coming:
      friendly_name: Time lowest price
      unique_id: time_low_coming
      device_class: timestamp
      value_template: >
        {% set fclist = state_attr('sensor.zonneplan_current_electricity_tariff','forcast') %}
        {% set pmin = fclist|map(attribute='price')|list|min %}
        {{ (fclist|selectattr('price','eq',pmin)|first)['datetime'] }}
This is the arttribute data
state_class: measurement
forcast: 
- price: 1690007
  electricity_price: 1690007
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T07:00:00.000000Z'
  sustainability_score: 544
  carbon_footprint_in_grams: 0
- price: 2007026
  electricity_price: 2007026
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T08:00:00.000000Z'
  sustainability_score: 558
  carbon_footprint_in_grams: 0
- price: 2024693
  electricity_price: 2024693
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T09:00:00.000000Z'
  sustainability_score: 643
  carbon_footprint_in_grams: 0
- price: 2460777
  electricity_price: 2460777
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T10:00:00.000000Z'
  sustainability_score: 708
  carbon_footprint_in_grams: 0
- price: 2522487
  electricity_price: 2522487
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T11:00:00.000000Z'
  sustainability_score: 765
  carbon_footprint_in_grams: 0
- price: 2341108
  electricity_price: 2341108
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T12:00:00.000000Z'
  sustainability_score: 805
  carbon_footprint_in_grams: 0
- price: 2524302
  electricity_price: 2524302
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T13:00:00.000000Z'
  sustainability_score: 763
  carbon_footprint_in_grams: 0
- price: 2595329
  electricity_price: 2595329
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T14:00:00.000000Z'
  sustainability_score: 663
  carbon_footprint_in_grams: 0
- price: 2703987
  electricity_price: 2703987
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T15:00:00.000000Z'
  sustainability_score: 533
  carbon_footprint_in_grams: 0
- price: 3244130
  electricity_price: 3244130
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T16:00:00.000000Z'
  sustainability_score: 453
  carbon_footprint_in_grams: 0
- price: 3667147
  electricity_price: 3667147
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T17:00:00.000000Z'
  sustainability_score: 395
  carbon_footprint_in_grams: 0
- price: 3946656
  electricity_price: 3946656
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T18:00:00.000000Z'
  sustainability_score: 361
  carbon_footprint_in_grams: 0
- price: 3973277
  electricity_price: 3973277
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T19:00:00.000000Z'
  sustainability_score: 306
  carbon_footprint_in_grams: 0
- price: 3591401
  electricity_price: 3591401
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T20:00:00.000000Z'
  sustainability_score: 253
  carbon_footprint_in_grams: 0
- price: 3490487
  electricity_price: 3490487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T21:00:00.000000Z'
  sustainability_score: 216
  carbon_footprint_in_grams: 0
- price: 3163787
  electricity_price: 3163787
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T22:00:00.000000Z'
  sustainability_score: 227
  carbon_footprint_in_grams: 0
- price: 2280608
  electricity_price: 2280608
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-15T23:00:00.000000Z'
  sustainability_score: 218
  carbon_footprint_in_grams: 0
- price: 2280608
  electricity_price: 2280608
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T00:00:00.000000Z'
  sustainability_score: 204
  carbon_footprint_in_grams: 0
- price: 2313399
  electricity_price: 2313399
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T01:00:00.000000Z'
  sustainability_score: 195
  carbon_footprint_in_grams: 0
- price: 2233297
  electricity_price: 2233297
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T02:00:00.000000Z'
  sustainability_score: 188
  carbon_footprint_in_grams: 0
- price: 2320417
  electricity_price: 2320417
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T03:00:00.000000Z'
  sustainability_score: 219
  carbon_footprint_in_grams: 0
- price: 2607186
  electricity_price: 2607186
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T04:00:00.000000Z'
  sustainability_score: 200
  carbon_footprint_in_grams: 0
- price: 3425510
  electricity_price: 3425510
  gas_price: 13988606
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T05:00:00.000000Z'
  sustainability_score: 202
  carbon_footprint_in_grams: 1312
- price: 3673318
  electricity_price: 3673318
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T06:00:00.000000Z'
  sustainability_score: 185
  carbon_footprint_in_grams: 0
- price: 3804966
  electricity_price: 3804966
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T07:00:00.000000Z'
  sustainability_score: 185
  carbon_footprint_in_grams: 0
- price: 3611487
  electricity_price: 3611487
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T08:00:00.000000Z'
  sustainability_score: 211
  carbon_footprint_in_grams: 0
- price: 3975697
  electricity_price: 3975697
  tariff_group: high
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T09:00:00.000000Z'
  sustainability_score: 289
  carbon_footprint_in_grams: 0
- price: 3558247
  electricity_price: 3558247
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T10:00:00.000000Z'
  sustainability_score: 280
  carbon_footprint_in_grams: 0
- price: 3352426
  electricity_price: 3352426
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T11:00:00.000000Z'
  sustainability_score: 284
  carbon_footprint_in_grams: 0
- price: 3314673
  electricity_price: 3314673
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T12:00:00.000000Z'
  sustainability_score: 279
  carbon_footprint_in_grams: 0
- price: 3322297
  electricity_price: 3322297
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T13:00:00.000000Z'
  sustainability_score: 269
  carbon_footprint_in_grams: 0
- price: 3368277
  electricity_price: 3368277
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T14:00:00.000000Z'
  sustainability_score: 245
  carbon_footprint_in_grams: 0
- price: 3387032
  electricity_price: 3387032
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T15:00:00.000000Z'
  sustainability_score: 184
  carbon_footprint_in_grams: 0
- price: 3572646
  electricity_price: 3572646
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T16:00:00.000000Z'
  sustainability_score: 145
  carbon_footprint_in_grams: 0
- price: 3656498
  electricity_price: 3656498
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T17:00:00.000000Z'
  sustainability_score: 148
  carbon_footprint_in_grams: 0
- price: 3375537
  electricity_price: 3375537
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T18:00:00.000000Z'
  sustainability_score: 165
  carbon_footprint_in_grams: 0
- price: 3319877
  electricity_price: 3319877
  tariff_group: normal
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T19:00:00.000000Z'
  sustainability_score: 159
  carbon_footprint_in_grams: 0
- price: 3151324
  electricity_price: 3151324
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T20:00:00.000000Z'
  sustainability_score: 242
  carbon_footprint_in_grams: 0
- price: 3094938
  electricity_price: 3094938
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T21:00:00.000000Z'
  sustainability_score: 330
  carbon_footprint_in_grams: 0
- price: 3006487
  electricity_price: 3006487
  tariff_group: low
  solar_percentage: 0
  solar_yield: 0
  datetime: '2023-01-16T22:00:00.000000Z'
  sustainability_score: 375
  carbon_footprint_in_grams: 0

unit_of_measurement: €/kWh
icon: mdi:cash
friendly_name: Zonneplan current electricity tariff

Take a look at the times and prices in the data you posted. Which time period in your data has a lower price than the first price of 1690007?

Looks to me like the graph and the data don’t match.