Automation with open-meteo condition

dear all,
I added the open-meteo integration.

the information I get is as the following:
developer tools / attributes:

temperature: 16.2
wind_bearing: 47
wind_speed: 6
forecast: 
- datetime: '2022-05-03'
  condition: cloudy
  precipitation: 0.04
  temperature: 17.3
  templow: 8
  wind_bearing: 93
  wind_speed: 9.8
- datetime: '2022-05-04'
  condition: lightning
  precipitation: 0.82
  temperature: 16.9
  templow: 9.2
  wind_bearing: 247
  wind_speed: 24.7

I get the rain forecast from today with the following:
{{state_attr('weather.open_meteo','forecast')[0].precipitation}}

Result type: number
0.04

Now I want to have an automation with this value as condition and I do not know what to enter to get the attributes value.

- condition: numeric_state
  entity_id: 
  below: '1'

Can somebody give me a hint how the condition has to look like?

thanks a lot!

Use a Template Condition.

  - condition: template
    value_template: "{{ state_attr('weather.open_meteo', 'forecast')[0].precipitation < 1 }}"
1 Like

cool, thanks a lot!
I will try this

This was exactly what I needed! Was banging my head against this data, and the trick was state_attr to reach the nested data.

I ended up with this to iterate over the forecast data and return true if there was something wet in the forecast for the week. Could apply to the rest of the values in the forecast array, such as a rolling 3 day average forecast temp etc.

template:
  - binary_sensor:
    - name: "Forecast Precipitation This Week"
      state: >
        {% set forecasts = state_attr('weather.open_meteo','forecast') %}
        {% set forecastedRain = namespace(thisWeek = false) %}
        {% for i in forecasts %}        
          {% if i.precipitation > 1 %}
            {% set forecastedRain.thisWeek = true %}
          {% endif %}
        {% endfor %}
        {{ forecastedRain.thisWeek }}
      unique_id: 'forecast_precipitation_this_week'

Thanks for the helpful post!

1 Like

Hi,

I know old thread,
Only brief look at this & not so experienced wit hHA but is there a way to get more info from open-meteo
i.e Hourly info on rain or even solar etc.
I am guessing a limitation of the API but thought would ask.

I use the API & call from visual basic & can get everything that open-meteo produces but not sure if can access this sort if info from HA.

thanks I/A