Hi everybody, as I’ve only copied the codes, I’m too stupid to adjust it, as the weather forecast has changed with 2024.3.
I used this sensor for the average temperature for the next 24 hours. If it updates once before sunset, it would be a dream:
{{ state_attr('weather.openweathermap', 'forecast')[:8]
| map(attribute='temperature') | average | round(1) }}
And second I use this sensor to decide, whether my shutters should go in “summer mode” so they are closed aligned to the sun. If this updates at sunrise, would be fantastic:
{{ (state_attr('weather.openweathermap', 'forecast')|selectattr('datetime', 'lt', (now().replace(hour=23,minute=59)).isoformat()))| map(attribute='temperature') | list | max }}
Sorry I have a really noob question. This looks like the kind of solution that I need, but where should I be adding this code? Is it in my templates.yaml file?
Thanks for providing these links! I’ll read them this weekend (hopefully)! I had followed a YouTube tutorial for how to !include the templates.yaml file in configuration.yaml, but the template I made with that tutorial just flat out didn’t work.
I’ve used the code mcweis used above and it worked!
EDIT: I say hopefully because I’m trying to set up, learn, and use HA with an 8mo baby who is up and down at night and very active in the day… time is not abundant lately!
Any tip for dealing with a weather service that returns datetime in UTC? I’m struggling to figure out how to take (now().replace(hour=23,minute=59)).isoformat() and then turn that into UTC.