Nord pool get today and tomorrow lowest price get fetch consolidation error

I consolidated the nordpool integration and making a sensor with both today and tomorrow and ran into a failure in the morning when tomorrow data was not available.

The consolidated template is based on this one which seems to have some error management: Nord Pool - Home Assistant

In the evening all was good - come morning on a restart - problem

all the sensors were unavailable I would expect the error management that I thought was in the original template to help take care of this but it seems on the error on tomorrow (values are not available yet) it just stopped everything.

I could use some help to understand this and maybe find a better way to deal with it than the work around I have come implemented

consolidated example code not working as is - works if use workaround in tomorrow get fetching todays date until after 13:00

## test nord pool
template:
  - trigger:
      - trigger: time_pattern
        minutes: /10
      - trigger: homeassistant
        event: start
      - trigger: state
        entity_id:
          - button.nord_pool_trigger_successful_now_query_servers
        from: null
        to: null
    action:
# today
      - action: nordpool.get_prices_for_date
        data:
          config_entry: 01JN4JFG5BDP2EVXH0HWK6S2CC
          date: "{{ now().date()  }}"
          areas: SE3
          currency: SEK
        response_variable: today_price
# tomorrow
      - action: nordpool.get_prices_for_date
        data:
          config_entry: 01JN4JFG5BDP2EVXH0HWK6S2CC
          date: "{{ now().date() + timedelta(days=2) }}" # workaround "{{ (now().date() + timedelta(days=1)) if (now().time().strftime('%H') | float ) > 13 else now().date() }}" 
          areas: SE3
          currency: SEK
        response_variable: tomorrow_price
    sensor:
# today
      - name: Today lowest price
        unique_id: efb03648-fd28-4cbe-9f4a-2ebf7baef39b
        state: >
          {% if not today_price %}
            unavailable
          {% else %}
            {% set data = namespace(prices=[]) %}
            {% for state in today_price['SE3'] %}
              {% set data.prices = data.prices + [(state.price / 1000)] %}
            {% endfor %}
            {{min(data.prices)}}
          {% endif %}
        attributes:
          data: >
            {% if not today_price %}
              []
            {% else %}
              {% set data = namespace(prices=[]) %}
              {% for state in today_price['SE3'] %}
                {% set data.prices = data.prices + [{'start':state.start, 'end':state.end, 'price': state.price/1000}] %}
              {% endfor %}
              {{data.prices}}
            {% endif %}
# tomorrow
      - name: Tomorrow lowest price
        unique_id: 7f694526-3b2c-4e1f-a3be-d8aa8ac9e52b
        state: >
          {% if not tomorrow_price %}
            unavailable
          {% else %}
            {% set data = namespace(prices=[]) %}
            {% for state in tomorrow_price['SE3'] %}
              {% set data.prices = data.prices + [(state.price / 1000)] %}
            {% endfor %}
            {{min(data.prices)}}
          {% endif %}
        attributes:
          data: >
            {% if not tomorrow_price %}
              []
            {% else %}
              {% set data = namespace(prices=[]) %}
              {% for state in tomorrow_price['SE3'] %}
                {% set data.prices = data.prices + [{'start':state.start, 'end':state.end, 'price': state.price/1000}] %}
              {% endfor %}
              {{data.prices}}
            {% endif %}
# tomorrow and today
      - name: Tomorrow and Today lowest price
        unique_id: 2d42b88c-c216-46da-b69b-68cf561259a8
        state: >
            {% set min_today_and_tomorrow
            = [ states.sensor.tomorrow_lowest_price.state 
            , states.sensor.today_lowest_price.state ] %}
            {{min(min_today_and_tomorrow)}}
        attributes:
          data: >
             {% if state_attr('sensor.nord_pool_se3_tomorrow_lowest_price', 'data') != none
              and ( now().strftime('%d') 
              < as_datetime(states.sensor.nord_pool_se3_tomorrow_lowest_price.attributes.data[0]["start"]).strftime('%d') 
              or as_datetime(states.sensor.nord_pool_se3_tomorrow_lowest_price.attributes.data[0]["start"]).strftime('%d') == '01' ) %}
            {% set results_consolidated
            =  states.sensor.today_lowest_price.attributes.data 
            +  states.sensor.tomorrow_lowest_price.attributes.data %}
            {% else %}
              {% set results_consolidated
            =  states.sensor.today_lowest_price.attributes.data %}
            {% endif %}
            {{ results_consolidated }}

In debugging I checked the template example and that also fails - it does not output state: unavailable data: [] either - I think it did at some point, didn’t it? or maybe I misunderstand it? - could it be nord pool is sending a different message so the error handling is no longer working?

The workaround I have so far is to get this working is to change the tomorrow get to take today until 13:00:
{{ (now().date() + timedelta(days=1)) if (now().time().strftime('%H') | float ) >13 else now().date() }}

Anyone know

  1. how to deal with a failure in an action in a better way (to allow the script to keep running and deal with it later)
  2. should the official template take care of this failure and output state: unavailable data: [] ? if so maybe answering question 1. will be the solution?

if nothing else, here is a template for nordpool to consolidate today and tomorrow if you use the workaround currently commented out and change to your configuration id for nordpool

edit 250331 - fix in tomorrow today to ensure it includes on last day today and 1st day next month tomorrow