Execute automation only once per day

Hi,
is there a way to execute the automation only once per day (when the trigger hits)?
because now when I leave the office for one hour and then returns, it creates a second calendar item.

alias: to the office
description: ""
trigger:
  - platform: zone
    entity_id: device_tracker.johnprivatephone
    zone: zone.work
    event: enter
condition: []
action:
  - service: google.create_event
    data:
      in:
        days: 0
      summary: In the office
    target:
      entity_id: calendar.john_gmail_com
mode: single

you can add a template condition with this template:

{{ (state_attr('automation.to_the_office', 'last_triggered')|as_local).day < now().day }}
2 Likes

This is brilliant! Works beautifully!

ist the trigger reset 24 hours after it was triggered or is the reset on midnight (0 o Clock)?

the “now().day” value changes at midnight. so it’s a once per calendar day trigger not a once per 24 hours trigger.

1 Like