Stop automation from looping

Hi,

I am setting up my first ever automation so be gentle with me.

I have a numeric sensor that triggers the automation when a value from a sensor has been within a certain interval for an hour. It works great except for the fact that it keeps on triggering every hour as long as the interval is within limits. I would like to add some kind of condition to say that it should only trigger again if it has not been triggered for 24hours.

Can I condition based on last triggering of an automation? How?

- id: '12345'
alias: Pellet level warning 50%
trigger:
- above: '0.7'
below: '0.95'
entity_id: sensor.ultrasonic_sensor
for: 
  hours: 1
platform: numeric_state
action:
- data:
  message: Det är cirka 50 procent pellets i tunnan
service: notify.slack_notify

Check out this thread. You can add a condition on the last triggered time of your automation.

1 Like

Would you mind sharing your code?
Please see the blue box at the top to make sure it’s formatted properly - otherwise subtle details like spacing, etc. might be lost.

I updated my post above. Thanks!

Thanks for the hint. I am trying this now, let’s see if it works.

`- id: '12345'
alias: Pellet level warning 50%
trigger:
- above: '0.7'
below: '0.95'
entity_id: sensor.ultrasonic_sensor
for:
  hours: 1
platform: numeric_state
condition:
- condition: template
value_template: '{{ as_timestamp(now()) - as_timestamp(states.automation.pellet_level_warning_50.attributes.last_triggered) | int > 86400 }}'
action:
- data:
  message: Det är cirka 50 procent pellets i tunnan
service: notify.slack_notify`

Seems like it is working now, thanks for the answers!