Trigger when weather is Sunny for more than 5 minutes

I would like to close my window shutters when the weather is Sunny for 5 minutes. Always.

I have a trigger like this, but it looks it needs a change from x to Sunny.

platform: state
  - weather.forecast_home
to: sunny
  hours: 0
  minutes: 5
  seconds: 0


I’m not sure what your question is. Yes the trigger you shared will fire when the state of that weather entity changes from any value to sunny and remains in that state for 5 minutes.

Scenarios where it won’t fire but you might want it to could be:

  • when you first create the automation and the weather is already sunny: the state is already sunny so the trigger will never fire
  • when you restart HA and the state changed to sunny during the restart, or less than 5 minutes before restart: The trigger won’t fire because when the automation is loaded after restart the state of the weather entity is already sunny and therefore no change will be detected

If you want to cover the 2nd scenario you can add a trigger of ha restart, and add a condition of the entity being sunny for 5 minutes.

1 Like

When, that’s the problem: I need to trigger a Scene in which the shutters are closed whenever it “stays” in the Sunny state for 5 minutes or more. I’m sorry if it wasn’t clear in my previous message.

I haven’t seen anything to fulfill this requirement. I really need something like that to protect my furniture from the evil sunrays :slight_smile:

Thanks you!

you are right that the triggers happen when it goes from not true (not sunny) to true (sunny).

so the ha approach is for you to determine other events that would cause the shades to be open such that you need to close it. because if it closes after 5 minutes of becoming sunny from not sunny then why would you need to close it again? how did the shades come to be open again if it got closed at the very first 5 minute mark?

said another way, if it’s been sunny for 30 minutes you might say it should close now! but really it should have closed 25 minutes ago when the trigger happened. so then you may say, oh I temporarily opened it to look out a sec… If thats the case then you should add as a trigger “5 minutes after being opened”

@mekaneck was identifying a couple other cases where it might “miss” the not sunny to sunny transition… like on ha reboot or first save of the automation… so you would trap those events as well.

I suspect that if you catch those 4 events (shades open, reboot, first save, not sunny to sunny) you will have largely solved this question