dimitripb
(dimitripb)
December 4, 2022, 3:31pm
1
I am using the Met.no integration for weather forecast and I already made a sensor for the temperature for tomorrow or the day after tomorrow:
- platform: template
sensors:
current_temperature:
friendly_name: "current temperature"
unit_of_measurement: 'C'
value_template: "{{ state_attr('weather.home', 'temperature') }}"
but now I want to create a sensor for tomorrow’s temperature at a specific time, like 5:00h in the morning. I cannot find any documentation how to query Met.no with a specific time. Any suggestions?
is a bit more complex, I am assuming your sensor has a section ‘forecast’ with hourly value
{% set x = state_attr('weather.home','forecast') | count %}
{% set pd = state_attr('weather.home','forecast') %}
{% for i in range(0,x) %}
{% if as_local(as_datetime(pd[i].datetime)) == now().replace(hour=5, minute=00, second=0, microsecond=0) + timedelta(days=1) %}
{{ pd[i].temperature }}
{% endif %}
{% endfor %}
3 Likes
dimitripb
(dimitripb)
December 6, 2022, 9:30pm
3
Thanks! I will try this next weekend, for hourly weather I have to use weather.home_hourly
dimitripb
(dimitripb)
December 23, 2022, 3:27pm
4
It took a while but it’s working! Thanks again!
Clearly then please mark my post for ‘solution’ to it can be seen by others searching for similar…thx
Unfortunately this solution does not work anymore since the service weather.get_forecasts
was introduced. The template editor gives me:
TypeError: object of type 'NoneType' has no len()
I found this, but don’t know how to get it working again:
This is my exact code that works on the latest HASS.io install, hope it helps.
template:
- trigger:
- platform: time_pattern
hours: /1
action:
service: weather.get_forecasts
data:
type: hourly
target:
entity_id: weather.forecast_home
response_variable: forecast_data
sensor:
name: Weather Forecast Hourly
state: "{{ forecast_data['weather.forecast_home'].forecast[0].temperature }}"
attributes:
forecast: "{{ …