Using the default HA weather sensor (Meteorologisk institutt (Met.no)) I got the following so far:
alias: Tomorrow's Forecast - Rain
description: 'Check to see if there is rain forecast tomorrow, otherwise stope the automation until next trigger time.'
trigger:
- platform: time
at: '21:00:00'
condition: []
action:
- if:
- condition: state
entity_id: zone.home
attribute: forecast
state: rainy
then:
- service: notify.notify
data:
title: Tomorrow's forecast
message: >-
Tomorrow's forecast is {{ state_attr("weather.my_home",
"forecast")[1].condition }}
else:
- stop: No rainy forecast for tomorrow
mode: single
What I am trying to do here is to have every day at 9:00 pm, evaluate if tomorrow will be rainy forecast. If it is, then notify me on my phone. Otherwise, the automation stops/finishes.
The issue where I’m getting it is at the “if” part of the automation.
You’re complicating things here just a little. Try to go one or two steps back and use “normal” automation functions.
alias: Tomorrow's Forecast - Rain
id: Tomorrow's Forecast - Rain
description: 'Check to see if there is rain forecast tomorrow, otherwise stope the automation until next trigger time.'
trigger:
- platform: time
at: '21:00:00'
condition:
- condition: template
value_template: "{{ states.weather.my_home.attributes.forecast[1].condition == 'rainy' }}"
action:
- service: notify.notify
data:
title: Tomorrow's forecast
message: "Tomorrow's forecast is {{ states.weather.my_home.attributes.forecast[1].condition }}"
mode: single
This does:
trigger at 21:00h
check, if tomorrows forecast is rainy (Note: check the exact states, I’m quite sure there are other states than “rainy” that are used for a rainy condition!)
send a notification
If the condition isn’t met, the following action part will not be used, so no need to do anything more. Following on this, it is not necessary to “stop” an automation. It ends after the action part is done, or it ends after the condition, if it isn’t met. All done!
If you want to enhance on this, let’s say start another service to close a window or a door (just an example), add it after (or before) the notification.
EDIT: changed the weather entity from weather.my_weather to weather.my_home