Help needed in improving Nordpool heating configuration

Could you please help?

I am using Nordpool integration to optimize my heating in couple locations. My question here concern heating a storage where the temperature inside does not matter if it varies. I try to keep this temperature as low as possible just to prevent freezing (temperature outside can be – 35 Celsius) I have two levels of heating:

  • Lower level
    • Using this the whole day when ”standard deviation” of the price is small for the day (overrules the Higher level heating)
    • Using this when the temperature drops below it in any case (if Highher level is not active)
    • This is very accurate (0+0.1 Celsius) using outside temperature to optimize heating time etc.
  • Higher level
    • When the current price is below a set ”Cheap”-value
    • When the current price is below day_min + X-value
    • When current price is within 8 cheapest using this common code below

I would like to improve this Higher level heating. I would like to create a value_template to get a ”True”- value when:

lowest_8_hours is true and next hour is not within 8 cheapest.

So with this you could rise the temperature only in the ”last” cheap hour, not all cheap hours. You should not worry about the last hour of the day if it gets too complicated, because the first hour tomorrow is practically never the expensive one.

I am not a programmer in any level but I have succesfully copied code with your help so please help also with finding:

price for next hour

All help is highly appreciated – Once again :wink:

        value_template: >-
          {% set l=state_attr('sensor.nordpool_kwh_fi_eur_3_10_024', 'raw_today')|sort(attribute='value') %}
          {{ (now() >= l[0].start and now() <= l[0].end)
          or (now() >= l[1].start and now() <= l[1].end)
          or (now() >= l[2].start and now() <= l[2].end)
          or (now() >= l[3].start and now() <= l[3].end)
          or (now() >= l[4].start and now() <= l[4].end)
          or (now() >= l[5].start and now() <= l[5].end)
          or (now() >= l[6].start and now() <= l[6].end)
          or (now() >= l[7].start and now() <= l[7].end) }}