Weather Forecast template

I’m fairly amateur at HA, though not unfamiliar with very basic php etc coding.
Pretty much everything else is configured in the UI so yeah, i dont have a 2nd 'template: ’ entry…

I understand i need to create a directory and switch to a directory merge include for templates moving forward for future additions.

That is one way, the other is to name the file more generic (templates.yaml) and put more templates in there .

Good morning, I have same problem. I used David code. I restarted HA but [sensor.min_forecast_temperature_hour_in_next_day] have unknown state.
Thanks

Did you replace this with your weather entity in ALL places it is mentioned, and did you check that your weather entity supports hourly forecasts?

1 Like

ok I replaced in all places my weather entity. My weather entity supports hourly forecast. I receive now
sensor.massima_domani = 11.3
sensor.minima_domani =
11.3 isn’t max temperature of tomorrow!!! Where am I going wrong?

this is my code:

- trigger:
    - platform: time_pattern
      hours: "/1"
    - platform: homeassistant
      event: start
    - platform: event
      event_type: event_template_reloaded
  action:
    - service: weather.get_forecasts
      target:
        entity_id: weather.tomorrow_io_casa_daily
      data:
        type: hourly
      response_variable: forecast
  sensor:
    - name: "Minima_domani"
      unique_id: Minima_domani
      state: >
        {% set tomorrow_forecast = forecast["weather.tomorrow_io_casa_daily"].forecast[1] %}
        {{ tomorrow_forecast.templow if tomorrow_forecast else 'N/A' }}
      attributes:
        state_class: measurement
        unit_of_measurement: °C
        icon: mdi:thermometer
    - name: "Massima Domani"
      unique_id: Massima Domani
      state: >
        {% set tomorrow_forecast = forecast["weather.tomorrow_io_casa_daily"].forecast[1] %}
        {{ tomorrow_forecast.temperature if tomorrow_forecast else 'N/A' }}
      attributes:
        unit_of_measurement: °C
        state_class: measurement
        icon: mdi:thermometer-high

Thanks for answers.

Hadn’t looked at what the template actually was supposed to to. But hourly gives you… next hours. So change the type to daily if you want to know the forcast for other days.

Also, ‘N/A’ is not something you should be setting on a numerical sensor. Use an availability template to determine if the sensor can return proper data.

1 Like