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 }}
3 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

Hey folks - New to HA, but so far really digging it!

I have similar case - or perhaps I think so. I have relatively simple automation that closes window shades when a temperature sensor goes over 75 degrees for 10 minutes (see YAML below) .

I guess my first question is, in HA do I need to limit this to run once per day? In the Alexa app, a similar routine would re-trigger throughout the day - I could see the shade hub up blinking, but since the shades are already closed nothing would actually happen. So far I’m not actually seeing this as an issue in HA. For example, this morning the automation triggered at about ~11am and has not re-triggered.

Cheers,
Jonathon

alias: Dining Room > 75 then close shades
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: 4046a46684d6a9fdc3cf573ea1598c4e
    entity_id: 68cd1d13f64f50373d84b94163ecdb4d
    domain: sensor
    above: 75
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - action: scene.turn_on
    metadata: {}
    target:
      entity_id: scene.stewart_powerview_hub_all_shades_closed
mode: single

The trigger will fire every time the room temperature goes from below 75 to above 75, if the temp stays above 75 throughout the day, there will not be any more trigger events.

If the temperature goes back and forth crossing the 75 degree threshold throughout the day, and you don’t want it it try to execute the scene action every time that happens, you should add a condition. You will need to decide which condition is appropriate for your situation. It could be the automation execution time based option shared above by finity or a simple state condition to check whether the shades are open.