Precipitation_Probability with .get_forecasts

Hi,

First time asking for help here, so go gentle on me!

Trying to do something which I’d have thought would be super simple but having no luck at all. I’m trying to get the probability it will rain tomorrow (or otherwise) in order to inform wether to run an automated watering system or not.

I’ve modified a template from the official docs at Weather - Home Assistant (Example template sensor using get_forecasts) and come up with the following:

  - trigger:
      - platform: time_pattern
        hours: /1
    action:
      - action: weather.get_forecasts
        data:
          type: daily
        target:
          entity_id: weather.forecast_home
        response_variable: daily
    sensor:
      - name: Rain Probability Tomorrow
        unique_id: rain_probability_tomorrow
        state: "{{ daily['weather.forecasthome'].forecast[1].precipitation_probability }}"
        unit_of_measurement: "%"

This continutes to report ‘unknown’ pretty much however I tweak it or change it, and I can’t really see anything wrong.

So questions 2 really:

  1. what have I got wrong? if it’s glaringly obvious to anyone
  2. how can I sensibly go about debugging this, is there an obvious place in the logs which will show when this template runs what data is being returned (or otherwise) in the ‘daily’ response variable or report what’s not working correctly.

Thanks for all your help, I’m still getting my head around a lot of this stuff.

Mark

target:
  entity_id: weather.forecast_home
----------------------------^^^

but

state: "{{ daily['weather.forecasthome'].forecast[1].precipitation_probability }}"
--------------------------------^^^

Hi,

Fairly sure that was just a typo when putting back the last thing I tried (which didn’t work) before copying into the forum, but will correct that now and check it.

As expected, that’s not made any difference (although as you say it definitely wouldn’t have worked like that) - any other ideas?

Thanks,

Mark

Hi all,
Same issue here.
I noticed that action weather.get_forecasts in general doesn’t have that field precipitation_probability despite the documentation.

Any changes recently?
Should it be visible if calling automation in GUI?
If I try to get some other values which are available in a GUI, such us temperature or humidity it does work. But not the precipitation_probability.

Also, another question. How to get maximum forecasted temperature daily? There is a templow which I can get. Does something similar exist for temphi?
Thx

It depends what your weather provider provides. If they don’t supply a probability, HA can’t invent one.

Also, it depends what your weather provider provides. You could create one from an hourly forecast. Using “Copy to clipboard (template)” on the Actions tab for my weather entity, to create a temphi equivalent from tomorrow’s forecast entries:

Template I used, modified for your weather entity, is:

{{ action_response['weather.forecast_home']['forecast']
  |selectattr('datetime','match',(now() + timedelta(days=1)).date()|string)
  |map(attribute='temperature')|max }}

Hi Troon,
Indeed, it all depends on weather provider.
I was talking about Home Assistant default one: Meteorologisk institutt (Met.no)
So is it known that they stopped providing this data? Such as precipitation probability? Yesterday I created several custom sensors. All of them works but precipitation probability. So I suppose they stopped provided this info. Unless I’m doing something wrong.
What about max temperature, Thank you very much for your idea. I’ll check it out later today. So far I’m playing with various weather providers. Trying to find the one which has forecast data I need.

The HA integration appears not to reference that data field, so if met.no provide it, HA isn’t using it. That seems unlikely, so I suspect they’re not providing it.

1 Like

Wow. Exactly like you explained. Thanks a lot.

1 Like

If you don’t want to mess around with trying different providers blindly, the Accuweather integration provides all 3 reports in the forecast out of the box:

  forecast:
    - datetime: "2024-10-16T05:00:00+00:00"
      cloud_coverage: 35
      precipitation_probability: 1
      uv_index: 4
      wind_bearing: 110
      condition: partlycloudy
      temperature: 26.1
      apparent_temperature: 28.8
      templow: 20
      wind_gust_speed: 29.6
      wind_speed: 11.1
      precipitation: 0
      humidity: 72

