Getting weather for tomorrow when going to bed (possibly after midnight)

Hi,

I’m trying to improve the TTS automation when going to bed.
I would like to include the weather forecast for tomorrow but i get in to trouble when i would go to sleep after midnight.

Before midnight I would need to retrieve the forecast for tomorrow, but after midnight I need the forecast for today …
The same problem exists when retrieving all the calendar events for tomorrow. I would like to do something like:

    - alias: Get calendar events
      service: calendar.get_events
      data:
        start_date_time: "{{ now() }}"
        end_date_time: "{{ tomorrow_at('23:59') }}"
      target:
        entity_id: 
          - calendar.my_calendar

But this does not work because tomorrow means something different depending on when i go to sleep …

Any idea on how to solve this?
Anyone would like to share how they overcame this problem?

One possible solution i was thinking about is checking the current time:
If the timestamp.hour is less then 3 or 4 or something, it is after midnight and I should look for today’s events/forecast.
Otherwise check for tomorrow’s events/forecast.

But this seems like a complex solution for a not so complex problem …
:thinking:

Create an entity that contains the weather you want grab populate this entity at the same time everyday (5:00 am?). Use this entity in your ttts. Then you are only accessing the entity and not grabbing the weather data.

1 Like