Hi there,
I’m quite neq at templating. After lots of looking through this forum, I’ve got a working template and I was able to format the datetime accordingly but I can’t put it together correctly.
This is what I’ve got, so far. It gives out the correct result:
The function today_at() will return a datetime object for the supplied time on today’s date in your local timezone. You can add a day to that using timedelta().
{% set target_t = '17:00' %}
{% set t_format = (today_at(target_t) + timedelta(days=1)).strftime("%Y-%m-%dT%H:%M:%SZ") %}
{{ state_attr('sensor.dwd_hourly', 'forecast') | selectattr('datetime', 'match', t_format)
| map(attribute='temperature') | first }}
@Didgeridrew please stop writing all this code, I have so many bookmarks for the cool code tricks you write that I’ll never find them . Today at is a very cool and useful snippet!
Thanks, so much. I found the docs quite confusing. So thanks for your help!
Unfortunately, though, your code results in the wrong formatting which doesn’t fit to the attribute.
I need 2024-04-27T07:00:00Z and yours gives 2024-04-27 07:00:00+02:00. I’ll try something else using timedelta and see if it works.