Note that the temperature in this case is the max temperature (as referenced in the docs in your first post), so you should be covered for all scenarios.

For the sake of learning new stuff. Would you have an idea why it won’t work from my templates.yaml like this?
So I created two actions, one hourly, one daily. Two variables to work with them.
First sensor, which simply show lowest temperature forecasted for today works.
Second sensor, however shows “unknown” state.
It literally suppose to do the same like in template editor. Take entire forecast by hours, filter only those records which has a datetime from now plus one day and then select only temperature attribute and then take max value of it.
And yet it says “unknown” state for the sensor.

- trigger:
    - platform: time_pattern
      minutes: "/1"
  action:
    - action: weather.get_forecasts
      target:
        entity_id: weather.forecast_home
      data:
        type: daily
      response_variable: weather_forecast_daily
    - action: weather.get_forecasts
      target:
        entity_id: weather.forecast_home
      data:
        type: hourly
      response_variable: weather_forecast_hourly

    - variables:
        my_forecast_daily: "{{ weather_forecast_daily['weather.forecast_home'].forecast }}"
        my_forecast_hourly: "{{ weather_forecast_hourly['weather.forecast_home'].forecast }}"

  sensor:
    - name: Minimum Temperature forecast today
      unique_id: Min_Temperature_forecast_today
      state: "{{ my_forecast_daily[0].templow }}"
      unit_of_measurement: °C

    - name: Test forecast today
      unique_id: 9a220316-fdbf-4299-9562-e55c60c26213
      state: >
        "{{ my_forecast_hourly
        |selectattr('datetime','match',(now() + timedelta(days=1)).date()|string)
        |map(attribute='temperature')|max }}"
      unit_of_measurement: °C

How do you get those data? Out of the box I have a lot of sensors but not like those. For instance, a lot of sensors for real feel temperature but no templow.

You need to switch to use the Accuweather Integration instead of the default Met.No.

Beyond that, I didn’t do anything special to get them in the forecast response. At most, if you still don’t see them after having switched, check the integration page that your sensors aren’t disabled (I had to disable around 80 sensors, because there was way too much data for what I needed).

Разобрался сам. Вот рабочий вариант.
Беру значения температур за сегодняшний день, а не за последние 24 часа.
Помогли логи Home Assistant. Где он собственно писал, что не так. Собственно главная проблема была он не мог string во float преобразовать

- trigger:
    - platform: time_pattern
      minutes: "/1"
  action:
    - action: weather.get_forecasts
      target:
        entity_id: weather.forecast_home
      data:
        type: daily
      response_variable: weather_forecast_daily
    - action: weather.get_forecasts
      target:
        entity_id: weather.forecast_home
      data:
        type: hourly
      response_variable: weather_forecast_hourly

    - variables:
        my_forecast_daily: "{{ weather_forecast_daily['weather.forecast_home'].forecast }}"
        my_forecast_hourly: "{{ weather_forecast_hourly['weather.forecast_home'].forecast }}"

  sensor:
    - name: Minimum Temperature forecast today
      unique_id: Min_Temperature_forecast_today
      state: "{{ my_forecast_daily[0].templow }}"
      unit_of_measurement: °C

    - name: Test forecast today
      unique_id: 9a220316-fdbf-4299-9562-e55c60c26213
      state: >
        {{ my_forecast_hourly 
        | selectattr('datetime','match',now().timestamp() | timestamp_custom('%Y-%m-%d'))
        | map(attribute='temperature')
        | max }}
      unit_of_measurement: °C
  1. English please
  2. Do NOT call the get forecast service every minute! You will spam the provider API & get blocked, or worse, piss off the provider & cause issues for the entire HA community.

If you’re fetching hourly forecasts, calling the forecast service once an hour should be more than enough.

  1. Sorry, should have forgotten to switch between languages.
  2. 1 minutes just for a tests. Indeed in real life I call it every hour.
1 Like