I would like to achieve a “use some extra blankets tonight” indicator. Based on the expected lowest temperature for this night. I think the best indicator would be the forecasted temperature just before sunrise the next morning.
Anyone got some hints for this? Which weather forecast API / service could provide this information? I am located in the Netherlands.
For now, the best I could find was OpenWeatherMap ‘temp_tonight’. But this is the temperature at 00:00. So it’s not the lowest temperature of the coming night.
Have a look to see if you can find an Integration that provides hourly forcasts for you area (e.g. Climacall or Meteorologisk institutt (Met.no). I live in the UK and the latter provides an entity that gives an hourly forcast in the Front End:
Presumably the temperature for the time you require could be extracted using a suitable template (note that there is a ‘templow’ attribute but I am unsure of what this actually is).
Something simillar could be done with the precipitation to notify if you need a raincoat for the following day.
It is going to require an interesting template… I will try!
Edit: the OpenWeatherMap hourly forecast contains the hourly temperatures for the next 48 hours. I was able to add it through the Integration page (not without a little struggle but so be it).
This template sensor does the job:
template:
- sensor:
- name: temp_nextsunrise
device_class: temperature
icon: 'mdi:thermometer'
unit_of_measurement: '°C'
availability: >
{{ not is_state('weather.openweathermap', 'unavailable') }}
state: >
{% set trise = as_timestamp(state_attr('sun.sun', 'next_rising')) | timestamp_custom('%H', true) | int %}
{% set tnow = as_timestamp(now()) | timestamp_custom('%H', true) | int %}
{% set hforecast = 24 - tnow + trise %}
{{ states.weather.openweathermap.attributes.forecast[hforecast].temperature }}
But actually, the temperature could be lower at a different time than at sunrise.
You could just loop over all the values and grab the lowest and the time that is and have that presented.
And I’m not sure your template is doing what you are expecting.
24 - 13 (currently 13:09)+ 7 (in my sun it says 7:00) = 18.
So you get the temperature at 18:00 tonight.
Hi all, I’m trying to do something not quite dissimilar
We’re in the south-west US and pool-season is upon us. I have a sensor for pool water temperature which records ever 5 minutes. I keep a 14 day recorder trail.
Just for people finding this thread, the above doesn’t work anymore. Plus there is a simpler way since some of the weather integrations provide the lowest predicted temperature already.
The integrations that I tested with are “OpenMeteo” and “OpenWeatherMap”. Both uses the same parameters. I just noticed that around 1AM, OpenMeteo gives yesterdays values too (could be a time zone related). You just need to adjust the index below according to your needs.
In my case the index is 0 because I run this at 1AM every day. If I want to run it before midnight and predict tomorrow’s lowest temperature, then I would use index 1.
After setting this up, you will have a new entity. You can use this entity in card or automations etc.
The below template goes into your configurations.yaml
template:
- trigger:
# trigger only once per day but it can also be recurring
- trigger: time
at: "01:00:00"
action:
- action: weather.get_forecasts
data:
type: daily
target:
entity_id: weather.openweathermap
response_variable: daily
sensor:
- name: Temperature Forecast Lowest
unique_id: temperature_forecast_lowest
state: "{{ daily['weather.openweathermap'].forecast[0].templow }}"
unit_of_measurement: °C