I want to create an automation to alert me if there is snow expected in the next 5 days. Don’t know how to write yaml and used chatgpt. I’m unable to get the notification to tell me what day(s) snow is expected. I am using weather.com. This is the closest I’ve come
alias: Snow in Next 5 Days (Weather.com)
triggers:
- at: "4:00:00"
trigger: time
conditions:
- condition: template
value_template: |
{% for day in forecast[:5] %}
{% if day.condition in ['snowy', 'snowy-rainy'] %}
{{ true }}
{% endif %}
{% endfor %} {{ false }}
actions:
- action: notify.mobile_app_iphone
data:
title: Weather Alert!
message: Snowy conditions expected in the next 5 days.
variables:
forecast: >
{% set f = state_attr('weather.home', 'forecast') %} {{ f if f is not none
else [] }}
mode: single
Are you sure your weather.home has an attribute forecast? Unless that’s a Template weather entity that you created, it is very unlikely. The forecast attribute was removed well over a year ago.
Weather.com is not covered by a core integration, so you need to tell us what custom integration you are using for us to help.
Thanks for your help. Yes that is the correct integration. Both automations work to notify me of snow in the next 5 days. Is there a way to have the notification say specifically what day the snow is expected on (monday, saturday ect.)?
You can find and test actions that are available on your HA instance using the Action tab of the Tools dashboard. Once you have found the action/service that corresponds to your device, use that ID to replace notify.mobile_app_iphone in the automation.
Also, keep in mind that your weather entity may have a different entity ID than weather.home, so you’ll need to check that as well by searching for it in the States tab of Tools or the Entities dashboard.