Regex_findall_index issue

Hi, I’m trying to to extract tomorrow’s temperature from a weather entity:

So, basically the number after the second instance of "temperature":

I thought that regex_findall_index would be the way to do this, but I’m going wrong somewhere, here’s my code:

{{ state_attr('weather.openweathermap', 'forecast') | regex_findall_index('"temperature": (\d+\.?\d+)', index=1) }}

IndexError: list index out of range

Have tried without the double quotes, but no joy, probably something really basic, so sorry to ask! Any help appreciated :+1:

You had a problem, and you thought you’d use regular expressions?

You should be able to access this with JSON notation, something like:

{{ state_attr('weather.openweathermap', 'forecast')[1]['temperature'] }}

I agree with Troon. That is the way to do it, but in case you want your regex to work then I assume this should do:

{{ state_attr('weather.openweathermap', 'forecast')| regex_findall_index('\'temperature\': ([\d\.]+)', index=1) }}

Thank you both, much appreciated :grinning: