Skip every second week

Hi, I want to set a automation which reminds me 14 days in a row and skips the next 7 days. My first try used now().isocalendar() with a startweek and modulo. But it will break every year as the week number resets.

Save the time in an input datetime helper every time it runs and use that in a template trigger with a delta of 14 days. You will need to give the input datetime an initial value.

How about a counter set at 14, each reminder makes the counter count down.
When the counter is 0 then set a new date when it should start counting as a helper.

Something like this:

description: ""
mode: single
trigger:
  - platform: time
    at: "09:00:00"
condition:
  - condition: numeric_state
    entity_id: counter.counter
    above: 0
  - condition: time
    after: input_datetime.alarm_time
action:
  - service: tts.cloud_say
    data:
      entity_id: media_player.player
      message: Reminder
  - service: counter.decrement
    data: {}
    target:
      entity_id: counter.counter
  - choose:
      - conditions:
          - condition: state
            entity_id: counter.counter
            state: "0"
        sequence:
          - service: counter.configure
            data:
              value: 14
            target:
              entity_id: counter.counter
          - service: input_datetime.set_datetime
            data:
              timestamp: "{{ as_timestamp(now() + timedelta(days = 7)) - 3600 }}"
            target:
              entity_id: input_datetime.alarm_time
1 Like

You could still use modulo, but just convert the timestamp to weeks, so it ignores new years.

{{ (now() | as_timestamp / 60 / 60 / 24 / 7) | int % 3 }}

Another variation based on this: Again use a counter, but just keep incrementing it day by day and do a modulo 14. Even with an int you’re not going to run out in a lifetime. Option A by Hellis is perhaps better if you want to see “days until” on a dashboard.