How to copy json list, nth item to end of list

I am looking for a way to copy the entries in a json list from a certain position until the end of the list, all handled within an action template in an automation.

The actual list is the output fron the Nordpool integration (extract below), where I want to parse the list from eg item #3 until the end of list, and with the requirement that the start is dynamically set (from the list below item #3 would give me the three last entries) .

In the template it will be determined by now().hour.

Is there any one-liner or filter that can address this, or do I need to loop through thd list and copy entries manually one by one?

- start: '2022-11-06T00:00:00+01:00'
  end: '2022-11-06T01:00:00+01:00'
  value: 0.35
- start: '2022-11-06T01:00:00+01:00'
  end: '2022-11-06T02:00:00+01:00'
  value: 0.31
- start: '2022-11-06T02:00:00+01:00'
  end: '2022-11-06T03:00:00+01:00'
  value: 0.32
- start: '2022-11-06T03:00:00+01:00'
  end: '2022-11-06T04:00:00+01:00'
  value: 0.29
- start: '2022-11-06T04:00:00+01:00'
  end: '2022-11-06T05:00:00+01:00'
  value: 0.33

Copy-paste the following into the Template Editor and experiment with it.

{% set x = 
        "start": "2022-11-06T00:00:00+01:00",
        "end": "2022-11-06T01:00:00+01:00",
        "value": 0.35
        "start": "2022-11-06T01:00:00+01:00",
        "end": "2022-11-06T02:00:00+01:00",
        "value": 0.31
        "start": "2022-11-06T02:00:00+01:00",
        "end": "2022-11-06T03:00:00+01:00",
        "value": 0.32
        "start": "2022-11-06T03:00:00+01:00",
        "end": "2022-11-06T04:00:00+01:00",
        "value": 0.29
        "start": "2022-11-06T04:00:00+01:00",
        "end": "2022-11-06T05:00:00+01:00",
        "value": 0.33

{{ x | selectattr('start', 'ge', now().replace(microsecond=0).isoformat()) | list }}

Fundamentally it should work, however HA complains over the usage of gt/>= in the select function

TypeError: ‘>=’ not supported between instances of ‘datetime.datetime’ and ‘str’

Trying “eq” instead of gt resolves the error message, but breaks the intention of picking all entries with start after now()

Will look more in to it. tomorrow evening.

That means the value of start and end is understood to be a datetime, not a string. Therefore simply use now().

{{ x | selectattr(‘start’, ‘ge’, now()) | list }}

Thank you for that piece of the puzzle.

The implemented soulution:

{% set today_end = state_attr("sensor.nordpool_kwh_se3","raw_today") | selectattr('start', 'ge', now()) | list |sort(attribute="value") %}
{{ today_end[0].start }}