Is there a simple way to have an automation that runs every other day?

It feels like to me having a trigger that says every ODD numbered day or something simple like this should be built into triggers. But I don’t see anything like that without doing some complex script with variables and such.

Is their an easy way to do this or an add-on that makes it simple?

Without knowing what you are trying to do, every 36 hours is one option.

Using a template condition with something like this might be an option:
{{ ((now().day / 2) | int) == (now().day / 2 ) }}

3 Likes

The simplest method is probably to just flip a boolean back and forth.
But of course some day the automation that does this might fail.
And it won’t work for every third or similar.

The absolute simplest (set up from the UI) is a repeating calendar event:

2 Likes

I was thinking of that… but again that feels more complex than it should be.

Is that an option can you do that? Can you say if something hasn’t been ON for 48 hours then turn it on for example?

My goal is to have a plug that comes on every other day at 9AM. It goes off once the current draw of what it is charging is done. So the off part I have figured out but the only coming on every other day i don’t have figured out.

Create a recurring local calendar event: Is their a simple way to have an automation that runs every other day? - #5 by tom_l

The use the calendar start event trigger. Automation Trigger - Home Assistant

1 Like

Sure.
But I actually think Toms suggestion is a safer method.

This turns it on after being off for 48 hours, but if you restart HA or connection temporarily ia lost to the switch then this restarts the counter.
The off trigger might need to be a numeric below something instead.

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - switch.something
    to: "off"
    id: "on"
    for:
      hours: 48
  - trigger: state
    entity_id:
      - sensor.something
    to: "0"
    id: "off"
conditions: []
actions:
  - action: "switch.turn_{{ trigger.id }}"
    metadata: {}
    data: {}
    target:
      entity_id: switch.something

This is the simplest way anyone has come up with that works flawlessly every time. There are no issues with reboots or resetting logic variables. It’s just a straightforward and easy-to-use solution.

The only thing I didn’t realize until after setting it up was that you can’t use one calendar to have events for multiple triggers.

When you trigger an event, you can only specify when an event happens in that specific calendar. You can’t say for events in the calendar named “X” to do one thing and for events called “Y” to do something else.

So, don’t use generic named calendars for automation purposes. Instead, name them based on the specific automation they’re intended for.

Once I understood this, I just created a new calendar with the correct name.

Thanks, Tom! This is a great solution to my problem.

Joe

1 Like