Wind speed alert help?

I’m building a wind speed alert automation. If tomorrow’s wind speed is above 20mph, send me an alert. However, I can’t figure out how to trigger based on tomorrow’s forecast.
Via the UI:
Trigger type: numeric state
Entity: weather.openweathermap
Attribute: Forecast
How do I tell the automation which forecast day to choose? The object attribute is “new_state.attributes.forecast.1.wind_speed” but the automation UI doesn’t expose that anywhere?
Thanks for your help!

The challenge here is that you need to use some logic to accomplish it. I can’t speak to Home Assistance automation features because tbh when I was faced with having to do some logic I eventually converted over to Node Red full bore and haven’t looked back. Using Node-Red you can write a quick function to pull out which day you are looking out of the main weather object. See the picture below.

Now with that said, what I do is have Node-Red check the wind every 15 minutes. If it’s above 10 mph I have it perform an action. Little different from your ask but there is a lot of flexibility there.

Thanks Martoq-
Yes I started with Node-red to identify the object attribute, since developer tools and automation UI don’t show it. But…how do people do this without node-red? Node-red can be overly complex.

I’m trying to learn HA automation basics…where do you specify object attributes in the automation UI??
And I’m trying to avoid using raw YAML. There HAS to be an obvious thing I’m missing here, otherwise the UI is way too limiting.

I don’t see how to specify which forecast day, for example, here:

Haven’t done this myself, but this template appears to have worked for some, based on a forum search:

value_template: {{ state_attr('weather.openweathermap', 'forecast').1.wind_speed }}

OK - just tested this and this format works. My forecast data doesn’t have wind speed, but if I ask for temperature it returns tomorrow’s expected temp.

Thank you!
Wow, zoogara, I guessed the “value template” had something to do with choosing which object attribute. But…How is anyone supposed to know this? A good UI has drop-down options like Node Red usually does! see below, the “Property” box unveils every single object value:

The automations UI shows no object attribute to select from.

Developer tools does reveal object data under “weather.openweathermap” under state attributes, but doesn’t yield format to enter into “Value template” as you show. You need an arcane weird format to reference it. How do you access this weird data template?

This pertains to ANY object I want to reference using automations UI.

Here is the raw object data for “weather.openweathermap” from the Developer Tools section, but it’s useless to copy/paste the entity into the automations UI:

The easiest way to do this would be to create a template sensor for tomorrow’s wind speed. Then you can use this sensor to create your automation in the UI.

  - sensor:
      - name: "Tomorrow's Wind Speed"
        unique_id: tomorrows_wind_speed
        state_class: measurement
        unit_of_measurement: km/h
        state: "{{ state_attr('weather.openweathermap', 'forecast')[1]['wind_speed'] }}"

Yes - create a new template sensor for it as suggested by @jazzyisj - that way you can easily use it both as a trigger and reference it in any alert you generate.

You could template it directly in the automation - but it will get a bit messy when you start doing the alert.

Jazzyisj thank you. I also found a reference how to make a sensor.yaml and make a template.

My underlying question is how does one find the state_attr information referenced. I need to figure this out for many other automations. The {{ }} data entry itself, what is it? JSON? Your format above is different from Node Red’s which is different from Zoogara’s:
{{ state_attr(‘weather.openweathermap’, ‘forecast’).1.wind_speed }}
{{ state_attr(‘weather.openweathermap’, ‘forecast’)[1][‘wind_speed’] }}"
or Node Red’s

?? Can I derive the proper Yaml formatting from Node Red (which actually TELLS me all the objects attributes? Where is this formatting found for ANY object?


“forecast” is the attribute name. This forecast attribute is a zero base array of values. With the template I provided you are asking for the wind_speed value for the second element (“1”). Element 0 is today, 1 is tomorrow and so on…

The two versions of this template you posted are equivalent. I prefer the notation I used, but either works.

The template format is Jinja - there is a link to the Jinja documentation in the Templates doco.

Both array formats are equivalent.

The developer docs tell you about the data structure of objects from various integrations - the documentation for HA also has numerous examples of templates for various attributes.

Lastly, please format your posts as per the recommendations in this:

For instance any YAML or template post using the </> format button in the toolbar when you are composing the post - it will make things easier to read and also encourages some of the grumpier regulars to be more helpful. :slight_smile:

I’m using NodeRed now to do this. May I ask how you can send an email to myself containing the forecasted weather value?
I’m trying to send “new_state.attributes.forecast.1.wind_speed” via notify:

The JSON Data field won’t accept the object value though:
{“message”:“This is tomorrow’s wind speed”,“title”:“Wind Speed tomorrow”,“data”:new_state.attributes.forecast.1.wind_speed}

Am I formatting the forecast variable wrong?

{"message":"This is tomorrow’s wind speed " & msg.new_state.attributes.forecast.1.wind_speed & " <some unit here>","title":"Wind Speed tomorrow"}

If I’m not mistaking.

Thank you-- I get error message “The literal value 1 cannot be used as a step within a path expression” which I guess refers to the “1.wind_speed” part.

I tried replacing the “1” with [1] and error went away, but no value appeared…so it’s not fetching the correct object value.

I’m just using what you said the message looked like.

I assume you have a current state node? Connect a debug node to it and set it to complete message.
Run the “code” and loon in the debug window, find the value you wanted and hover at it.
On the right a few buttons appear, click on copy path.
Then replace the message path with this path.
You will probably need to add msg. before you paste.

Bingo! This works using the “email” node and passing this object value to that. Thank you!

FYI for anyone attempting similar. I used the “change node” to calculate a new payload value, converting from meters/sec to miles/hour:

"Tomorrow wind speed is " & (payload)*2.24 & " m/h"