Run automation only once every 24h

Hello,

I have made an automation to send me an e-mail once a humidity sensor is above 60.
This is working. But problem is that if sensors after 1 min goes back under 60 and than one minut later again above 60 I have everytime a new mail.

Now I want to receive only one mail every 24h. How can I program this?

This is the code I have that is working now.

alias: Notificatiemail luchtvochtigheid living boven 60%
description: Stuur een mail bij wanneer de luchtvochtigheid meer is dan 60%
trigger:
  - platform: numeric_state
    entity_id: sensor.living_humidity_2
    above: 60
condition: []
action:
  - service: notify.email
    data:
      message: >-
        De luchtvochtigheidsgraad in de living is gestegen boven de 60%.  De
        luchtbevochtiger uitzetten.
      title: Luchtvochtigheid living boven 60%
      target:
        - [email protected]
mode: single

Add the following Template Condition

condition: "{{ state_attr(this.entity_id, 'last_triggered') < today_at() }}"

The condition checks if the last time the automation executed its action was before the start of the current day.

Perfect thanks!

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

I have another question. What is the last_triggered status when I want to run the automation only once per year?

Is this correct?
condition: “{{ state_attr(this.entity_id, ‘last_triggered’) < thisyear_at() }}”

Home Assistant’s template functions are documented here and there’s no function called thisyear_at().

I suggest you do this:

condition: "{{ state_attr(this.entity_id, 'last_triggered').year < now().year }}"

I’ve been thinking about this but that will not trigger the automation when it should be.

I want a notification on my phone to inform me the first time when the temperature goes below a certain point. So that I have to disconnect water outside to prevent the tubes gets frozen.
At my location that’s mostly in october or november.

But when I use to see if it has been triggered this year than I will have this notification in january. But than I already have disconnect the water and I will not receive a new notification september/oktober.

So the automation actually should only run once between september and january.
I hope it’s more clear now for what I’m making an automation.

I suggest you create a separate topic because your latest requirements are substantially different than the original ones.