I’ve started playing around with creating some sensors via weather.get_forecasts, but I’m observing an issue regarding how time is returned within PirateWeather. I’ve parsed some info via templates and their outputs below to better outline my issue.
(the sensor.forecast_hottest_time is an idea I got from here. Filters the returned list to match today’s date, sorts them in descending order by temp, then returns the first entry)
Yes, but also on homeassistant restart to make sure I can test them after a restart . The sensors are working correctly as that time is technically the forecasted warmest in the day (its warming up into the next day)…
EDIT: well I guess the warmest in the UTC+0 day (this is my issue)
Apologies, I see I’ve technically fallen victim to the XY Problem.
I guess my real issue is all the datetime returned by PirateWeather is UTC+0 despite my latitude and longitude in configuration.
all datetimes are returned as UTC+0 (in fact, performing the action it right now (11:05 AM local time) the first entry is as follows:
- datetime: "2025-02-28T15:00:00+00:00"
I’m guessing I can’t simply match based on the day, but have to convert all datetimes output by PirateWeather to local time first, before running a date match filter.
Just curious if other PirateWeather users have experience with this
The issue with triggering at times other than midnight is that the forecasts that are provide will only contain values from the current hour onward. If your query happens after the hottest hour, the value returned will not be the hottest hour of the day.
I would just use a standard Time trigger instead of a Time pattern trigger, but either will work.
Yes, my mistake. Though, it shouldn’t matter since weather integrations usually only return 24 hourly items. If you are only triggering at midnight, and Pirate weather doesn’t return more than 24 items, you don’t need to use slicing at all.
All datetimes in HA are UTC, so that all the cards, triggers, etc have a standard frame to work from. If you don’t plan on using the sensor for those kind of uses, you can remove the device_class: timestamp from the sensor configuration so the state is WYSIWYG:
Fantastic logical thought. Actually, I just checked and PirateWeather returns hourly entries for the next 7 days! lol (didn’t expect that). Either way, will run your range list fix. Thank you.
This makes sense. Working with time in HA is relatively new for me (just started HA journey in January), and I gotta be honest all the time coding and formats gets me spun around sometimes.
Its cool to see {{ as_timestamp("2025-03-01T04:00:00+00:00") | timestamp_custom('%I:%M %p')}} actually returns as 11pm of Feb 28, for me.
A thought I had as well, but figured I would keep as timestamp in case down the line I want to trigger things based on this information. To return it more readable in an entity card (I usually use Mushroom Template cards), I’ll template within that to return a more readable time format.