How often will this trigger fire?

If at 11PM the humidity is 90% and 11:15 it’s 96% will it run again? And if so, is there a way to prevent it from running more then once a day

It will not trigger at 11PM because 90% is not above 90% (it is equal to).

It will trigger at 11:15.

If at some later time the humidity rises from 96 to 97% it will not trigger again.

The automation only triggers when the humidity crosses from below to above 90%.

Thanks! Is there a way to prevent it from firing more then once per day if it goes below and rises above 90% more than once per day?

You could either do an input boolean that you turn on when it runs once, and then have an automation to turn it off at midnight, or you could use the last_triggered attribute of the automation to calculate how long its been since last run, though this is only useful for once per 1,2,4,24 hours etc, not once per calendar day.

1 Like

If you switch to YAML mode you can add this condition that will only allow the actions to run if 24 hours has elapsed:

condition:
  - condition: or
    conditions: 
      - condition: template
        value_template: "{{ as_timestamp(now()) - as_timestamp(states.automation.your_automation_here.last_triggered) | int > 86400 }}"
      - condition: template
        value_template: "{{ states.automation.your_automation_here.last_triggered == none }}"

Note that this will reset if you restart home assistant and allow the next trigger.

Similar to @tom_l 's approach I am using the following condition, to check if the automation has already been fired on todays calendar day:


  # automation was not yet executed today
  - condition: template
    value_template: >-
      {{ as_timestamp(state_attr('automation.your_automation_here','last_triggered'))|timestamp_custom('%d')
      != as_timestamp(now())|timestamp_custom('%d') }}
1 Like

Nice. Like it. What happens after a restart, when last triggered is set to none?

Tbh, I have not checked yet. I have just recently discovered that template in an older thread and included it in my automations. So far it is working great though, I may not have restarted home assistant to often.

Edit: Checking under Configuration/Automations most of my triggers have a last triggered underneath their name. Some of them are rarely triggered and show a date of 1-2 months back. I must have restarted in the meantime. So maybe your assumption is no longer valid

1 Like

I dont believe its reset on restart, I use these all the time to block stuff occurring more than once an hour/day/week etc, and I haven’t had these fire more than they should, and I sometimes restart HA a few times a day.

You should also use default(0) in there to cater for the last_triggered ‘None’.